Earlier quoted context omitted.
Like the Node.js community, when they're not busy fighting themselves over gender pronouns.
Ooh, is there a story behind this one?
CoffeeScript 1.7.0
71–80 of 91 posts
Re: CoffeeScript 1.7.0
#72Earlier quoted context omitted.
There has been a development of hate towards CoffeeScript in most JavaScript communities. CoffeeScript seems to be very popular in the non-JS communities that need to write JavaScript, like in the Ruby and Python web development communities. CoffeeScript was designed for non-JS coders to feel a lot more comfortable writing JS.
CoffeeScript was designed for non-JS coders to feel a lot more comfortable writing JS. I'm not so sure about that. I use it as an experienced JS developer because it makes a lot of needlessly complex JS operations simpler. Most of those are features in ES6, so it may well go out of vogue then - I've played around a little and may well end up returning to JavaScript at that point.
The original reason for hatred towards CS in the Node community was when module written in CS started showing up on npm. If someone was trying to debug something and hunt down a problem to your module, they can't really read the code generated by CS(because it really does become a mess unless you don't abuse the syntactic sugar), and you can't debug the CS code.
Another problem occurs when you're trying to setup a sane build system for your project. It can become really tedious to use the entire build system every time you want to run your code, and even more to setup everything correctly with source maps, stack traces, minifying, etc. Just about every other module that deals with the code you write will support CS, so in many cases it is the deciding factor in which modules or libraries to use.
The original reason for me to dislike CS was because the first team I worked with using CS made so many different style choices about the code that it become unreadable. Some people wanted to use the syntactic sugar sparingly, others would use it and put everything in one line.
Take this for example:
# print all lines given
pall = (lines...) -> console.log line for line in lines
Someone might write the function like that so that it would fit on one line and be easier to call. But as it turns out, there is a lot more than meets the eye. This is the generated code: var pall,
__slice = [].slice;
pall = function() {
var line, lines, _i, _len, _results;
lines = 1
Which in that case, you might as well skip CoffeeScript's for loop and do an ES5 `Array.protocal.map` call, which will do the same thing, and can be optimized a lot further by the engine. # print all
pall = (lines...) -> lines.map (line) -> console.log(line)
Which, in V8, can be shortened down to: # print all
pall = (lines...) -> lines.map console.log
That skips the whole array generation part and is much more concise and up to ES5 standards. But there are still a few more problems with the code. Look at what it generates: var pall,
__slice = [].slice;
pall = function() {
var lines;
lines = 1
See a problem? We could skip the entire first two lines by calling `Array.prototype.map` directly on the arguments. But also, we've forgotten that we never needed to 'map' over the array in the first place, because we know that `console.log` will return `undefined`. I just stuck with using map over `.forEach` so it would match CoffeeScript's 'always return something' rule, and it would be ugly to have an empty handing `return` at the end. So instead, we should probably write the function like so: # print all
pall = -> Array::forEach.call arguments, console.log
This is all in all the best of all the other code, because it generates the optimal representation in JS. If you wrote code like what CS generates, then you could see and make out a ton of flaws before hand, but who dare questions the power of CS and inspects the generated code? But none the less, if you were to write your CS like that, there would be no point in CS. Still, if you wanted to cleanest possible code to be generated, you'd need to put one of those annoying empty returns at the end of the function. pall = -> Array::forEach.call arguments, console.log
returnRe: CoffeeScript 1.7.0
#73Earlier quoted context omitted.
There has been a development of hate towards CoffeeScript in most JavaScript communities. CoffeeScript seems to be very popular in the non-JS communities that need to write JavaScript, like in the Ruby and Python web development communities. CoffeeScript was designed for non-JS coders to feel a lot more comfortable writing JS.
I'm also not so sure about the "non-JS coders" part. As a proficient Javascript programmer, I absolutely love CoffeeScript. I even recommand it to learn the good parts of JS when you are completely unfamiliar with it. I think there is a lot more than synctactic sugar to Coffeescript. It makes obscur or verbose JS patterns really easy to use. My code generally compiles down to up to twice as much JS code. Yes the comp…
Re: CoffeeScript 1.7.0
#74Is coffeescript still hip? I used to read a lot about it on here, maybe a year or two. Where is it at? Mainstream?
There has been a development of hate towards CoffeeScript in most JavaScript communities. CoffeeScript seems to be very popular in the non-JS communities that need to write JavaScript, like in the Ruby and Python web development communities. CoffeeScript was designed for non-JS coders to feel a lot more comfortable writing JS.
Re: CoffeeScript 1.7.0
#75I absolutely love CoffeeScript, with how it structures classes and functions makes sense (plus the python like syntax was a big plus for work). JavaScript seemed to unorganized, unclear, and cluttered for big projects.
I do a fair amount of coffeescript work and every time I see the compiled source I'm so glad that I'm writing in coffeescript. It's not just that it makes certain JS gotchas almost non-issues (almost! there are still several things that can trip you up), it's that it makes clean, concise and correct programming so much easier. There are a lot of things, like curried functions (`f = (a) -> (b) -> result`) or testing f…
Re: CoffeeScript 1.7.0
#76Earlier quoted context omitted.
I'm also not so sure about the "non-JS coders" part. As a proficient Javascript programmer, I absolutely love CoffeeScript. I even recommand it to learn the good parts of JS when you are completely unfamiliar with it. I think there is a lot more than synctactic sugar to Coffeescript. It makes obscur or verbose JS patterns really easy to use. My code generally compiles down to up to twice as much JS code. Yes the comp…
What speed and ease to you gain with it? CoffeeScript won't get you any performance; if any, less. Making obscure or verbose patterns easier to use is syntactic sugar. Part of the thing about CoffeeScript, is that there are more bad parts that it introduces than prevents. Cleaning up the class model is generally not a good thing, since JavaScript isn't designed to have true OOP principles. Things like it's expressive…
I'm not sure about that; it prevents many of JS's ugly quirks: http://arcturo.github.io/library/coffeescript/07_the_bad_par... ;)
> Cleaning up the class model is generally not a good thing, since JavaScript isn't designed to have true OOP principles.
I really don't understand this. What does "true OOP principles" mean? Objects are so central to JavaScript that it has a concise syntax for object literals. It even goes to the extent of having a dynamic "this" to let any function work as a method in an object.
It has its rough edges (like primitives), yes, but they don't make it a non "true OO" language (whatever that means) IMO.
> [...] it's expressive for loops [...] shun people from using ES5 array methods like .forEach, .map, and .filter, which are a lot cleaner and more optimizable by the engine.
Thay are cleaner in the compiled JS, but Coffee's for loops are quite clean too, and they don't require a nested closure ;)
And, although i would also like native Array#forEach et al to be faster than manual for loops, that hasn't been the case in modern JS VMs: http://jsperf.com/for-vs-foreach/75
Re: CoffeeScript 1.7.0
#77Earlier quoted context omitted.
What speed and ease to you gain with it? CoffeeScript won't get you any performance; if any, less. Making obscure or verbose patterns easier to use is syntactic sugar. Part of the thing about CoffeeScript, is that there are more bad parts that it introduces than prevents. Cleaning up the class model is generally not a good thing, since JavaScript isn't designed to have true OOP principles. Things like it's expressive…
> Part of the thing about CoffeeScript, is that there are more bad parts that it introduces than prevents. I'm not sure about that; it prevents many of JS's ugly quirks: http://arcturo.github.io/library/coffeescript/07_the_bad_par... ;) > Cleaning up the class model is generally not a good thing, since JavaScript isn't designed to have true OOP principles. I really don't understand this. What does "true OOP principle…
Re: CoffeeScript 1.7.0
#78Earlier quoted context omitted.
CoffeeScript was designed for non-JS coders to feel a lot more comfortable writing JS. I'm not so sure about that. I use it as an experienced JS developer because it makes a lot of needlessly complex JS operations simpler. Most of those are features in ES6, so it may well go out of vogue then - I've played around a little and may well end up returning to JavaScript at that point.
The thing about CoffeeScript is that it makes it a ton easier to reason about doing operations like default arguments, pattern matching or expressive for loops. When you don't see the messy code generated from its syntactic sugar, you don't think its a problem. But when it comes to best practices, long term decisions and performance , CoffeeScript will stab you in the back. The original reason for hatred towards CS i…
pall = (lines...) ->
(console.log line) for line in lines
return
Is going to get you much better performance in JavaScript than using the forEach method.Re: CoffeeScript 1.7.0
#79Re: CoffeeScript 1.7.0
#80Is coffeescript still hip? I used to read a lot about it on here, maybe a year or two. Where is it at? Mainstream?
But now that decent alternatives with support for static types like Typescript and Dart exist, I'd choose either one over Coffee just for maintenance reasons and improved tooling support.