3 ms·
Although it is a nice joke, CofeeScript has several issues. I could explain why omitting an ending delimiter is an issue, or how easy it is to add a new line o
by limeblack 15y ago
Although it is a nice joke, CofeeScript has several issues.
I could explain why omitting an ending delimiter is an issue, or how easy it is to add a new line or space, but the image does a decent job.
http://img856.imageshack.us/img856/306/javascriptinasimpleway.png http://img856.imageshack.us/img856/306/javascriptinasimplewa...
Now guess which of the three Javascript examples is generated by.
foo -> bar 'foo', -> 'bar'
The point, is that Javascript is simple in demonstrating what are and aren't functions because it has an ending delimiter.
CofeeScript isn't pretty very clear.
- jashkenas 15y agoTo play devil's advocate: Does JavaScript have "several issues", in that it allows you to write your first example like this? https://gist.github.com/1567793 https://gist.github.com/1567793
- limeblack 15y agowhich of the three Javascript examples is generated by? foo -> bar 'foo', -> 'bar' The point, is that Javascript is simple in demonstrating what are and aren't functions because it has an ending delimiter. CofeeScript isn't simple with anonymous function creation.
- jashkenas 15y agoFYI, function application wraps rightward to the end of the line, or the end of the block, so: foo -> bar 'foo', -> 'bar' Means: foo(-> bar('foo', -> 'bar')) But in any case, you wouldn't write it like that.
- limeblack 15y agoTelling the user to write something in two different ways, depending on the argument being passed, isn't simple. The point is an ending delimiter would greatly benefit CoffeScript. Although CofeeScript certainly has its perks, anonymous function creating isn't simple then Javascript.
- jashkenas 15y ago> Telling the user to write something in two different ways, > depending on the argument being passed, isn't simple. Huh? Sure it is. Fun fact: Any algorithm you can write in JavaScript can also be written as a single function, full of nested whiles, if/elses, fors, labels and breaks ... does that mean you should write your entire program as a single function? Nope. I'd like to think that CoffeeScript functions read better without an "ending delimiter": $('button').click -> alert "hello" # Or: app.get '/', (req, res) -> res.send 'Hello World' In any case, if you're interested in using CoffeeScript, but the lack of an ending delimiter is putting you off -- I encourage you to add one in your fork.
- fooandbarify 15y agoJeremy, I don't know much about CoffeeScript but I'm having a really hard time parsing your last example. Did you mean app.get '/', (req,res) -> res.send 'Hello World' ?
- jashkenas 15y agoI did indeed. Serves me right for commenting on the run.
- deleted 15y ago[deleted]
- dekz 15y agoYou do realise jash (the one you replied to) is the creator of coffeescript? There are horrible ways to write a lot of code, especially in whitespace based languages. What does petty comparisons like this bring to the argument?
- limeblack 15y agoYou can read the logic here: https://github.com/joyent/node/pull/2472#issuecomment-3378317 https://github.com/joyent/node/pull/2472#issuecomment-337831... Basically it would be a lot easier if a ending delimiter was the default for the language.
- leptons 15y agoIt would be a lot easier if done in javascript
- benatkin 15y agoThe first instinct of a beginning JavaScript developer on seeing that code would be to reformat it. Not as much with the CoffeeScript code. Also what would the beginning CoffeeScript programmer reformat it to? With the JavaScript code, just removing the extraneous whitespace ought to work. Also you didn't account for the widely-deployed technology of paren/bracket matching.
- deleted 15y ago[deleted]
- chc 15y agoThat image does a facile job. You could create an equivalent for almost any other language, and JavaScript would be lucky if that was the worst kind of criticism that could be leveled at it.