We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Analysis Summary
Worth Noting
Positive elements
- This video provides a clear, conceptual introduction to Lisp syntax and the benefits of immutable data structures for developers coming from Java or C# backgrounds.
Be Aware
Cautionary elements
- The speaker uses 'revelation framing' to suggest that Clojure's syntax is a barrier that, once overcome, grants superior insight into software development.
Influence Dimensions
How are these scored?About this analysis
Knowing about these techniques makes them visible, not powerless. The ones that work best on you are the ones that match beliefs you already hold.
This analysis is a tool for your own thinking — what you do with it is up to you.
Related content covering similar topics.
Datomic Cloud - Datoms
ClojureTV
The Taming of the Deftype Baishampayan Ghose
Zhang Jian
Exercism Summer of Sexp - solving challenges with Clojure
Practicalli
A Primer on Match Expressions in Scheme - Learning Guile Scheme
System Crafters
Debugging Clojure with Conjure and Neovim
Olical
Transcript
good morning everyone my name is Mario I'm gonna go ahead and go around the room everyone please introduce yourselves I'm sorry I'm just kidding so why are you here yeah why are you here it's Saturday what are you doing here seriously what are you here I don't know why you're here and that's your business why I am here is because I want to come on do it there you go I want to talk about how I taught myself to read a language called closure so I'm a developer from st. Louis I have been doing programming for a long time since the 90s something's and I'm involved in a user group in st. Louis I organized a group called the lamda lounge Landa lounge is a group that is a collection of people that have an interest in functional and dynamic programming languages I've got a long history with the Ruby programming language which is an object-oriented imperative programming language but I've also always been interested in functional programming languages and closure is a functional language the my interest in learning languages is something that I have had for a long time and it's something that's influenced my development style as a as a programmer thinking about problems in different ways helps me change and adapt and I think be a better programmer closure is a language that does not look like any language that I had ever programmed in before closure is a lisp let me get a show of hands who in this room knows lisp any of the lisps a few folks not a lot for everyone else everyone else provably you're in some kind of an imperative programming language Java C sharp raise your hand something like that maybe how about other functional programming languages Erlang Haskell closure anyone Scala thank you okay so what I want to do is kind of go over how the closure programming language syntax works and hopefully once you can wrap your your eye around the way that it works the ideas that are part of the language that was designed by a really smart developer named rich Hickey who is building on ideas that have been around since the 50s that those ideas will trickle in and hopefully find a place in your head and inform you in terms of how you approach developing software so what I want to do is start off with object-oriented languages so in oh oh you've got nouns nouns are like the predominant concept in object-oriented languages where nouns are these concepts that you might model as classes and those classes may have relationships with other nouns and what the nouns do is they verb other nouns where you might have a user which is a noun and the user has emails email is another noun and you might associate an email with user by setting the user the users email you might also have a pitcher so pitcher pitches so you've got a noun verbing a batter with a curve more specifically you might say that the pitcher pitches a curve ball to a batter so you've got nouns verbing other nouns so yeah now it's verbing other nouns the way that the io languages tend to be read is left to right you've got and it's very readable I mean the it's naturally to at least to the Western I reading from left alight left to right makes a lot of sense you can read exactly what's going on the pitcher pitches a curve ball to the batter easy to understand so oh you've got this set of concepts that are objects or instances of classes that are these concepts and those objects they have relationship to other objects and the way that they interact with other objects is objects are through messages the the verbing is all messages where you're invoking some kind of a behavior that's been associated with an object by means of calling some kind of a method or something like that so that's how it works closure though is a lisp closure is not an it's not an oo language the the basis of closure instead of objects is parentheses so I'm sorry indeed I think actually does so you can thank John McCarthy for that anyway so lisps have parentheses and so what what closure does come on animation yep so what closure does is it takes those parentheses and wraps them around everything to make lots of lists in closure you've got this there's a distinction between two concepts that actually kind of bleed into each other you've got code and you've got data where code is a thing that operates on data but code can also be represented as data in fact you can interpret code as data and data as code it's this sort of snake eating its own tail thing with closure that's actually very powerful come on okay so closure deals in lists in lists of all kinds of things the parentheses are these things that bound the contents of your list so the things that are in lists of things you can have all kinds of stuff in list but these are some of the examples of the kinds of Lists that exist in closure so one kind of lists are lists that are represented with parentheses the little single quote at the beginning of it I'll explain what that is in a second another kind of list is a vector so a vector is just a list that has these square brackets you've got another kind of list that's a set so sets are lists that have unique items you can't have more than one of an of a particular kind of item in the set you also have maps that are key value pairs so one of the things about lists in closure in fact in closure in general is that things that are sort of white Spacey really aren't necessary closure doesn't care about it considers commas as whitespace and it doesn't really care you can put commas in there if you want to but the language doesn't care it's just not part of the syntax and this example of the map is not really a good one but you can have numbers as the keys and values in your map but this is probably more common something that you would see something that's where you've got a key of hands and value of two and then a key of limbs and a value of four I'll explain what those colons are in a second but all of these things are lists of items and Lisp is Lisp and closure are full of these things everything is evaluated in the context of some kind of a list so these collections are what are called persistent data structures all of the ways that closure has of managing data structures is treating them as persistent data structures so let's talk about what that means what this what's going on here is that we've got a function so we've got a function called concat and concatenate this function is evaluated what comes out is a sequence of the values one two and three so you have three different data structures here the first data structure is one to the other data structure is three vector of three and then the third data structure is the sequence of one to three closure does not change the contents of lists of the data structures data structures are immutable whenever you modify a data structure whether it is a list or a set or a vector or a map well you actually get back in the modification is a brand new collection that has all the contents of the old one plus whatever changes you've made in whatever your the operation that you applied on that collection one of the advantages of that and there's actually kind of a big idea one of the most challenging problems in programming is mutable data when you have some collection of data that could change based on any kind of interaction tracking down what is causing that change and guarding it is something that we spend non-trivial amount of time on one of the things that the closure language gives you for free basically are these data structures that will never change if you have a reference to a particular data structure that has some data in it it'll always be there for as long as you are looking at it you can make changes to it but what you get back in that changing operations is a pointer to a different data structure that has the original data plus or minus whatever the effect of the change was so in that way they're persistent it doesn't mean that they're persistent in the sense of like a database they're persistent and in that they are always the same so in closure data structures are declared they are not assigned you don't have in as in imperative languages where you may have something equals something else closure doesn't work that way when you have data structures you declare them by some kind of name so I've got a data structure here that I have called Mario's favorite Lang's and it's a vector that has these two values Ruby and CoffeeScript what I can do with this data structure is that I can see what its value is so it's value is Ruby and CoffeeScript I can also call a function that's going to try to change the data structure by reassigning whatever is at the first index of the data structure index 1 which is the second position change its value from whatever it is into closure and so then what comes out of that is a brand new data structure that has Ruby and closure but my original one is still intact that'll always be there anything that is holding on to that original one will always see those two values so manipulated manipulating data structures enclosure yields new data structures closure is a functional programming language so where closure deals in lists of things the lists are operated on by functions in other languages you have objects classes and methods in functional programming languages you've got functions you don't have classes you've got functions so let's have a look so what I have here is something that looks like it's inside of a list so closure uses parentheses to denote the scope of something that's going to be evaluated so this could look like a phone off this could look like a list but it's actually a a sequence of values that are going to be evaluated as a function so the way to read this is as with the oo left-to-right paradigm it works the same way it reads and R evaluates left to right in this example you've got this function pitch that takes these two parameters ball and batter pitch ball and batter are three symbols in the language that point to you'll have to just trust me they point to a function and then two data structures but they don't necessarily have to be two data structures they're just two other things these two things ball and batter are being passed in to the function pitch so this is the style of function invocation is called prefix notation so we're in an imperative language you may an imperative language that uses in fix notation you may see something that's like two plus five in prefix notation the function that you're applying to the parameters is the first argument and everything that follows are arguments into that function this is one of the things that for me was it took a while to get used to but I mean not just the function goes first because it's just not how you learn things in school and not how I learned things but the function going first and then the parameter second once I got used to that concept is first is the thing that you're doing and everything else is what you're doing it to then my I could read the language a lot better also the thing about parentheses so far I've only shown you a couple I'm gonna show you a lot more later on but they tend to melt away that's one of the things that for me when I first would see languages like closure or Haskell that would see things that my I just couldn't like parse but eventually I started making sense of what I was seeing and the things that are just that set the boundaries they were just sort of melt away okay so that's prefix notation when so here are more parentheses here we have another set of function calls but these are nested function calls where the the previous example I showed you is evaluation of left to right when you've got nested function calls it's a little bit different it's really more kind of like evaluating inside out and there's a reason for that so what's going on here is that there's a function called generate count that I'm going to pass whatever this thing is in the middle plus this other thing this is going to be a thing and inning is is a thing but the thing that's in the middle is another function call so the way that closure figures this out is it says okay you want to invoke generate count and you're going to pass in something in order to do that I've got to figure out what's going on then on the inside so the inside is this function called pitch that's being passed ball and batter so the way that closure reads this is it starts from the inside of the thing figures out what the return value is of pitch ball to batter and then the return of that is going to be the parameter for the outside call generate count so once it figures out what pitch ball batter returns then it's going to invoke generate count with that return value plus whatever inning is so one thing to remember is your eye is a muscle is that really a muscle but let's just say that it is a muscle closure definitely treats your eye as a muscle because one of the things that is going to help you do is it's going to help you get your muscles stronger going left to right with closure you're going to be looking left to right all the time because you're gonna have to figure out you're gonna go into the function and they're gonna have to go back go back out wait what is this really doing and then you go back in what's going on here and go back out so your muscles gonna get really strong you're gonna have like bulging eye pecs right okay so things that can go into lists so there are a number of things can go to lists numbers a thing called keywords I'll explain those in the second symbols and other lists you can put everything in lists lisps love lists alright so let's talk about numbers so closure is a language that has numbers it has integers everyone knows about those floating points closure is one of the few languages that I know of that has rational numbers I think this is awesome rational numbers are the things that we learned in elementary school that no programming languages that I've used before now use and they're I'm so I'm I'm not a mathematician perhaps in Mathematica or other mathematically oriented environments rational immersion just like a thing is like whatever then the rest the world just didn't catch on to it but this is fantastic that there are numbers that can be represented just simply like that and the programming language can work with that that's fantastic closure is something that can also do number promotion so one thing I have forgotten to mention until now is that closure is a language that runs on the JVM yeah JVM Java super so one of the things that that gives you is access to the entire Java ecosystem Java is a language that has these primitive numeric types instant floats and doubles and then object wrappers that wrap those things so closure is a language on top of the JVM that can deal with either numbers as as the regular integer values but can also promote things because in Java you've got numbers intz that have a range of values that they can hold that pass those they'll overflow into the negative space and closure can do that but it can also promote numbers once they get past the storable range for one kind of number type it'll bump them up to the next kind of number type and then off the races you can store a lot more into that and it can do that for you but it doesn't have to do that for you and that's one of the great things about the language it gives you options in that way at least with numbers keywords so keywords are a thing enclosure keywords are these symbols that have their prefixed by a colon and then have some number of characters after them and there are all kinds of characters you can put into keywords they're call keywords because you're most likely to use them as keys inside some kind of a data structure probably an associative data structure like a map so the the common style in closure is what is called by a couple of different names kabab case is the K is the way that I like to call it because I love kebabs and food some call it - case but kebab case everyone here please call a kebab case I'm like an advocate for kebab case because kebabs are fantastic so let's all call them the phone call a kebab case so keywords keywords you're most likely to use them in maps and so this is an example of using a map and a function called get so closure the closure core comes with a function called get and which is a function that will operate on maps so you hand get the map that you want to pull something out of and you hand it the key that is the thing in the map that some kind of value is associated with so when you pass the map and the key it'll return back whatever the value that corresponds to that key inside of the map straightforward another thing that you can do with keywords and maps and closure is that you can just say well I'll take the map and almost treat it like a function and pass to that function this parameter of this some key keyword it doesn't matter what the key is but it's treating a data structure as a function remember I said before about code and data data and code it's like this whole big thing so that's really cool that you can say okay map I'm gonna mash a keyword at you and if you've got the keyword you give me the values kind of mash it in there I like mashing things you can also do this this is also a cool thing okay keyword I'm gonna throw a map at you just mash it together whatever comes out is gonna be the value the reason why these things work both for keywords and maps is that both of them behind the scenes they implement this interface called I FN and what I fen allows you to do is treat something as a function so code data pushing together all right that's keywords and maps symbols so symbols are anything that has anything any named thing that lives inside of the namespace that you happen to be in or any other namespace that exists in the universe so symbols are the things that are they they can either be data structures that have some kind of a name to them or a function symbols point to those things so that you can use them so values so symbols values here we have a value called Mario's Twitter and the value has a symbol name of Mario's Twitter and the value of that symbol is at Mario you know my at my Twitter account so that's values that's again more things that you can put into lists in closure you can also put functions so functions you can treat them as values you can pass them around let's talk about how to declare functions so this is one way to declare a function closure I want to talk about what exactly is going on here so you've got this function called mix that takes this parameter of things so the way to express the the parameter set that you can pass in to a function closure is with as a vector so this we're brackets in here I'm passing in something I'm calling foods and I've got this ampersand in front of it so the ampersand means I'm treating anything that gets passed into this function just under a single name and I will do something to that name in the code of the function but I don't want to like so any number of things so in Java this would be like a VAR args kind of a parameter declaration what this means is that you can pass any kind of thing into this function and I will just treat anything you pass in under just this one name so what happens inside of this function is that I'm creating this associative data structure where I've got this key of mixture and mixture is something that's outside of the scope of this slide but it's a symbol to something I've got contents of foods and that's whatever got passed in and I've got this tastes interesting and interesting is something that again lives outside of the scope of this slide but it's a thing the way that you would invoke this function is that you would say mix and then a list of things that are together a really great mixture and this is what I love that's how I love to eat popcorn just mix it all together to kind of mash it all these things they implement the i FN interface ok so here's another way to declare a function in closure so where the other function that I declared mix had a name this is an anonymous function it's an unnamed function and the way that it's declared is I say FN which is the function that takes a parameter of email and then does some stuff this function I'm actually passing into another function so this other function I'm passing this one email operating function into is a function called map enclosure and in all functional programming languages functions are these things that you can just pass around in the same way that you can pass around values you can pass functions around and have functions call other functions and do things to them so in this one I'm passing this function email I'm sorry I'm passing this function that accepts an email and then applies the lowercase function to whatever got passing is the parameter then outside of the scope of that function so after the the second closing paren I've got this vector this is Mario at the strangely and Mario Yukino at gmail those are the two parameters that are passed into map map gets this one email function in this list of two values and what comes out is the two values pass through the lowercase function is just lower cases the strings that's right ah thanks for pointing that out right so you've got two different kind of concepts the sort of curly brace associated data structure you've got a key value pair it can be called a map a hash map this other function map is called map for historical reasons just trust me it said that that's a name that's been used for this process of applying a function to a collection of values it's a name that's been around since the dinosaurs which because Lisp has been around since the dinosaurs and so that's probably where it originally came from but anyway the idea is that you're passing a function in plus values and this other function will apply that function to each of the values and then give you back whatever the return is this is something you would use in a different imperative language like Java you might use a for loop for doing this kind of a thing in functional languages you've got functions that you apply functions to collections of data - that might accomplish the same thing as a for loop but they do it without more elegantly in my opinion and without any side effects okay another way a sort of variation on what I showed a second ago so before I show in an unnamed function you can also have an anonymous function that while it's not really anonymous once you give it a name but you can give a name to these functions that aren't just sort of callable by anybody but they're their functions that you are passing in to other functions so here I've got a function called power that takes these two parameters a number and an exponent and this is a function for calculating something to the something power and the way this one works is that it tests if whatever the exponent is is zero then it'll return back one if it's not zero it'll call itself recursively so that's one of the great things a functional programming languages that you tend to do more things in recursive style than you would otherwise just by accumulating state in some other way so the way that that thing works is that it applies the multiplication function to the number that was passed in plus the return of calling itself by passing in the number that was originally passed in and decrementing the exponents that was passed in so that will loop back until it gets down to if it's zero then return back 1 and then return back the whole answer as 81 so this is the same as just calling three four times but it does it recursively here is the third way to declare functions so this is another anonymous and unnamed function I mean it's kind of a like a shorthand way to declare functions so and this is another one we're passing a function into this function called reduce and what this function does is that it invokes this function called STR which is going to construct strings and whatever the first parameter it was that was passed to it is going to get passed into STR and then an empty string just you know two quotes in a space and then the second parameter so the percent one and percent two are the first and second parameters that were passed into this function that starts with the pound sign in print so this is this third sort of anonymous shortcut style function and I'm passing this function in to reduce and then this other data structure that has three strings Mario and Rika Kino and so what reduce is going to do is it will take the first two values that are in the data structure pass them into here and then whatever this function call returns will be passed back in as the first parameter plus the next parameter in this sequence here as the second one and it'll do that until it gets to the very end and then return back what the product of all of those things are how reduce works or what it does is not so much is not as important as understanding that this is like another sort of cut shorthand way of declaring functions that's just convenient okay so that's functions so I mentioned before that there's not an assignment in closure that closure is a programming language that has that declares things so in the absence of being able to assign things there's a structure called a let in closure that is used very often and it's the way to construct algorithms basically where each step in some kind of a some kind of an analysis or some kind of a function operation is going to be a step in to a larger process so the way that let works is that you will do it typically inside of a function and you say inside of these square brackets so the left square bracket is on the left side of the min and the right one is down here at the end of the second line that the things that are being done here in the middle are going to be used outside of the parenthesis of the let but still inside of the scope of the lab so what you do inside elapses in these square brackets is you build up the basically the pieces that you're going to then put together assemble together by the end and the return of whatever you have done in the set up is going to be why you're using a let here so what's going on here is that I'm saying I'm gonna call min whatever is returned by applying multiplication function to threshold which as a parameter that's passed into this outside function and this other constant 0.75 that I'm gonna turn that into an integer and that'll be what I'll call min then the second one down works the same way except I'm going to call it range and then the point of the whole thing is so that I can add min to whatever Rand int passed the having passed range into it returns so I'll add those two things together and that's going to give me the whatever the value of get Rand threshold is led is something that is used very commonly in closure for doing the set of steps in doing your programming in a function and so it's important to when you see it to know exactly what's going on you don't have assignment but instead what you have is this scoped set of local variable names that are whose values are whatever it is that you put inside of the prints you know what okay macros all right so macros are this really powerful concept it's really powerful facility of the language that are these compile time tools that at compile time it replaces code that you have used in the macro with whatever the macro outputs given what you pass into it macros are often thought of as sort of Pandora's box kind of a thing because while they're very powerful they're also something that you can get lost in and can have strange consequences so macros are a thing that are useful in the language the language itself closure makes use of macros for a lot of the facilities that are just part of it and I want to go over just a couple of them so one of them is the reader macro so the reader macro we don't see this yet but let's just say you've got this function where you want to add some numbers together okay cool and you decide well what I'd like to do is actually I'd like to see what this function does when I actually replace either a place alright I don't want to have part of the calculation happening and so the reader macro the way that it works is that you Express I'm sorry not just the reader macro but one of the ways of the reader macro works is that you use a pound sign and then depending on what type of the pound sign the underscore here is going to be effectively like don't interpret this don't interpret this symbol inside of the operation so it's almost like commenting out some part of the calculation but it's not but it doesn't stop anything else that's after it it just happens to like a local why's commenting out of some part of it and so the effect of of that is that the rest of the form will evaluate just not that one thing you said don't evaluate that thing and it's a macro closure self does not have a lot of language key words it has functions and macros that together basically make up the whole part of they make up the whole language it's just a composition of functions and macros that can that evaluate out two functions that you can pass parameters into so here is an example of a different kind of a macro so this is more of the sort of nested inside out evaluation calls for a function so we've got a function here called Reed resource and what Reed resource does is it takes a path and then you got to sort of you know build up your eye muscle here you're going to start at the left and go all the way inside and like okay this is the first thing that's going to be evaluated because this the return value of this is going to be the parameter that's passed into that and the return of that is going to be what gets passed into that other things so you got to go a lot of back and forth to figure out what exactly is going on here so while you're trying to build up your eye muscles you can make use of the threading macro which lets you do things more in the order that they're actually being evaluated so the way the threading macro works is that it takes whatever the first parameter is that's passed into your series of functions and it passes that in like it passes that int as the first parameter of the innermost call that you're making and the return of that is passed as the parameter to the next function that is called in the sequence and the return of that is passed in to the next function and so on so basically what it does is it unwinds the set of nested function calls to make it more readable it's not something that helps necessarily the language do something better but what it does is what it tries to do is make the the language easier for you to read and maybe even to think about so there are lots of macros for doing this kind of things lots of the lots of parts of the language are implemented as macros and some of the consequences of that are that things may not work in the way that you would expect them to work if you didn't realize that they were macros as opposed to have function calls but but but there's still a very powerful construct of the language so I've gone over a lot of stuff closure is it's a lisp lisps I mentioned our this family languages that originated from the 50s at a time when there are sort of two camps of programming a declarative camp and an imperative camp the sort of Fortran and C camp were the imperatives and the functional lists were more the declarative and closure is a lisp it's a language as I mentioned also it lives on the JVM it can interoperate with Java or really any other language that lives on the JVM in one way or another and that means that the entire Java and JVM ecosystem is available to it and it's very different from oo imperative languages so why do you care about that the reason that I care about that is I feel like when I try to adopt a completely different way of thinking about functions about thinking about composing operations for solving problems that forces me to get out of my comfort zone and attack ideas in a different way and I keep the ways that those things influence my thinking and apply them to the next thing that I learned and in that way I feel like I get to be a better programmer closure is one of many languages that I have studied and that I really like and for anyone who would like to find out more you can read about it at closure org there's also a good book that is available online at brave closure comm there's a website called for closure which is a series of programming exercises yeah there's a series of programming exercises that will build up your exposure to the language in novel interesting ways there's also a really fantastic talk by rich Hickey called the value of values rich Hickey has done a lot of keynotes and other talks at conferences that are available online and he he generally has really really great insights into programming concepts that I think we don't often think about critically but he does so anyway that's closure my name is Mario keno you can find me on twitter at at mario keno calm i work for a start-up called out pace we're hiring we do closure and a lot of other really interesting things does anyone have any questions and you work from home thank you questions that closure is not a nightmare to debug so that's a good question there's so there's so much about the language that I did not show there's really a lot more to it and part of what I didn't show are sort of tools support this I wanted this to be more a talk of how to actually parse the syntax so one of the things that is important about closure is that everything has to be balanced all your opening parens need to have closing Prinze or opening bracket closing bracket etc so in terms of a nightmare to debug at one point it probably was a real nightmare to debug there are tools available to people writing closure that watch out for that kind of balanced closing and opening wrapping structures whether it's branding they're square brackets or curly or whatever that will make sure that you unless you're I mean so it's it's possible to have unbalanced prints but not accidentally you have to like be intentionally be trying to ah right so funny thing about breakpoints so closure doesn't really have great debugging tools so that was for me something that took a level of adjustment I remember when I first started doing programming my debugging was print lines and boy I've come a long way since that but now it's come full circle because that's now how I do it I would do my debugging as it is now anyway so in terms of like getting your I used two nested structures you get used to it the more you read it the more it makes sense to the AI plus your eye muscle gets stronger so that's a fantastic point that's something I did not mention at all in this talk so closure is a language that has a ripple and repple stands for read eval print and loop so it's just a command prompt basically where you can express commands to a working interpreter that will tell you the value of things you can declare functions you can investigate things so that is a really really common way at a write closure where you've got an editor open for writing your code and then you have a rebel session where you type commands how to just try stuff out in so I came to closure from Ruby Ruby also has a repple but I I didn't end up using it as much because my feedback mechanism in Ruby was generally through tests and in closure there are many options for writing automated tests but it's more like I think culturally it's more common for closure or any Lisp developers to have a repple open and to try things out in the repple and and when they figure out something that works then you put it into your source and then just sort of iterate your development in that way that's very very common so yeah and any other questions go ahead so closure is a dynamically typed programming language that operates on data structures period.the where languages that may be strongly and statically typed will use type declarations to make sure that you are passing something that that is intended to be the recipient of some set of operations inside of a method or a static function call closure doesn't have that and there are lots of languages that don't have that too and what they tend to do instead is think about things in terms of the shape of data not necessarily the type of data but the shape of it functions in closure will take data structures that they will do some kind of either investigation and manipulation of or compose other things that wrap whatever is passed into them the absence of strong static typing in closure means that you can write functions that can operate in a more general sense on data structures that may or may not always be the same kind of things but will likely have or have to have the same shape so yeah closure thinks more about shapes then types question yep yep hahaha good question so the question is closure is on top of the JVM and that's supposed to be a good thing right so I'd say that it can be a good thing is the interoperability with Java painful it can be painful what you what I have found and it's true with closure as with other languages that are built on top of larger ecosystems is that you tend to prefer to stay inside of your language for as much as you can and to the extent that you need to call out to something that is not implemented in your language you do that through a channel where you make you basically make accommodations for the ways that the world there is different outside of your world and try to localize those things in function calls where you treat the outside world as a thing that is a you pass something in and you get something back and you try not to do some sort of a conversational interaction so that's definitely true with a number of languages that have that are built on top of other things I think it's true for closure question ah dropping bombs in this room good anything good question so closure is it's a list and so it's great at lists of things so if you've got like a to-do list or a shopping list closure definitely good a closure and if you've got lists of gigantic amounts of data that you want to operate on that you want to do interesting analysis on so that's actually what we do at the company where I work we use closure to be able to deal with large amounts of data and not have to worry about mutability in what we're doing in interacting with it so you can definitely do this with Java it's just there are things that you have to do there's more work that you have to do in Java to accomplish the same things that you do that you get just out of the box by default with closure and immutable percentage structures yes absolutely so as we are approaching a world where the speed of processors isn't growing as fast as the number of processors number of cores that are being put into a into a chip being able to parallel eyes processing and think about computing in parallel and languages that make that thing easier make the process of fertilization easier it is definitely to our advantage to start looking at languages like that closure is a language that does parallel processing very well and there are others too I think functional programming languages that deal with pure functions that don't allow for a mutable state inside of across interactions they eliminate a thing that you otherwise have to guard against that makes it harder to operate in parallel environments so I think closure and we're using that where I work now we're using closure specifically for that reason and though that there are trade-offs so there are some things I mean so closure is not the whole Silver Bullet thing that whole analogy is just so used right but closure is not a magical language it's a language that has trade-offs and you can use this trade-offs to your benefit depending on what your use cases are in parallel secretion is something that closures as well and there are other languages functional otherwise that do a lot of parallel processing well hmm well so if I guess there are environments where you can't use closure like for mobile applications for example where the language is just not available for that for doing like system operations where things like a you know a shell language makes more sense there's like easily there that doesn't require you to like an install the JDK or whatever you have or maybe if you're in an environment where you don't have other people who are experienced in a functional paradigm who are just using an imperative programming model and that's just what you know there are I guess lots of reasons why you might use something other than closure but again it's just a question of trade-offs I wouldn't say necessarily that there are problems that closure cannot do I can't think of them there may be some but I mean like in terms of why you would choose not to try to introduce closure I guess it depends on what your needs are yeah I wouldn't say it's because any kind of limitation in the language for practical reasons question well so as in Java you've got garbage collection that happens behind the scenes so in closure you don't do any kind of allocation or releasing of memory and it all just sort of takes get Satan 10 karat some right I hear you so the question is how does memory management really work in closure so culture has a compiler that emits Java byte code so though for the same way that the Java programming language in the the the garbage collector in Java looks for references to things the closure compiler it emits Java bytecode instruction that will operate in the same way that compiled Java works inside the JVM and it manages like so where there may not be assignment to variables in closure explicitly behind the scenes how it all works is something that's compatible with the garbage collector and the JVM so it's utterly possible to experience out of memory exceptions in any language that runs on the JVM so yeah but the running out of memory is something that may happen to just depending on what it is that you're operating on you may be operating on some amount of data that's beyond the heap space of the JVM and it's to you to figure out how to manage that better in a good way question so I don't have a lot of experience with the closure script so I may not give you the best answer to this question but what I do know is that closure script is so for anyone in the room who hasn't heard of it closure script is a it is writing closure that a compiler will take and turn into Java scripts that can run in the browser and what you have access to in closure script is basically all of the closure language that will get compiled down to something that can run in the browser and there are lots of really novel and innovative ways that that's being used for doing either asynchronous processing in the browser or other ways of doing data manipulation in a functional style which is also possible in JavaScript because javascript is a language that you can write in a functional paradigm but it's arguably easier to do in closure so your question is are there ways to have closure used like have common functions used both in the server-side in on the client side via closure script and definitely you met that's because you've got access to closure functional code that you write or libraries that you make available those can be turned into JavaScript by the compiler and effectively reuse the same stuff in the client that you might be using in the server any other questions all right thanks very much [Applause]
Video description
from infoq