- Podcasts
- Programming Throwdown
- Clojure with Eric Normand
About this episodeOn this show we discuss Clojure and ClojureScript, and all the amazing things you can build with them. Show notes…
On this show we discuss Clojure and ClojureScript, and all the amazing things you can build with them. Show notes: https://www.programmingthrowdown.com/episodes/61-clojure-with-eric-normand
★ Support this podcast on Patreon ★Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Clojure with Eric Normand
Programming Throwdown Episode 61: Closure with Special Guest Eric Norman. Take it away, Jason. Hey everyone. If you're a long-time listener, you may remember we did an episode on Lisp almost three years ago, and we're coming back and we're covering in a lot of detail one of the things—one of the comments that we got when we did the Lisp episode from a lot of people was, 'You know, hey, we want to learn more about Lisp,' and here are some more details about Lisp and things like that. This is before we really had a strong social network presence where the only way you could really communicate was by emailing us. And so we got a lot of email about Lisp, and so I'm really happy. Oh, go ahead, Patrick. Yeah, we also briefly did mention Closure on—we did like a collective episode of a bunch of JVM languages. That's right. And so we mentioned Closure by name there, and so we have Eric Norman to talk in much more detail about Closure and kind of really teach all of us a lot of really cool things about Closure. So, Eric, kind of tell us about yourself and what?
teacher uh in the peace corps and i was teaching math and when i got back i i kind of started missing it i started programming again and uh i started making uh videos and off and on and then at some point i did a kickstarter to get some closure videos made and that was a success and just ever since then i've been adding more and more videos
friend who has funded a lot and like kind of saw what worked and what didn't i i hadn't been active on kickstarter at all and so it was like just a lot of discussions with him about like how what should i set my goal at uh what should my rewards be uh you know that kind of thing and he helped me come up with the uh the structure there um yeah i i would say that my biggest advice for someone who's going to do a kickstarter is take into account the marketing that you're going to do during the campaign so i did mine for 30 days which at that time was the default i don't know what the default is now but at that time it was default to 30 days and so that's 30 days of you like tweeting and promoting and like just being generally like on edge about whether you're going to make it and stuff and if i were to do it again i would probably cut it down to like 10 days or 15 days um because most of the the backers came in at either the beginning or the end and so if you just cut out the middle then i would have had about the same amount so
that makes sense and one thing that i noticed is it's really you know you have to the audience wants to have faith in in you like in you delivering on the kickstarter and so if you're if you're messaging every single day like you know here's what i ate for breakfast today i ate closure flavored cheerios you know then then like people know okay this person needs business and and if i if i donate that it's one it's going to work out and two like i'm donating to more than just a set of videos it's like a cause yeah
The void? Yeah, that makes sense. Um, so you know kind of explain, you know, if you had to sort of explain functional programming to someone who's never heard it before, how do you, you know, how do you sort of describe that? Let's say there's someone who, you know, has taken some courses—they get C, um, on C++, really well. Um, and but they've never seen Lisp or Haskell or closure or any of these, how would you sort of explain that?
from lambda calculus. And lambda calculus is a mathematics that uses nothing but functions, and so there's definitely the notion of using functions as your main form of abstraction. And functions are higher-order. That means that they can be passed to other functions as arguments, and you can return functions from arguments. So functions are values that you can pass around. And languages like C, C++, you can kind of—like let's take C because I know that a bit better, you know, you can pass function pointers around and stuff, and people do interesting stuff with that, but they don't have what's called lexical closures. It's a technical term. It just means a function that can refer to variables that are defined where the function is defined. So like in JavaScript, if I have a variable defined—let's say variable A equals one—and then I have a function defined right after that, then I can refer to A in the body of the function. You can't do that in C. So it becomes like you can't so you can't like capture the environment that it was in. So you can't really do the functional stuff.
Yep, that makes sense. So I mean, I think one analogy is if you've ever played World of Warcraft or any of these, you know, MMOs or many games kind of like it. You know some of the weapons, you know, in the beginning you get the wooden sword and like you just hit the rat over and over again, but then as you get better and better, you get one of these swords that has what's called a proc, which is short for a procedure. So it might be, you know, when you hit somebody there's a 10% chance of them turning into a chicken or something, right? And so you know that process—like that event—is sort of tied to that sword. Like you kind of want to assign the turning into a chicken to that weapon and be able to if you give the weapon to someone else, you want to sort of give that logic to them too, right? And so I think yeah, part of functional programming is this idea that like you can pass these functions around as a sort of first-class citizens. Yeah.
Is so you have if you're familiar with object-oriented programming, you've got objects that have methods. So that's data with functions attached. Well, in a closure? In a lexical closure, like? In a functional language, you have functions with data attached. So those that the variables that are defined in the scope are the data that you can access from that function.
Yeah, that makes sense. So that's functional programming, and we covered Lisp in the episode, but basically, you know what is closure? I mean, when we covered closure, we just very superficially said closure is Lisp on the JVM, but you know, I'm sure it's much more than just that. You know, kind of how does closure fit into this whole landscape?
So there's a lot of stuff that comes with Common Lisp that is built into the language whereas Closure because it's designed to be hosted, it just relies on what the host can do. So I'll give an example. Common Lisp has this very sophisticated and like just a lot of features in the exception mechanism. So when you throw an exception, you can actually do what's called a restart. So you catch this exception, and you can like fix the problem and then recall it and go right back to where the exception was thrown. So if like the file is not found, you can be like, oh, not found? Well, let me make it, and then you go right back into where it was. Right. Oh, cool. Whereas in Java, and it's just built into the JVM, it's not part of the Java language; it's it's part of the virtual machine. The exception gets thrown, and like the call stack gets unwound, and it's lost. Like you can't go back to where you were. It's just... And so Closure just kind of borrows all of that stuff from the host that it's on. So that includes like Closure's numbers are just Java numbers. Closure strings are just Java strings. Functions in Closure get compiled into a Java class. Um so you know all this stuff just becomes some concept on the JVM.
Gotcha. That makes sense. Um so I mean how are some of these things like possible? Like in Java you can't have closures, right? So so um I mean I'm assuming Closure can't be built in Java; it has to um like in other words, like the concept of closures have to be added in machine code, I guess, to the JVM or something.
Java. Um, the way closures are implemented is like I said, it's a there's a class and when you have a new function that you're compiling, it extends that class. That function class, oh, I see, and the function class has a bunch of methods on it, and each method is a different signature, so it'll have the zero-argument method, it'll have the one-argument method, the two-argument method, etc. And the your class that it compiles to will extend those, gotcha? And then all of the data in the closure—meaning the variables in scope that it needs to access—get put into the class, class as member variables, okay?
It makes sense. So um, so sort of you know for somebody who's maybe you know really into web development or you've done a lot of maybe C++ kind of back-end work—C++, Java—like why should they learn closure? You know, for somebody who's already mastered you know one or two or several languages, like what, you know, we always talk about this metaphor of the toolbox and how there's not one sort of magic language. It's just the same as there's not one magic wrench that just does everything, or not one magic tool that just does everything—that's a wrench and a hammer, and whatever. And so you know if someone wants to assemble this sort of toolbox of languages that's sort of comprehensive, you know what sort of closure add to that toolbox that?
I don't think is is really fully answered. I can tell you like there's no general like one answer to satisfy that question. I'll tell you why I like it and some also why people I know like it too. Um, so when when it first came out, the big story behind closure was that it handled concurrency really well. So the JVM has a lot of Java, the language has a lot of libraries and stuff for handling concurrency, and there's books written about how to do concurrency right on the JVM. Yeah, it's very problem is yeah, it's hard like you have to read this book and then do everything right or you're going to get bugs. Yeah. What Rich Hickey, the creator of Clojure, did is He took that book and basically built the language around that so it works that way. Like it's very hard to not do it that way. So a lot of the primitives in the language, like you know there's all sorts of stuff in Java, like you use the volatile keyword and you have to make stuff immutable and things like that. All of that is just taken care of for you so it has this really nice story of like concurrency is the default and it works really easily right out of the box. And that is true, and it's really nice. And it's weird when I go to another language and I'm like, well how do I do this at the same time? And like, oh well you can't or you have to do this other completely boilerplate system to get something else to run at the same time. Yeah.
Yeah, that's a huge problem. I mean, you know what typically happens? You're building, especially if you're building an app for the desktop, you have some kind of UI and use the person specify some files, and then you want to go off and do a bunch of work on those files, and it's almost always embarrassingly parallel. Like very rarely do you need to do just one very sequential thing at a time. Usually someone gives you a batch of things to do, and in most languages like C++ and Java, this can get kind of quite painful.
you just do new Thread and you have a thread. And like what's the problem? Well, that's only half the answer. The other half is now that you've got this thread, how do you get information that it's calculating out back into the thread where you're going to display it on the UI? Right? Yeah, and it's all these like ancillary problems. Like, oh, I maybe need a queue. Okay. Well, you know you're going to construct a Thread and a Queue and a thing, and like you just it just never ends. Right? Yeah, whereas in Clojure, it's as simple as well. I'll just have there's a bunch of different primitives. One of them is called an Atom, and an Atom is like the simplest kind of shared state. It's just one pointer that that you can change. And you you can have multiple threads accessing this pointer. You can read from it or you can write to it, and it's thread-safe. And I mean, this goes into like why one of the reasons I really like it is the focus of Clojure is on the simplicity of separating out all the different problems and solving them independently so that you can compose them back together. So you have the Atom, and all it does is keep one pointer and make sure that whenever you transition from one state to the next, you're transitioning from a consistent state to another consistent state, like in a transaction. Gotcha? You can't see it halfway done. And that is what allows multiple threads to read and write to it. I mean, really with very little code. You don't have to deal with locks and stuff like that; it's all handled by the Atom. And this simplicity of sort of here's the right tool for the job and like the language just kind of gets out of your way. I really appreciate that. Yeah.
It makes sense. I mean, most of the time you don't need to do these like hog-wild things where you have three different threads all updating the UI at the same time. I mean, these things were important, you know, in the '90s, but now it's like if you have three threads and each one locks the UI updates it and unlocks it, computers are fast enough where we don't need that level of control, and if you are willing to sacrifice the level of control, you could have a much
For sure. So most people want to build—I mean, there's people like Patrick who do crazy robotic stuff, homebrew stuff. He's got, you know, a drone firing lasers at people who come to his house, but for the rest of us, like the other 99 of us, we're either building, you know, a website, a desktop app which could include like a server that's serving web pages, or a mobile app like an iPhone app or an Android app. So can you do, you know, these three things, like any or all of these things in Closure? How does that—how does that?
Kind of work? Yes. Yes, for sure. The easiest one is the web app. Web apps have been done in Java for a long time. There's a thing in Java called Servlets, Servlet Interface, and most of the Closure web systems are some wrapper that uses that uses the Servlet API. There's the actually the Closure ecosystem web ecosystem is evolving right now, but for a long time the main system was called Ring, and it was kind of like Rack in Ruby, and all it would do is it would take the request and turn it into a map, and it had a standard format. You know, the request method was under a certain key, and it was a string, and then the like the port was a different string, was a different key, and it was a number, and the body was, you know, so you could get this map, and then you did whatever you want with it. And then you would return a in a—you would return a response. There's another map in a similar format, and then there was a—there's three concepts: there's the adapter, which is the thing that connects to the Servlet API or whatever API you're using to do the web stuff, so it—that adapter connects to the API and converts requests into the Ring request, and then converts the Ring response back into an HTTP response. And then you have your handlers, which are functions from request to response. And then what's called middleware which transform the request or the response as it passes through, so it actually transforms the handler into a new handler. Yep, so that's So you would basically construct your web app out of these pieces. Um and like I said, it's evolving. Like people are learning stuff they want to do asynchronous stuff. Functions aren't great for doing like async calls. But that's—that's still the main idea is that you got this request map and a response map. Yeah.
That makes sense. So basically all of the ideas if you're used to doing Java, you know, server-side web development, all of those ideas kind of translate almost one-to-one to Closure, and someone has written adapters so you can kind of work in a completely Closure environment and not have to worry about all of those bridges.
It's much more direct. So in like the Servlet API, you get this request object that you like query, like well what you know, you call the method like get—get method, right? Which gives you the HTTP method and stuff like that. And um so you really have to understand this API really well and like look up the docs. And then when you do the response, you have to like do set header, and and you're not supposed to call set header after you've like piped in the body, you know? And like there's all sorts of rules for how to use these things. It's—to me that's like really hard to keep track of. Yeah. Um the and so in Ring, the adapter is supposed to handle that. So you handle that one time, right? Like the adapter once it's well written and and conforms to the API and to the Ring spec, it's done. You know, you know it's—it's like you can just close that book and say, 'Well, version whatever, it's done.' And um that's the kind of thing I really appreciate with the Closure community. There's actually libraries that they're like, 'It's done, we finished.' Um it's not like this continuing thing like, oh well, we're trying to adapt it to this other situations so you don't.
In Closure, so there's a couple of options. Um I don't think that this is being done so much anymore, but because the Closure runs on the JVM, it can run on the Android JVM, the Dalvik JVM. Okay? Um but I think the most of the work now is in React Native. Um there was some stuff with PhoneGap, so we didn't Talk about this, but Closure also compiles to JavaScript, and I talked about it being hosted.
That is quite remarkable. So if you—if you know, I mean JavaScript is very universal, but if you just let's say you just hate JavaScript or you're programming something in a certain paradigm where a functional language would be much better, or at least you know Closure would be much better, then you can actually write Closure and it will compile or transpile down to JavaScript. That's pretty cool. That's.
Right, that's right. And you know, you said—you said the word 'transpile,' and that's what it's doing. But a lot of times when people think transpile, they think CoffeeScript, and. i have nothing against coffee script but one of coffee scripts like goals was to be just javascript but with better syntax right it's like right you could you kind of guess what what javascript would be generated yeah i think
They even have a—it's two-way. You can actually—you can convert it back. Oh, I didn't know that. Or maybe it's—oh no, sorry, sorry, it's not two-way, but there's a—there's a what's the word? Like there's a JavaScript compiler for CoffeeScript, and so there's actually on the CoffeeScript website you can paste CoffeeScript, and it will turn it into JavaScript. You just write down on the website, and that's what I use CoffeeScript for—for taking other people's CoffeeScript and converting it.
Hairy is that it does a lot. The compiler does some optimizations. So, you know what looks like a regular function call is actually going to turn into in JavaScript a dot call. You know functions in JavaScript actually have methods, and one of them is dot call. And so when you're looking at the compiled code, it's like a little crazy because it doesn't look like you would write JavaScript at.
Yeah. So source mapping and maybe actually be amazing if you could explain it because I have no idea how it works, but basically I've used it for TypeScript, and what it does under, you know, under the hood? I don't know. Hopefully maybe Eric can educate all of us, but on the surface, you know, you've written in TypeScript, but the person in the browser is still executing JavaScript. The person could be you, and when you get an error, you don't want it to just show you this completely unintelligible JavaScript. You want the error to actually redirect back to your code that you can actually modify, and the source map helps make that happen.
Yeah, for sure. That's a great explanation. It's like if you're gonna—if you're gonna serve up some JavaScript, usually you're gonna minify it and like maybe uglify it, and so it's gonna be like one long line of JavaScript, and that's... Gonna be impossible to debug. It's gonna say line one, like bugs on line one. Exactly. So they came up with this system, the browser makers came up with this system where...
Yeah, and that's actually largely thanks to one system that the Closure Script Compiler uses. It's called the Google Closure Compiler, and that's Closure with an S, Google Closure. Um, so the Closure Script Compiler is a very simple kind of naive compiler, but it outputs code that the Google Closure Compiler can read. The Google Closure Compiler is what Gmail is built in, and um it does some
Just to sort of explain because it's super confusing. Um, so there's a Google Closure Compiler, I think the naming is really terrible. Yeah, it's spelled with an S, and it has nothing to do with closure, you know, at least directly. All it does is it takes JavaScript code and it makes it, you know, faster and more efficient. Um just like you could have a think of it as like an optimizer, right? You could have, you know, you could compile your code with dash O dash O zero, which no optimizations, or you can compile your code with dash O three, and it produces even though it's the same code, same logic, it produces a totally different binary. And that binary has all sorts of crazy, you know, GCC optimizations, you know, baked into it. And so Closure is kind of like compiling with dash O three, but it's in JavaScript, and so it JavaScript goes in, JavaScript goes out, but the JavaScript that comes out is a much more efficient representation of what you originally intended. Um, and that's different than Closure with a J, which is what we're talking about, but but you can actually use Closure Script with Closure to produce, you know, to write in Closure and produce really fast JavaScript that's
Right. That's right. And I mean it is. It is some really cool technology. It's from Google. That's what they use to produce Gmail. And I mean there's stuff like What's called splitting module splitting, which means like okay, so imagine you've got you're developing this web app and like your front page it's going to have some JavaScript on it, but you don't have to be logged in to do it, and most people who go to that front page aren't going to
code and figure out—well, the front page uses, you know, this bit of code, the back end uses this bit of code, and then this bit of code is shared between the two. So you can cache that one that's shared between the two and only serve the—the, you know, the home page code and that shared code to the people who are visiting the front of your site, and then after they log in, they can get the rest of the code. So it's a way to like optimize the experience for, you know, people who don't need that part of the code.
Cool. Yeah, that makes sense. I mean, one thing—one thing that people might not realize is there's an incredible amount of energy spent on making, especially the front page of any site load very quickly. Um, there are statistics that show for every, you know, maybe 10 milliseconds, and of course it depends on different products and different sites, but, you know, for every 10 milliseconds that the front page takes to load, you lose, you know, X percent of your customers, and it's like pretty significant. So, so yeah. So if Closure can kind of do separate that and speed that up, it's awesome.
is the development experience in my opinion is better than the JavaScript development experience. So it's not like it's, you know, oh, you get this great language, but then you've lost something because you have to have all this tooling and stuff. I recently—so okay, let me give a little history about four years ago. I was doing a lot of front-end development, back-end and front-end, but
Times, and it worked. You know, it worked. And then I went into Closure Script, and I was doing the way you do it in Closure Script, and Closure Script was really new, so a lot of it was like raw and but it was evolving very quickly. And then I had to go back to JavaScript for another job, and I was just shocked. I mean, the number of tools you need and libraries, and like, oh, you're still using Grunt? You should be using YARN or whatever it's called, Yarn, NPM. Like NPM didn't exist when I left JavaScript before, and it's like, I just. It is. It is just so crazy how many libraries and.
If you play like Zynga Poker on your phone, that's—that's almost all C++ code. Um there's just a little bit of, you know, iOS or or Android code to handle the drawing and things like that. Um if you play Zynga Poker on say like facebook.com or or I don't know if it's even zynga.com, like but on on the web version, that's also C++ code—the same code, but it's been it's been um, you know, translated to JavaScript with MScripten. And talking to people who who've worked at Zynga, it's just a total nightmare. I mean, if you have a bug in the C++ part, you just have to catch it on mobile. Like if there's some bug where if someone gets all four aces, it crashes or something, you just won't catch it on the web. Like it's—it's lost. You just have to hope you have that same bug on mobile.
Well, I mean, I'll tell you like I don't—I don't mean to bash on all these languages. They're great, but I recently had to work in C++. Um and I don't know C++, so it's totally new to me. So I was already dealing with all of the like the novelty of everything, but the build system. I mean, we were just taking like it took me over a week to get it to build on my machine, and I could imagine if then okay, you finally got it to build, and now it's running in the browser, and you don't have any way of no like you know source maps or you know something like that to debug it. Oh man, yeah.
I mean it's a total nightmare. Yeah, but you're totally right. Like I mean now things are a little bit better. There's Basil and there's Buck. Basil's from Google, Buck is from Facebook. They're basically the same thing, but even then it's they're not great. I mean, it's well, even dependency management in C++ is still really bad. Oh yeah, it's a total nightmare if you want to pull like there's really no repository—not that I know of. There's not really a central repository of C++. You know, I don't even know how that would work because you'd have to you wouldn't be able to keep the binary because it's machine specific, you know.
That. Oh yeah, and I mean the thing about JavaScript is it's a huge ecosystem. There's so many people in it. People are dissatisfied with their tools and they write new tools, but there's so much to keep up with. Every six months you have to like rewrite your build system because you know it's not using the newest thing and you need a feature from the newest one, or. I mean that's why like what in my personal—my personal website I use Cat. I have a Makefile and I cat JavaScript together, and JavaScript is. Kind of like that. You can do that, right? You can just take two bits of JavaScript and smoosh them together and you have a bigger bit of JavaScript. Yeah, and that's—I just don't I guess I'm getting older. I just don't want to deal with these like cycles of learning a tool and figuring out its JSON config format, and I don't know.
Absolutely. I mean, when I was in high school or I guess maybe college? Yeah, yeah, when I was in college I got Ubuntu—not Ubuntu, I got a Gentoo, and for people who don't know, it takes about 18 hours to install, or at least at that time it took about 18 hours to install Gentoo. Now you don't have to be there for 18 hours, but it's kind of like you get in, you install the bootloader, you know, you spend about an hour entering all these different commands to install the bootloader, and at the time that was super cool because you feel like this like Neo from The Matrix, like some crazy hacker. Yeah, and.
Yeah, yeah, but in terms of like effort—I mean, like yeah, I mean like Windows definitely took a while to you know write to disk and all of that. But this was like you know you have your bootloader, you'd reboot to the command line, like to just a root prompt, and sometimes you know you do it wrong and you'd reboot, nothing would happen. And that was super super fun at the time, but as soon as you become a professional and someone says when is this going to be done, and you say a week, and then instead of taking 18 hours it takes 30 hours to install your OS, you're kind of in big trouble. Like yeah, it is not fun anymore, you know. And so yeah, you immediately switch to okay, I need something reliable, you know that's quick that I could depend on.
Yeah, sure. I mean, I remember—I used to be like. In the '90s I used to run Linux, and it was kind of the same as you were saying, like it would take this huge amount of time to like select your video card and make sure that X Windows would work with it and get all the settings right. There was no auto-detect at that time, and. Then at some point I would just be like, okay enough, I need to check my email. Like I just—I would so I would just like use the barest X there was. Yeah, barest X Windows, the one where you like you.
Old days. So, let's say someone, you know, has a website already in JavaScript, and it's using, you know, a bunch of different libraries. It's using, you know, Random, and using all sorts of different libraries. They're rewriting it is totally off the books, but now they need to do something which Closure is really good at. How does that work? Like, is there some type of interoperability layer? Yeah?
So, um because Closure and Closure Scripts were designed to be hosted, the interop is just really seamless. You can call first of all—first of all any function, you can just call it like a JavaScript function. You get a JavaScript function from something, you just call it. If you get an object, like let's say you get a Promise, you can just call methods on it just like normal JavaScript, and you can access the properties too. So, uh, the hardest part with the interop is that you're not dealing with JavaScript arrays anymore; you're going to be dealing with Closure immutable data structures. Um, so you're gonna if you are doing a lot of interop where you're like building up a Closure Vector of data and then you need to pass it to something that needs—that's expecting an array, you're gonna have to convert it. And so there's gonna be a little performance penalty there every time you convert it. That makes
That makes sense. Cool. Um so what about I mean, you know we have sort of a faction of the audience—a faction is is faction? Like, I feel like 'faction' is a connotatively positive word, but now I'm starting to doubt myself. We have a portion. Yeah, we have we have a portion, we have a section of the audience that's just really into the career side, you know? It's it's people who want to get into the industry. Um and and so they're, you know, right now they're, you know, really wondering, you know, what's the job market? Um, you know or even, you know if they're doing freelance, they want to do freelance work. They're wondering, you know can how would this sort of affect my freelance work? Like does this give me some, uh, you know if I'm given the freedom use any language, you know, does this, you know boost my productivity? Um and so what is sort of the, you know on the business end of it? Um how rich is sort of Closure right now?
But the average is higher because Closure and Closure Script are probably not their first language, whereas in JavaScript it's—it's more much more likely that JavaScript is their first language. So even if you just think someone with two languages is better than one, you know, you've got that going for the Closure and Closure Script side.
That makes sense. So oh, I think there's a lot to be said for joining a smaller community, especially when you're just learning. I mean, there's a lot of resources, there's people who are very passionate about it, and you're not just completely swamped. I mean, if you were to learn JavaScript as your first language and learn it in sort of a professional sense, you're just completely swamped with, as Eric mentioned, just all the different tools, all the different libraries, and it sounds like Closure Script, you know, with a smaller community, you can really kind of dive deep and get a good
understanding. Yeah, for sure. Um, and it's—it is a I mean everyone or not everyone, I don't know. Many of us have heard this story that JavaScript was actually designed in 10 days, which is kind of an exaggeration, but it's not far from the truth. Um, whereas Closure and Closure Script have a much richer history and a lot of design
Yeah, and I think you know things are starting to trend in the direction of more fully featured languages. I mean, if you look at Haskell and Scala, for example, they have type inferencing, and the browsers now are more sophisticated, so you can—you can see the inferred type, and so you know combination of the browser and the tooling getting more sophisticated, and also the projects just becoming more complex. It sort of dictates, you know, languages that that are more principled, and so that's one of the reasons why there's just so many alternatives to JavaScript, like so many different ways you can write JavaScript because people just can't get by with native JavaScript when the project gets very large and complicated. And so yeah, I think Closure Script would be a great first thing for people to.
Learn. Yeah, I mean, I just did a workshop and we did Closure Script. Um, it's, and a lot of them were first-time programmers, and it went well. Um the number of things we had to install, I think we had to install two programs on their computer. Uh, we had to get the JVM on there because the Closure Script
But there's an editor called Nightlight that is just a plug-in for Lining. So it runs like you just type Line Nightlight, and you get an editor that you know, you open your browser to a certain URL, and you've got an editor editing the code in that project. Oh, nice. And you got live reloading with another plug-in, so you're typing and like you can see the change in your browser, like you can see the effect of that. And so it's just like it's just an amazing experience that someone can type a couple commands at the terminal and get this development experience going. Um.
see the most bang for your buck, like if you really can choose whatever language you want, um which I think is the case in a lot of freelance situations. Yeah, I mean it is such a—it's so much better than JavaScript in my experience. Like if I was going to do freelance, I would do Closure and Closure Script. No.
matter of time. Yeah, yeah. Maybe maybe because like the ClojureScript, so I don't think I've done it enough justice. So not only is the development experience great where you have like live reloading, and when I say live reloading, it doesn't mean like it just refreshes the browser automatically. What it means is your state, your app state is still there, but The UI, like you've changed. Your UI code and so you could be like a few clicks in, you know, like you're testing out your. Yeah, you have.
Yeah, when we explained functional languages three years ago, now, you know, we told people a lot of people say, 'Oh, I've never done functional programming.' And what we've told people is actually yes, you have. And probably your parents have too. It's called Excel, right? And you know when you're using Excel and you type a formula and then you paste some data and just kind of magically, you know, and as you're changing the formula, the spreadsheet is just changing. It feels so kind of alive and magical. I mean, it sounds like with, you know, a closure script, you get that same feeling but with web development.
Oh, good question. There's a lot of books, but I'm actually going to take this as a as a cue to plug. My stuff. Um, so I've got PurelyFunctional.tv. There's um oh wow, 150 something videos on there. Oh wow, of varying length, and most of them are like behind a paywall, but there are some things that are um that are available for free if you want to just test them out and see if you like it? Um, there's one called Intro to Closure. And that's not Closure Script; it's regular Closure, but it's the same syntax, same data structures, same core library. So you're—it'll help you on your way. Um, and also I've got a page set up at PurelyFunctional.tv/throwdown, and I'll give you a nice coupon code for a discount on a subscription. Oh, very cool.
be great too cool awesome. Um yeah, I mean, I'm definitely gonna check this out. This is super cool. Um I uh yeah, I had no idea actually that Closure could be used with React and React Native. Um I've struggled trying to learn React, React Native. I mean, I did learn them eventually, but it was not intuitive. And so I'm gonna give this a shot and see if it feels more natural. It's weird. I feel as if there are some things like uh trying to give a good example. Um I think actually JavaScript is one of them. Like JavaScript felt natural to me insofar as when I was doing it, I was just inspired to keep doing it. There are other things, um like Scala, is a good example where I write some Scala and I just want to write less Scala, you know? I I had to do it for a job, so I you know kind of powered through it, but uh um and and I feel React Native is one of these things where the more I did it, the less I wanted to do it. And and I'm gonna I'm gonna try with uh with Closure, uh I guess with Closure Script, and and see if it if it feels more
natural? Um well, I actually um I had the same experience. I was using JavaScript in React Native for a client, and uh it was—I mean, there was just so much to learn that was the real thing. It's like I want to get something done, but you know there's all this life cycle things and um a lot of the the tooling was was kind of weird. And then there was uh all the styling and the the new components that you had to learn. Yeah. Um and then the the biggest thing of all which I don't think we ever solved—I think no one has solved this yet—the routing, which I don't like. I don't do much mobile development. Apparently, routing is like really important, and I just don't get it. Um yeah, same, but but uh you know, it has to do with like keeping track of the back button and stuff can slide in from the right and slide in from the bottom, and like you want it when you hit the back button, like you want it to remember the right thing to go to. Um anyway, apparently that's a hard problem. And um I then was like, well I got my I got my bearings in React Native and that, and that was cool. And so then I tried it with Closure Script, and it was just—it was just so fun. Now I didn't make like a complicated app with a lot of screens and stuff, but it actually felt like wow, I can now make all those little apps that I thought should be easy to do, you know? Like I wanted to make a like a tip
Yeah, exactly. Like I don't want to track my—I run, so I want to track my runs, and I use RunKeeper, but it's like overly complicated for what I need. I just want something like I click a button and I start running, you know? Um, and you know that I did it, and it's so nice. Um, so I'm actually making a course about that app that I made. Um, I've given a talk about it, and
Very cool. So yeah, I think that kind of wraps it up. Um, so Merry Christmas, Happy Kwanzaa, Happy Hanukkah, other things I might have missed, you know, because this episode will probably go out, you know, around that time. Have happy holidays and all that. Um, thank you everyone out there for supporting the show. Thank you Eric for coming on the show and explaining Closure to us. And we really appreciate your time. There's a shout-out to LinkOverTime so people can
There it is. And yeah, and have fun happy hacking. Hopefully you have a cool Christmas project. Like Patrick's probably going to build, you know, like, you know, as I said, some robot that will terrorize his neighborhood. I feel like you're just going to make the Feds show up at my door. Yeah, um, I don't really have anything in mind, but oh, actually, I do plan on doing a lot of drawing. I wrote a script for a game, but this is like a role-playing, like one of these RPG games where it's you know a lot about kind of dialogue and characters, and so now I want to actually go and draw those characters. I think I'll probably make that my Christmas project, but whatever. That sounds really cool. Yeah, have fun and have a happy Christmas. And we'll see all you listeners next year. The intro music is Axo by Binar Pilot. Programming Throwdown is distributed under a Creative Commons Attribution-ShareAlike 2.0 license. You're free to share, copy, distribute, transmit the work, to remix, adapt the work, but you must provide an attribution to Patrick and I ShareAlike.
