4 ms·
I think anyone who thinks this should take a good long, long look at ClojureScript. * You don't have to refresh the browser to develop, this is single largest
by swannodette 15y ago
I think anyone who thinks this should take a good long, long look at ClojureScript.
* You don't have to refresh the browser to develop, this is single largest productivity boost I've experienced in my 6 years as a JS developer.
* You can fully leverage JS prototypal inheritance (even on natives) because of ubiquitous namespacing
* You have access to macros - you can build the very features that people have been talking / debating about for years today
Unlike CoffeeScript (which I like and use), ClojureScript does lets you write correct code you would never write by hand.
- scott_s 15y agoI don't think your points disagree with his eventual point, which is that JavaScript is the C of the web.
- swannodette 15y agoThe following code looks pretty assembly-like to me ;) This is my state-of-the-art pattern matcher for Clojure working w/ ClojureScript. https://gist.github.com/1177437 https://gist.github.com/1177437 While this may look scary the pattern match compiler now emits precise errors (not shown here). Also I mentioned to Brendan Eich that I created an 8 line ClojureScript macro to marry closures and prototypes. https://gist.github.com/1214547 https://gist.github.com/1214547 You would not write any of this stuff by hand. ClojureScript lets you fully leverage the promise of JavaScript. I haven't seen anything else that comes even close.
- scott_s 15y agoIt also looks like the kind of code one would generate when C is the target language.
- swannodette 15y agoSure before Google Closure takes an optimization pass at it. Anyways, I don't really think it's a point worth debating to death - I defer to Erik Meijer.
- cousin_it 15y agoYour first example has massive code duplication. If you did that in idiomatic JavaScript, it would be smaller, faster and debuggable.
- cheez 15y ago> You don't have to refresh the browser to develop, this is single largest productivity boost I've experienced in my 6 years as a JS developer. How does it work?
- swannodette 15y agoClojureScript supports a feature called Browser REPL. The compiler REPL compiles your code to JS and sends it to the browser for evaluation which sends the result back. This means you can develop w/o restarting the browser or ever leaving your source file while incrementally developing your project. At the moment it works best in Emacs, but people are starting to add support for other development environments. After developing JS this way going back is simply painful.
- bretthoerner 15y agoIs the only difference between the ClojureScript REPL and Firebug/WebInspector (for JS) that I get to keep using my editor? I mean, you can already do JS at the REPL without reloading the page. fwiw, I'm an Emacs user, Lisp geek, and huge Clojure fan. I see the benefit of this, I'm just curious if not leaving my editor is the only advantage or if I'm missing something else.
- swannodette 15y agoI dunno, IME, refreshing the browser to test small changes is a massive time sink.
- bretthoerner 15y agoI think you misunderstood. I can already pull up a REPL (that's running code on the current page) and write/paste as much JS as I like into it without ever refreshing. So is the fact that you get to stay in Emacs the main selling point? Like I said, I'm just trying to understand.
- 15y ago
- thurn 15y agoWhat kind of performance hit does ClojureScript come with? I imagine there's a lot more of an impedance mismatch between Clojure and JavaScript, especially since you presumably only use immutable objects and arrays.
- nickik 15y agoClojureScript adopts some of JS semantics like the numbers. Like with Java you can use nativ arrays if you really need to. ClojureScript has an implementation of Clojures immutable Data Structurs this are slower then nativ objects but should not be the bottleneck in most applications. The great thing about ClojureScript and performace is that ClojureScript get piped threw the google closure compiler with does dead-code elimination and some other optimizations. I have not written any big enought app in ClojureScript that I could really tell but if you look at the compiler output you'll be surpised how little there is.