5 ms·
At no point ever this: getUser = (id) -> url = "users/#{id}" dfd = $.ajax url: url format: 'json' method: 'get' u
by lloeki 15y ago
At no point ever this:
getUser = (id) ->
url = "users/#{id}"
dfd = $.ajax
url: url
format: 'json'
method: 'get'
url: url
promise: dfd.promise()
was unreadable to me. $.ajax+'\n'+indent instantly triggers nesting, hence call, in my head. The way I instinctively parse this code makes the added parentheses just distractive noise to me. Actually I would have written it this way, which makes things tick even more:
getUser = (id) ->
url = "users/#{id}"
dfd = $.ajax
url: url
format: 'json'
method: 'get'
url: url
promise: dfd.promise()
A single newline makes the whole thing absolutely obvious to me, including the possibly ambiguous meaning around the implicit return.
> It's not a case against using Coffeescript - it's a case against writing terrible code.
Actually it looked like a case of change refusal and confirmation bias. The author seems to be well-versed in JavaScript, trying hard - consciously or not - to write JavaScript in CoffeeScript, which in turn produces terrible code. Every itch gets scratched, producing terrible irritation.
> you can’t compress [whitespace]
gzip. rake assets:precompile generates .gz for you so it doesn't even incur a performance hit on your servers.
> The increase in debugging complexity is a fair point, and it does add an extra step in between finding a problem and fixing it. However, in practice, I'm not sure I've ever had this be a major problem
Me neither. In fact the mapping is most of the times fairly obvious. Besides, editor enhancements[0], though not essential, helps a bit to not have to pull stuff in the browser every single time. Anyway SMAP support (or something close) is on the way[1] but in the meantime it doesn't bother me the least with CoffeeScript, thanks to it being so close to JavaScript.
[0] http://esa-matti.suuronen.org/blog/2011/11/28/how-to-write-coffeescript-efficiently/ http://esa-matti.suuronen.org/blog/2011/11/28/how-to-write-c...
[1] http://www.infoq.com/news/2011/08/debug-languages-on-javascript-vm http://www.infoq.com/news/2011/08/debug-languages-on-javascr...