4 ms·
Brilliant! I had always hoped CoffeeScript or somehow a JS library would add blocking channels like this. Writing JavaScript is a pain after being spoilt by Go.
by saljam 13y ago
Brilliant! I had always hoped CoffeeScript or somehow a JS library would add blocking channels like this. Writing JavaScript is a pain after being spoilt by Go.
I'm quite curious about what the compiled code looks like. (On a mobile now, I'll have a look when I can.)
- jcromartie 13y agoCompiling ClojureScript to JavaScript doesn't yield anything too surprising, and that's great. But core.async does some amazing stuff to actually analyze the code inside a "go" block and recompile it as a state machine so that a single thread can be "parked" and resumed. This allows core.async to work without multiple threads. It does this all at macro expansion time. This is the sort of thing that really demonstrates the power of Lisp. There's no way to do this without modifying the compiler in a language without a macro system. So the output of a core.async program is going to be startlingly different than a normal ClojureScript program, because of the way it takes your "go" blocks apart and rewrites them when the macro is expanded. Here's an example. https://gist.github.com/jcromartie/5991947 https://gist.github.com/jcromartie/5991947
- matthavener 13y agogo blocks are transformed into little state machines. Details here http://tomasp.net/blog/async-compilation-internals.aspx http://tomasp.net/blog/async-compilation-internals.aspx via https://twitter.com/timbaldridge/status/354613181886369793 https://twitter.com/timbaldridge/status/354613181886369793
- deleted 13y ago[deleted]
- deleted 13y ago[deleted]
- amasad 13y agoIt seems like the compiled js code from the page's examples is quite large: csp.js minified ~83kb I wonder if most of that is the runtime and libraries or the resulting JavaScript code is just that big.
- swannodette 13y agoThere is no runtime and note that's 22k gzipped. This is far smaller than jQuery + Underscore.js + persistent data structure library + stream implementation + async control flow library gzipped which is what you're getting. jQuery alone is 33k gzipped.