5 ms·
In this case, the semantics were already decided: CoffeeScript was intended to map transparently to JavaScript. Each change to semantics would add complexity to
by skymt 16y ago
In this case, the semantics were already decided: CoffeeScript was intended to map transparently to JavaScript. Each change to semantics would add complexity to that mapping.
- davepeck 16y agoSyntactic sugar is all CoffeeScript can ever be. Is pretty syntax better than common-use syntax? (To be clear: I don't have a strong opinion. I'm curious what the community thinks the value proposition for CoffeeScript, HAML, etc is.)
- jacobolus 16y ago> Is pretty syntax better than common-use syntax? What do you mean?
- davepeck 16y agoJavascript is understood by most developers these days. CoffeeScript is pretty. (Edit: I don't think that "pretty" is a bad thing. I just... when is it the most important thing, or even high up on the priority list? Pretty isn't bad, but if it means learning an entirely new syntax and immature toolchain, its value for all but personal projects is unclear to me. I see that others value it differently, and I'm trying to understand why.)
- ramidarigaz 16y agoYou say "pretty" like it's a bad thing...
- innes 16y agoIt's unusual usage as well. Like referring to a keyboard that lets me type faster or a screen that's more readable as 'pretty'.
- gfodor 16y agoFor competent Javascript developers the learning curve to CoffeeScript is an afternoon tops, because it is Javascript. If you consider that, it essentially becomes a free lunch since now you can express your ideas more clearly than raw JS.
- davepeck 16y agoInteresting. To me, CoffeeScript is emphatically not JavaScript. There are new tools and, well, there's a new syntax. Semantically they may be (almost) equivalent -- but it strikes me as a far stretch to say they're the same, or that developers will treat them the same. I suppose I would feel similarly about HAML, too.
- gfodor 16y agoCoffeeScript syntax is close enough to Python or Ruby syntax that the syntax itself is "instantly readable" and "quickly writable" -- HAML on the other hand is altogether new syntax and much more 'innovative' on that front than I'd argue Coffee is. I'd be really shocked if you showed a solid Javascript programmer who has written code in a scripting language like Perl, Python, or Ruby a chunk of CoffeeScript code and he/she couldn't easily infer what was going on just by intuition alone.
- gmac 16y ago> Is pretty syntax better than common-use syntax? IMHO, in this instance, absolutely yes. I enjoy using CoffeeScript in a way I've never enjoyed JS. It's easier to write and easier to read. For example, compare: x = this.x; y = obj.map(function(z) {return z + x;}); with y = obj.map z => z + @x I also find it of great benefit if I'm coding elsewhere in Ruby (for example, if I'm coming from some Ruby coding I'm prone to forgetting return statements in my JS at key moments).
- hermanthegerman 16y agoHm, to me the value proposition is this: There are many, many interesting projects that I want to look at, read, potentially use or learn from. Every little help for reading and understanding many open source projects faster is a huge value and a huge timesaver for me. I think that clean syntax is just the better tool, like other people would probably prefer an IDE with integrated toolchain and dozens of tools that are modeled after the state of a programming system at some point in time. Readable semantics behind a clean syntax are the more flexible toolchain in my eyes. It's like an integrated user interface. I can easily read and understand CS/Haml/Sass/Ruby/.. in my own files, in some libraries that i installed, in posts on blogs and on github ..
- M1573RMU74710N 16y agoWell it seems your assumption that "pretty" is purely a luxury, something that's nice to have but serves no practical purpose other than aesthetic satisfaction. Personally I disagree. I think a programming language is not like a car, at least not in that with a car whether it's pretty or not has no practical effect on the utility of the car. You are using the computer language to express your own ideas, and to formulate your own constructs via it's syntax and semantics. When the language's syntax and semantics are clunky, verbose, and full of line noise....those things become intermingled with your ideas and your semantics and it becomes difficult to separate the two. I've been writing Javascript a long time, and what I like about CS is not only that it makes writing code easier by providing shortcuts for patterns I use constantly, but that the finished code more closely resembles the actual ideas I had when I wrote the code. With syntax and semantics that get out of the way you can focus more closely on your ideas and how to improve or fix them imho.
- davepeck 16y agoMy perspective is a little more subtle than that. To clarify: "Pretty" is great -- desirable, even. But if "pretty" comes at the cost of using immature tools that may slow me down, or at the cost of forcing my development team to learn a new syntax just because I believe it's "pretty" -- well, that's a harder value proposition. That's what I'm trying to get at with all this. It sounds like, to you, the level of "pretty" in CoffeeScript outweighs the potential disadvantages -- which is great! I do like the notion that CoffeeScript syntax gets out of the way; that it lays constructs and ideas bare in a way that JavaScript does not.
- alextgordon 16y agoThis is all anecdotal, but learning CoffeeScript took me no more than a few hours, and I seem to be able to write CoffeeScript faster and with less errors than JavaScript. Obviously YMMV, but it's not just about "pretty".
- detst 16y agoPretty to me is the difference in being excited about writing code and feeling dead inside. Yes, a bit hyperbolic but I really don't like even looking at JS at this point. CS makes me more efficient for this reason and for the improved syntax. I feel the same way about Sass/Compass vs CSS, BTW. How long do you expect it to take your team to learn the syntax? I would expect anyone with JS experience to have this [1] page open and be able to immediately start writing code and have it down in no time. 1. http://jashkenas.github.com/coffee-script/ http://jashkenas.github.com/coffee-script/
- kaffiene 16y agoI think you've nailed it. I program a lot of JS. I don't especially like it. CS is trivially better because it is prettier but CS code expresses ideas in much the same way JS does. Big deal.