> CoffeeScript, http://coffeescript.org/, is the proper way to program in > JavaScript. It should not cause any brains to explode. >
Thanks. This statement got me reading about CofeeScript. Javascript has been surfacing with increasing frequency at work but I've been largely ignoring it as my wee brain is already full with learning python. CS makes it look approachable and not so distant a possibility. Today I've run into Iced, *"a superset of CoffeeScript<http://coffeescript.org>. ... a drop-in replacement for the standard coffee interpreter; it will interpret almost all existing CoffeeScript programs. ...[it] adds two new keywords: await and defer. These additions simply and powerfully streamline asynchronous control flow, both on the server and on the browser. ... Say hello to clean, readable, maintainable control flow for network and asynchronous operations!"* -- http://maxtaco.github.io/coffee-script/ The example for how these 2 simplekeywords can dramatically affect code readability under the heading "ICS and Standard Control Flow<http://maxtaco.github.io/coffee-script/#iced_control>" is compelling. ICS: ``` # Search for 'keywords' in parallel, then callback# 'cb' with an array of the parallel results parallelSearch = (keywords, cb) -> out = [] await for k,i in keywords search k, defer out[i] cb out ``` CoffeScript: ``` # Search for 'keywords' in parallel, then callback# 'cb' with an array of the parallel results parallelSearch = (keywords, cb) -> results = [] n_out = 0 cb_generator = (i) -> n_out++ (json) -> results[i] = json if n_out-- is 0 cb results for k,i in keywords search k, cb_generator i ``` (the longer and harder to read pure javascript equivalent is omitted. No need for any brains to explode ;-) I bring it up here not to tout the benefits of ICS, which I've not yet used, but as an example of a code pattern or way of thinking that may have some bearing on the recent threads re: distributed or web enabled Leo. Feel free to ignore if not relevant. cheers, -matt* * -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/leo-editor?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
