ClojureScript for Skeptics
Derek Slager's talk for Clojure Conj 2015 where he is Discussing the many reasons why ClojureScript is in fact a very pragmatic language to consider for web development.
transcript
welcome Skeptics I assume everyone in the room is very skeptical indeed uh you've self- selected you see uh so what what do we mean Skeptics right I I think you know it's a it's it's kind of a a heavy word but the definition is rather simple right not easily convinced having doubts or reservations I think that described like all programmers about all technology and I think this is actually a very healthy thing to be um I'm a skeptic about just about anything I hear we deal with a lot of marketing and so I would encourage you all to be very skeptical and so welcome fellow Skeptics now you might be thinking why is there a talk called closure script for Skeptics at a closure conference that sort of doesn't make sense uh and yet they accepted the talk and you guys are all here so maybe it kind of makes sense after all um but uh but but actually I think they're actually are some Skeptics in the room and yes this is the closure community and and maybe it's a little bit easier sell because you guys have sort of embraced some of the aspects of the ecosystem but I'm guessing that there's a decent percentage of Skeptics in the room and in fact I'm going to pull you uh if you're pretty much skeptical if you meet this definition about closer script specifically you could just raise your hand so I can kind of get get a sense okay I would say that's about 30% of the room nailed it so so and so yes we're at closure con not closure script con right so this is this is not not terribly surprising right so so yeah there's some people in the room who are not skeptical about closure script and and that's that's great um and I'm guessing there's probably even fewer people here who are are skeptical about closure itself or the closure ecosystem in general um and and I think that's fine and and I want to be clear my goal here is not to convince all of the people who are skeptical about closure script but not skeptical about closure to embrace closure script because that's actually not going to earn us very many people right if we had all those hands uh that that went up all of a sudden become not skeptical we've grown by a very small amount right so in this room this is not where we're going to make closure script happen um and in particular if we zoom out and we go into the world of those JavaScript people uh the ratios look pretty different right and and I didn't actually count how many people I put on the left hand side but I I think this is probably pretty close to Accurate um and the reality is I think if you go and tell the closure SC story again we're at closure con and 30% of the hands in the room went up right if 30% of us are skeptical about closure script uh in the broader programming and JavaScript community in particular um wow right that's that's a that's a really tough cell and yet I think the closure script story is powerful I think it's actually compelling for these mainstream people doing JavaScript and and I know this because I've been one of those people for a very long time um now you may be thinking okay yeah you've been a JavaScript guy but you don't understand skepticism about closer script you're selling us closer script at a closure conference uh and and you you might be right in fact if you think about me right this describes me three or four years ago when I first tried out closure script and I was in the center of the bullseye right so for those who don't know a big part of closure script is Google closure right which is a pretty large uh set of stuff that closure script is built on top of and like nobody's ever heard of it um but I had and i' been working with it for years and years building really really big JavaScript stuff uh so I knew that uh I I had it licked I knew all the Java ecosystem stuff I know about class paths all that fun stuff I even am an expert in emac um and and had Proficiency in closure right so closure script for me I should have been the easiest cell in the world uh and and yet three four years ago I tried out closure script and it was terrible it was a disaster I had a horrible experience um so what went wrong right if there's one word it's tooling the tooling was a mess I probably spent 90% of my time experimenting with closure script 3 four years ago just fiddling with tools right and and it actually hurt me coming from the closure world because I expected all my closure stuff to work right I was like why can't I jack in why does none of this stuff actually work and just getting a browser reppel I had to figure out like Austin has to piggy back on the weasel or I don't even know like to this day like does anybody understand this stuff um uh if so talk to me later because I I couldn't figure it out I I don't think I'm smart enough um even when I could get through some of those tooling challenges though they were just missing things right so I'd been using Google closure building really really large JavaScript applications and yet we didn't have modules right so we had no way of kind of breaking up our compilation units um there were Basics missing like Source maps and and a lot of these were kind of known and and acknowledged gaps but there were gaps nonetheless and they hurt the experience of of using using closer script documentation uh was a disaster what documentation was there uh was always out of date because it was constantly changing right everything was moving around all the time uh and you never quite knew what the right tool set was so it was very very frustrating uh and in the end even sort of you know being pre-biased to like closure script and having all the requisite knowledge to be successful with closer script it just wasn't enough better uh against the stack that I was already using and successful with for me to really give it further consideration so you know I I stamped myself with the with the skeptic Mark and moved on I just put closure script back on the shelf and said not interested right and I went right back to the JavaScript world uh which which had served me well so so I am still here on on stage um selling you closure script so something happened between 3 four years ago and today and it looks something like this right this is a partial list of all the amazing things that have happened uh in the closure script ecosystem uh in just the past mostly the past two to three years in fact uh so basically a lot of rough edges got smooth and I think others in this room may have had the same experience I did dabble with closure script a little bit uh in its very early days and have a bad experience like things have gotten way way better and there's a lot of cool new stuff as well so we'll talk through uh some of the stuff in in specifics we don't have time actually to talk about all the cool stuff in closure script um so I'll leave it to some other some other folks who are giving talks to fill in some of those gaps but um seriously if there's people in the room who helped with this stuff you guys are awesome uh really impressive uh impressive momentum and impressive collection of stuff from a very small community so what else changed right if we if we think about over the last three four five years um things have changed really dramatically uh in the world of web development the world JavaScript um in particular right in the old world five years ago there was this default right and and the default was we're going to put jQuery on the page and then we're just going to keep adding stuff till it works right and and that was how everybody started their application 5 years ago with very very few exceptions and and it didn't matter if you were building form validation for your WordPress blog or a rich internet application or whatever we were calling those things 5 years ago you just started with jQuery and started hacking away until it worked um and as applications got more complex this started to break down right and by the way jQuery is still you know here in 2015 fantastic for doing form validation on your WordPress blog by all means use it um but our problems in the world of web development have gotten way more complex and as the old tool set started to break we did some bad stuff right this Middle Ground was not pretty right and so new tools have started to form and in the last 3 four 5 years there's just been an explosion of new stuff um I just really want to emphasize this new stuff is all about the right side here right angular wasn't developed to do better form validation react wasn't developed um you know for WordPress plugins right this is really these Technologies are for these larger single page applications and this is a really important point right because this red square is where all the new stuff is happening and it's where it belongs so when we talk about closure script we're right there in that in that red square we are not we are also not designed uh to help you with with your WordPress blogs form validation that's closure script is is too much for that uh and jQuery is just fine so I really want to emphasize that because I think I I still see confusion in the broader Community about what closer script is for I'm just going to state that it's for this um until proven otherwise this is what this looks like via Google Trends um there are actually believe it or not five different Technologies uh on this on this and again Google Trends just relative search traffic on Google that purple line you can probably guess is jQuery right um and then if you look in the bottom right there's a bunch of static right that's all the other technology and by the way closer script is not one of them because I I I doubt it would register um so if we take jQuery away and zoom in right we see a very different picture right and so the four remaining Technologies are some of the the you know you might say hotter Technologies uh for building single page applications and sort of NVC style applications in the JavaScript ecosystem and you can see right wow look at this tremendous runup for for angular that's actually quite impressive and yet it's static right relative to to jQuery relative to to the whole of the community and I mentioned this uh not not to say that none of these Technologies are important they're all very important but I want to emphasize it's early right and we're still figuring the stuff out um if you're wondering why every single week there's like a new framework or a new library or a new something that you have to learn uh in order to do we development it's because we're figuring it out like we are right now just figuring this stuff out as a broader Community right and closer script is part of that Community right now we're contributing ideas but I think we can be more than that so if you go and talk to your friendly local JavaScript developer and say hey have you thought about closer script right you can probably imagine pretty easily the list of objections that they're going to come up with right I think we all know the first one yeah exactly I see a lot of people making making hand pares in the audience so so yeah clearly we all get this one and and that makes sense right lisp and and you know parthe this it's it's it's different it's really different right it's not a little bit different it's not typescript to JavaScript different it's really different um but a point I want to make and and I find this really interesting is that JavaScript syntax is also getting really scary right so a lot of people who have been using JavaScript um are starting to get scared by changes in JavaScript this is the operator precedence table for JavaScript script right I would show you ours but we don't need one um so here's a fun thing I did um I took this code snippet which by the way uh I'll clue you guys in is completely valid JavaScript it's mostly es6 with a little tiny bit of es7 but you can compile this in Babel this works um so this is Bid JavaScript um I told more than 200 JavaScript developers that this was closure script four people called me on it four people knew that that was JavaScript and not closer script so I think we're at an interesting point where a lot of JavaScript developers are being forced out of their comfort zone and and I think we can sneak in a little bit and say well actually our syntax is very stable it doesn't change every year um we'll see how it goes um but also kind of cool that JavaScript is getting you know destructuring and and uh sequence comp apprehensions and other cool things so that's good too um next objection Community right well nobody actually uses this stuff so if I get stuck I'm I'm I'm really I'm really I'm really stuck um that's not true actually we are a small community let's let's not kid ourselves uh relative to some of these larger communities relative to to even you know the Ember Community um we're very small and yet we're a really great Community uh if you look and by the way I didn't doctor the screenshot on the left hand side just go to stack Overflow and look at the closure script tag people are answering questions right so um people are getting stuck and then people are getting them unstuck right small community but very active Community um really nice numbers on GitHub for some of the some of the more popular closure script projects right I mean you know star counts in the thousands that's actually really impressive uh it's it's it's not normal to to see sort of these smaller communities have uh have such impact and there's some companies using closure script uh and by the way we need more companies using closure script we need a few Marquee names and so um if you're in this room and you work for one of those uh Marquee companies uh I'd love to see you guys do something to get your logo on this list that stuff helps a lot um with easing people's fears about adoption um debugging right I'm writing in this weird language and I'm compiling to stuff that runs in the browser that's going to be a mess not really actually um so uh it's it's pretty straightforward there's a technology called Source maps and this isn't something we invented right this is just like stuff that exists in the broader Community uh and it works great right so I can set a break point on closer script code um and that works fine and again a lot of JavaScript developers are now using this because they're writing code in New School interesting JavaScript that compiles to Old School browser JavaScript um and so you know this stuff this stuff works really well um another interesting thing I want to point out um you may notice that this is an actual screenshot from Google Chrome um and see those things that are colored it's actually syntax highlighting my closer script code right and that's not a plugin there's code that ships in Google Chrome and not some special closure script developer version of Google Chrome the same version of Google Chrome everyone at the coffee shop is using has code to syntax highlight closure script code so I think that's that's a pretty interesting sign that we're we're on an upward Trend here okay great but you guys are bringing lots of value there's lots of stuff in closure script so uh this is going to be really bloaty right I'm going to have to pay a huge cost in terms of code size nope uh I I wrote this I've complete source code on on the bottom so you can you can check my work later uh if you're really really bored um but I wrote two uh essentially equivalent applications you know Allah hello world uh one in closure script and one using jQuery um plus the minimum amount of JavaScript code seen there um to to make it actually work um and after gzipping and in the case of closer script passing through advanced compilation we're actually smaller than jQuery for hello world right um and in fact uh this 23k Gip includes the overhead of persistent data structures so that's pretty good that's pretty good and in particular we'll talk more about code size later um but as you add more stuff uh you're going to pay a much smaller incremental cost with closure script so this is kind of a worst case scenario um and and so if you want to add immutable data structures and make it a little bit more fair we're about half the size of jQuery Plus in a mutable data structures Library pretty good tooling right and and I told totally empath emphasiz empathize with the the JavaScript community on this stuff um they have had to figure out what all this stuff does and I mean all this stuff they don't get to choose like two of these um it's really challenging to glue stuff together in in the JavaScript world right you have to know browserify or webpack or Gulp or grunt or Babble or like everybody has to know all this stuff and it's a lot of stuff and and they've you know they sort of earned their Battle Scars figuring this stuff out and so you can und understand that they're going to be a little bit reticent when you say wait you don't work with any of my existing tools like yikes that's that's a pretty reasonable objection the good news is that we're basically just asking you to pick up one new thing right and yeah maybe you can you can do it without line but I think if you're doing anything even a little bit interesting um you're going to have to pull down some libraries right and line is line is still definitely the best uh the best sort of ease of use story for that everybody puts lining in coordinates um on their GitHub pages so you know this is kind of the tool that you have to learn but that's kind of it actually if you look at what line does it pulls your libraries it compiles your code it makes your output files it concatenates stuff it does Advanced compilation it kind of does everything uh that that that other stack uh does in JavaScript so it's not you know maybe it's super great story but uh it's a lot better than yeah here's eight other tools you need to learn interop uh our story on this uh is actually surprisingly good so let's say that I want to use a popular JavaScript library there's this really cool kind of under the radar thing that was added to closure script um called cljs JS um and it's basically it's it's a combination of a way to package up libraries that are closer script friendly um and a registry so if you want to use react you just add the library just like anything else that you would depend on in closer script whether it's closer script or closer it's just it's the same thing right it's packaged as a jar um you require it and then you just start using it right they package up all the externs and other things that are required for advanced compilation it just works it's really awesome uh and given how much stuff comes in the box with closure script um it's it's very rare that you would need to do something more complicated than just that uh to consume external Javascript code so really good um what if you want to go the other way I want to write some closer script code and make that available to JavaScript totally trivial right that export keyword that's that's it right you put that export keyword in there and then you just call it from JavaScript you're done um really really easy um what about my existing apis right those talk Jason and you know Jason Jason works well we have Transit right and transit's a great Library um it lets you work with existing Jason uh it also lets you take Jason and kind of decorate it and and do you know cooler and more interesting things with it so so Transit really good stuff can I trust this right that's that's definitely anytime there's something new and scary if I said hey guys like for transcript is the next generation of web development you'd say I don't know about this can I trust it and that's a hard question to answer right it's hard to give a data driven answer to can can you trust something other than sort of giving your own anecdotal experience but um here's something that that I think is good there's less than 5,000 lines of code in the in the closure script compiler right and that's the closure code in the closure script in the closure script code base right so there's some Library code closure script yeah we're almost 20,000 lines there but if you really got stuck and you had to read all 4,600 lines of code which is very unlikely You' have to do that I mean that's a weekend right not too bad we're not talking about 200,000 lines of stuff this is not an insurmountable thing most JavaScript developers I believe this is a fact uh write 4600 lines of code every day so somebody's asking for a citation I can't can't help uh okay that's great closer script has all this useful stuff but I'm going to pay for it right okay maybe it's not code siiz but like stuff's going to be slow uh not really right so if you look at the stuff that comes out the closer script compiler it's just JavaScript right we didn't like reinvent Dom there's there's really very little um that we could do even if we wanted to affect performance in a strongly negative way um now you might reasonably say okay but what about those persistent immutable data structures we all know and love like those are expensive right we're going to we're going to pay for those um and that's a reasonable intuition except this thing came along called react that completely flips that intuition around um so basically because of the fact that the Dom is unbelievably slow and a virtual Dom and JavaScript engines have become really really fast um this intuition kind of flips around and so now if you go to reacts page and go way to the bottom of the advanced performance page which I think means the most advanced performance tip that they have they say by the way use immutable JS right um and I won't get into all the details but basically you know shallow equals is cheaper than deep equals uh when you're doing checks and deciding whether whether to update the Dom so oddly enough the thing that should cause performance problems does the opposite so it's an embarrassment of riches for performance in the closure script community so I think those are frankly some of the most common objections and I think we have a really good story for those um there's some somewhat less common objections but they're things that I think we don't have quite as good a story on just yet um there's sort of developing stories but we're not there yet um so I put an asterisk on this section of the objections the first one and I'm going to say this surprised me a lot um I've talked to closer script with a lot of you know real experts in JavaScript people who really know their stuff some of whom have even uh dabbled in closer script and tried it out and Java surprisingly comes up as a thing they're like yeah I love closer script love persistent data structure oh man there's so much good stuff in there but Java right and I'm like really Java like we have strong opinions about Java you don't actually have to write Java right like that's not that bad is it what um but but in fact I I think and and you know I kind of query and they're like uh you know and it really kind of comes down to it just doesn't feel right and and to be perfectly honest with it with you I get it right like when you type node it's just there right like imagine typing node and hitting enter there's like you don't perceive any delay now imagine hyping lying anything and hitting enter right we're we're reaching for the coffee cup and I think that you know it's kind of Death By A Thousand Cuts and especially when somebody's just getting started um that hurts a lot and and I think uh if we're also talking about class paths and other things from the Java ecosystem that is you know thoroughly uncool right and dates back to 1995 I think it just it's it's a problem and and I don't have a good solution because um we're not getting away from java any time soon um but it's something for us to think about I think you know finding a way to to make the introduction of java a little bit more delicate in the process of of telling people about closer script might help a little bit I was surprised um by you know how aggressively people reacted negatively to Java just being there um speaking of new people our first run experience needs some work um so industry standard uh metric ttf X were worst in class um if you're not familiar with ttf X um that's okay I just made it up uh it's time to First XML um which is defined formally as the number of pages after you Google the language name until you see a block of XML uh we're not actually doing very well on this metric um and in case you don't believe me you're welcome to try it yourself um but I'll save you the trouble right so if somebody Googles closure script and clicks the first link as many people I'm sure have done uh this is what they see right and imagine yourself as a an expert JavaScript developer who's just heard you know a very compelling pitch for closure script by maybe someone in this room um who you know is now has a great thing to talk about they're going to come to this page and that's not cool right there's this is just a bunch of stuff that nobody's ever heard of right I guarantee you that the vast majority of of expert JavaScript developers have never heard of any of the stuff uh that I I I highlighted here right and in particular once they see Maven and that block of XML they are like darting out the door like we've lost them at that point um so I think our first run experience needs a lot of work I think our first run experience for closure developers has gotten dramatically better right oh go check out quick start that's that's really good right if you already kind of understand the closer ecosystem that gets you right in awesome um but for a JavaScript developer for the bigger Community needs needs a lot of work types so the JavaScript Community I think has been doing a pretty good job of adding types to JavaScript right this is a difficult thing to do historically languages have kind of been binary on the type decision right you have lots of types or there's kind of minimal types um but in the JavaScript world because there's so much JavaScript code existing the approach has been well let's give you types but you can kind of put them where they make sense which I think is a really good model um I mentioned I have experience with Google closure um that is you know one of the one of the language Frameworks in the JavaScript world that allows you to kind of put types in where they make sense and that's really nice right because types are not always useful but when they're useful it's nice to have them um because we're built on top of because we're built on top of Google closure we can use that and we should um and and there's I think a very minimal amount of work I've seen at least one ticket on this so I know uh it's on the radar um to to actually take advantage of of what exists in the base but but there's more that we can do and and I think really what we need to do is just have an answer to the question what about types right this is a really hot thing right now in the JavaScript community typescript and flow like people are really thinking a lot about this kind of stuff and they're thinking about this stuff because they're writing bigger and bigger and bigger applications and one of the things that people start to long for when they're writing big applications is types and refactoring tools and all the stuff that they're used to from idees and Java world and the net world and so on and so forth so we need we need a way to answer this question um we have tools right we have the underlying Google closure stuff we have some stuff that we can add to the closer script core uh we have you know kind of an interesting extension for runtime types schem totally supports closer script today so that's really cool for a certain category of use cases cord type down the line will likely help us out a little bit on the compile time stuff U but none of this stuff is really baked um so we need to kind of compose this into a story ah you like types let me tell you what we have right now and right now the best story is well we do aity checking by default right there's some things we can say but we we need a little bit more editors this is a problem this is a big problem Oh closer script sounds great but I don't like emac right um people are either sold on emac or they're not by the way I'm sold um but I certainly wouldn't suggest to somebody that you should learn emac and closer script and all this other stuff all at the same time it's a bad idea um and these logos I think all of these are the great tools for for building closure um sorry Vim users I just there wasn't room on the slide um but I I want to be clear these These are the power tools and and everybody who's doing serious closure or serious closure script should get here eventually but it's a tough place to start uh it's a really tough place to start if you don't already know how to use it um and so you know if you don't have experience in job I tried to use cursive just to kind of see well what does this look like even as an emac user um I spent 20 minutes and I couldn't really figure it out right I had to like make a Java project or something it was it was confusing um now the tools that exist over in the JavaScript World tend to be pretty simple right editor Focus um there's a tool called Visual Studio code Microsoft has made a cross-platform development tool um somewhat similar to atam um these are tools that are built on something called electron it's a JavaScript core um designed as a programmer's editor and these are things that you can download and have running you can have code open them in like 30 seconds right you just download it open it and you're you're coding away um both of these come with syntax highlighting out of the box again crossplatform tools for closer script a cool thing that happened just like in the last week or so is par infer um which is this really really cool kind of um evolved take on paredit um and it's written in JavaScript and actually can plug into these kind of simple editors um so I thought well it would be fun to try this out and literally 90 seconds start to finish I was able to download Atom open it up get parer in there and play with it that was like a really good first experience and I think that's a much easier place to kind of get people started hey closure not only is our syntax simple and very stable I'm GNA I'm going to keep selling that until somebody um somebody tells me that it doesn't work um but look at this parf for thing let you do it in a really cool way so I think it's it's it's kind of a new way to sell um without you know without it being so heavy and scary so obviously there's a lot of things that people instantly um think of when you when you pitch closure script I don't want that but there's also stuff that we make better and um we have to talk about templates um because templates are like just a thing that annoy me um so everybody loves templates right like oh templates are so great and oh why do you love templates well templates are great because you know then the designers can build the templates and pass them off to me and then you know I just plug them in and everything works amazingly right does that does anyone actually do that no of course not right like that just doesn't work at all um and if it does work it works in those kind of old WordPress type applications for single page applications your templates don't look like this right because it's not welcome name right it's okay we have some conditional logic and oh maybe actually we need to escape some stuff and uh actually that that needs to be in a loop and uh okay we need some mobile that's what everybody's templates look like and yet the people who love templates are building all this stuff they're like Reinventing everything in order to have this it's Madness it doesn't make any sense at all uh we have a better story for this right I think we have um a very nice syntax using the syntax you already know right there's nothing new to learn you've learned that closure script syntax which is really basic um and you didn't need an operator precedence table so that's cool um and then it works for this too right and so you go from this to this and and it's just better right there's less stuff there it's vastly simpler it works better uh and I don't think you really lose anything in readability um my two cents workflow we're the best at this right now uh our workflow is awesome um if you haven't seen fig whe I don't have time to demo it here but like go look you have to go look at it it's absolutely amazing it's the best thing out there um the JavaScript Community has some hot loading stuff and that's great I want them to do more of that stuff and I want us as a community to to to do more in that model um but we have an advantage right um we build with immutable types by default it's much easier to write reloadable code in closure script and our tools arees Awesome every time I demo fig wheel I always say and by the way I started fig wheel 3 days ago and it still works right like it's so awesome having a robust tool that does something that cool um so I can't say enough good things about fig wheel it's the best thing out there uh we should be screaming it from the rooftops uh Dev cards uh another recent Edition that kind of Builds on that same concept for building sort of you know style guides for components super awesome we're the best of this for now uh call back hell right you might think yeah but you said JavaScript is is getting fancier and they have destructuring uh they probably also fixed call back hell right nope not yet um what I heard about promises no no no it's still callbacks right it's just uh with some stuff around them um so so we haven't fixed callbacks in the JavaScript universe and in fact if you if you ask somebody to take this this problem statement from the goang uh presentation and say hey solve this in JavaScript you're going to get people scratching their heads right I mean that's kind of hard to solve if you don't have the right Primitives and obviously has a really nice way of doing that and we have core a sync enclosure so we can emulate that but we also have core sync en closure script right so this right here Works in closure script right and and so you've got this kind of this great feature of goang that was designed in goang from the beginning and it just works in closure script I mean this is crazy right no call backs here right that that's a really hard problem that you're solving very very succinctly and it matters right because there's a lot of asynchronous stuff happening in a web browser right there's users there there's events happening there's stuff coming from the network there's a lot to coordinate and it's a very hard problem so having good Primitives for doing that uh it's not Superfluous at all it's it's really really really helpful and we have a great story on this right now we should be talking about it if you ever want to be entertained if you're bored go to stack Overflow click the JavaScript tag and find the most popular stuff and you will find example after example of this right somebody asking a very simple question how do I get the current date in JavaScript this is the answer with 934 upvotes and I'll let you guys all come to your own conclusions about whether or not that's a good answer or not I have my own opinion uh but I do know that I don't have to fuss with this because enclosure script oneliner right we've got all this great Library code from the from the Google closure Library uh we don't need to mess with this uh I I came across this question I'm like what are they even trying to do like it took me like 5 minutes to read understand the question then there's all this code yeah it's another oneliner for us right like we just don't even need to worry about this uh and it goes on and on and on again you could spend probably a weekend looking through all this stuff and cackling or whatever it is that you do um but the complete absence of a standard library in JavaScript is a problem it's a big problem and people deal with this stuff every day by copying and pasting crap or adding libraries that are way more than they need to solve the one problem that they care about all this stuff it's just these are on liners it's just it's so easy we don't we don't need to to go and fuss with all that stuff um we talked a little bit about code size earlier a few months ago somebody wrote an article um that got reasonably wide distribution saying the mobile web sucks right wow that's a that's a bold statement you know I like the mobile web why does why does it suck somebody went and looked at this article and the article talking about how bad the mobile web was had seven megabytes of JavaScript I can see how they reach that conclusion uh it might have been on their own website um but the reality is I'm not picking on on on this guy because this is not uncommon right like go around the web and if you want to be depressed open the network inspector and look like ouch it's awful it's awful page after page after page has megabytes and megabytes of JavaScript and people aren't using all this stuff I guarantee you have the 7even megabytes of down of download time that every single user mobile or otherwise has to endure when they go to that site they're probably using 150k of it right but they just don't have the tools to shrink it down so we have a story for this right we have advanced compilation so if you have this C of code uh that you want to to call from if this is seven or even 700 megabytes of JavaScript and closer script code uh closer script will automatically figure out what you're actually using and it'll just find that and that's all that will go into your compilation output this is crazy power right we talked about that hello world example earlier that's the worst case because of this because if you pull in some utilities you know utils cljs and it has 700 functions in there and they use two of them you pay for two functions not 700 functions this is super super powerful stuff um we're leveraging Google's closure compiler for this which is a really robust tool it's been in use for probably about a decade now um it's the tool that powers Gmail and all of all of Google's own really high-profile applications it's a really Rob tool it works fantastically well and we just get that we get to use that so it's it's really really awesome I think it's one of one of the biggest strengths of closer script and I would argue as as somebody who's used Google closure for many many years closure script right now is the best tool path to use Google closure that's kind of a big deal so I think we can we can talk loudly and proudly about how great we do at shrinking code um but it gets better right I I referenced this a little bit earlier um closure script didn't have modules 3 to four years ago that was a big gap especially for me coming from that Google closure background because we wrote really big applications and modules are really important it's great to only take the code that you need and put it into an output module but even that might be too big right if that's a megabyte of code I I don't want the code for the settings page to be downloaded when somebody goes to the homepage right this used to be really easy right back in you know five years ago we would just throw in jQuery we would write all of our utility code directly in utils JS we would write all of our other code in uh in the module that it made sense so our development time module modle system was exactly the same as our runtime module system so it was pretty easy to reason about that um but then we started building bigger stuff right and we started breaking up files and doing code organization stuff we changed the way that we do our Dev organization but we didn't fix the runtime organization right so now we've got all these small little files in the JavaScript world and they're all referencing each other and you've got you know everybody's you know organizing their code and all this crazy stuff um but the problem is it's really really hard to go from this broken up thing and then get back to the optimal runtime modules right so most people aren't taking the code for their settings page and taking the code for their homepage and and optimally separating it or even trying to separate it at all if you go and look at most single page applications bam they just put everything into one big file and that's what you download that's what you get most of the time when you go to a single page application you're getting the settings page code whether or not you visit the settings page and I I don't think that's very good again we've got this licked uh and again we're borrowing from the Google closure compiler this is really really powerful I want to emphasize how awesome this is I put a little bit of declarative configuration in into my build profile I say this is the name space for my settings page everything else is automatic so that aform mention utils cljs file if that's referenced from both the home module and the settings module I don't put that into both and in fact I don't put it into base if there's some function that they both depend on that goes into base if there's a another function from that util cljs that's only referenced by settings it goes into settings so it'll actually reach into that code file and put everything exactly where it belongs it's called cross module code motion it's really awesome when you're building big applications this stuff's really important more people should be doing this they don't because the tools are terrible we don't have that problem we should we should take advantage of this stuff so this is relatively new in in the past year or so but this is this is something I'm really excited about because I've used it a ton uh in the past so I'm actually very curious of the of the people in the room especially the people who were non-skeptical had some knowledge of closure script how many of you knew about all this stuff okay I'll point out that rich hickey's hand didn't go up so that's that's that's interesting but I'm always amazed when I go and look at closure script and especially the momentum right how much has happened in the last two or three years especially since sort of the the dawn of the react era um to to think about sort of where do we go next we have an incredible story to tell and and I think our story fits really well with the problems that people have today um so I think what we should do is go out there and tell our story uh I think we need to do a lot better job of proactively going out to the JavaScript Community let's stop trying to sell closure users on closure script right let's go out and sell JavaScript users on closure script uh right now we're considered I think amongst the JavaScript Elite a great idea Factory um but I think we're more than that our story is a lot better than just here some ideas from om that you can use uh in a JavaScript library we better than that um and we aren't done by the way what I've talked about is the stuff that exists today all that stuff is usable today there's stuff coming down the pipe um and uh there's libraries that people are writing that that cross compile between closure and closure script that's awesome do more of that if you're a closure Library author please consider making that available to closure script if it's relevant if corent can do it so can you trust me uh om next is coming coming down the line a lot of people really excited about that um David's talking about that tomorrow react native this is a big deal native mobile applications with closure script sounds good to me I believe the next talk in this room is going to talk more about that so that's exciting um I think om next and react native are a really powerful pair right because some of the challenges that you have with mobile applications like people using things um using versions from two years ago and things like that are things that om uh is particularly good at so think about those two together that could be a really exciting story for closure script uh we need to fix our first run experience right we can't be showing people Maven XML on the first link from from Google we we got to do better than that um I want to plug there's an unsession tonight at 7 pm about new closure. org um and it didn't State whether or not they were thinking about closure script but I'm going to show up and tell them that I think they should think about closure script because I think uh having having a new website and a new way to tell our story um is a great first step um for for fixing that and we need to work on some of those unsolved problems again I don't have answers for this but I really want us to think about tooling right like when somebody says yeah this is interesting enough to try how do we make that as simple as possible for them to get up and running let's not sort of shove class paths down their throat until they're necessary right I do want all these people to be using closure uh uh cursive and emac and all this other great stuff in the ecosystem down the road um but that's that's too much all at once so I really want us to think about that that first run experience and and the initial tooling and uh you know less Java in that case is probably a good thing um so that's all I've got and uh and we're at time um if you have questions I'll be around and uh feel free to to grab me thank you
- from
- Talks, ClojureScript
- added
- 2026-10-10
- likes
- 0
Talks › Categories > Web Development: “by Derek Slager (Clojure/Conj 2015) [41:08]”
ClojureScript › Resources > Videos: “Derek Slager's talk for Clojure Conj 2015 where he is Discussing the many reasons why ClojureScript is in fact a very pragmatic language to consider for web development.”