If you understand programming (there is a difference between knowing how to program and understanding, a lot of people lack the latter) there is absolutely no difficulty learning CS if you know JS.
I've been coding CS for over a year now and I like it, I've never found it hard to debug and it's just easier to read.
I've made some pretty large apps in CS, by myself and in teams. So many good things in CS that I can no longer live without when writing front-end code:
1. @ = this
2. -> to => solves almost every context problem
3. Object notation by simply using colons ':'
$('body').css
color: 'red'
background: 'blue'
4. statement if condition
5. jsondata?[2]?.hierarchy?.url
6. Optional brackets allow very terse/clean code:
setTimeout ->
statement
, 1000
7. (function_argument = 'default_value') ->
8. Automatic return on last line
9. I also like how CS handles scoping, even though others might not. My very few globals are ALLCAPS and everything else is local scoped. I don't do things like {log, tan} = Math in the global scope just to save a few keystrokes elsewhere.
Add jQuery/Backbone/Underscore/Bootstrap to the mix and you can develop some very large, complex apps with CS in a very clean way. Of course, people may not like some of the above syntax but I love not having to write/parse 2x as much code.
Indeed, the claim that JavaScript developers can't read CoffeeScript seems odd to me. As a novice JS developer, I could read CoffeeScript the first time I saw it and it took me a day to be fluent.
For me there's a noticeable productivity and enjoyment boost from the more terse syntax and that makes it more than worth it for me.
Did they? I can't get to the end of the thread 'cause their infinite scroll thing is not working on mobile safari. Looks like they should focus on coding instead.
I find this a curious debate to have so early in Discourse's life. There doesn't appear to be a pain point, so it's mostly speculation. If this happens, then that consequence, but if this happens, then that other consequence...
I would stick with CoffeeScript until it becomes painful. There is relatively little downside risk. If and when you have great people refusing to contribute code because they hate CoffeeScript, well, that'll be a pain point. On the other hand, what if you get a bunch of other people who like contributing code because they can do it in CoffeeScript?
Are there meaningful statistics collected? Until there are, or at least a weighty collection of anecdotes, I'm sure there's something more important to worry about.
Disclaimer: I don't know Discourse's situation in detail, and I use CoffeeScript on node.js, not the client.
The sheer mass of anti-CoffeeScript FUD ironically makes it more likely that they'll get more contributions if they go back to JavaScript. ;) YOU might know people who seriously consider Erlang and Clojure, but most people respond badly to superficial syntactical differences.
Of course, is "contributions" really the best metric? What about productivity or quality? And can they make it so that people can easily contribute JavaScript?
(Even among people I know, I've heard such irrational FUD against CoffeeScript. And I know it's FUD because none of their boogiemen came true after I aggressively introduced it into their codebase. They now use it every day without concern. Most people hate innovation, including programmers.)
In particular, the ES6 argument sounds like FUD. Did they link to timelines and CoffeeScript developers' opinions? And where's the tradeoff analysis comparing the immediate productivity benefits of CoffeeScript vs some future ES6 event?
From what I understand, the developers have noticed that they get patches for the Rail app but not much for the CoffeeScript part, so they think that by switching to JS they'll get more dev interested.
Also it looks like one of the core dev doesn't like CS much, which might have precipitated things a bit [1].
There is a distinct possibility that the conversation was a chosen topic to try to get at the top of HN, so that we could all go and be consumed by the awesomeness that is Discourse without realizing we just got marketowned.
Are you familiar with CoffeeScript? I've been developing in it for more than 6 months now and that code is perfectly readable to me. Granted, I wouldn't say it's very good code -- I would probably split that into two lines just so it looks less intimidating. But I can assure you, once you get into the swing of it, that's not some intelligible mess -- you can most certainly understand it. And if you don't? Just take a peek at the compiled JS.
Someone said that CoffeeScript is designed to be more writable than readable, and I'd tend to agree with that. But frankly, after having worked with it for the better part of a year, I prefer reading it than JS for just about everything. It's an acquired taste, but don't knock it till you try it :)
If you were to read the equivalent javascript as a one liner it would be hard to read too. Probably more so. Really, all you are pointing out is that you can write shitty code in any language. No language protects you.
If you write beautiful javascript, you will write beautiful coffeescript and it will be 20-60% smaller. Reading less lines is less reading, this helps me.
(ie multi line rather than a single line) but that's very much just stylistic choice. It's also a lousy example of the benefits of cs as the cs version doesn't add any benefit over the plain js one.
If I've understood correctly, the most compelling argument (or at least the most seemingly objective one) is that CoffeeScript conflicts with planned features of ES6+, meaning that there is a risk that large CoffeeScript projects will be locked into the ES5 feature set.
Since Discourse is planning on being around long after ES6 becomes widely available, it was a winning argument.
Also, one of the big reasons the Discourse devs liked CoffeeScript is because it makes it hard to commit common JS errors. Building JSHint into their workflow can help bring this protection back.
Seems like a very narrow mindset. Why would they assume coffeescript won't adapt to ES6? CoffeeScript compiler can change quickly while maintaining backwards compatibility. ES6 standards move at a snails pace.
There's other perfectly valid reasons to use pure-JS on a large open source project, but the ES6 thing is a red herring IMHO.
> CoffeeScript has significant whitespace. So instant no. It makes it a pain in the butt to parse. It's annoying. Most people (except for Python developers) don't like it. Due to being difficult to parse, you will have problems when you try to refactor. Not to mention the problems of re-indenting everything when you have really long and ugly blocks you want to clean up (happens).
maybe people should stop writing unindented ugly blocks in their non-indent-significant language then?
No one is writing un-indented code. The issue is lack of metadata for automatic indentation.
In C if I shift a block of code a quick gg=G will reformat and reindent. Possible because blocks are explicit and whitespace is separate from scope. By the same token autogeneration of {}'s is impossible in C. This is obvious but obfuscated in Python from whitespaces' overloading.
The issue is autogeneration of blocks. In any language blocks are a fundamental aspect of programming. Blocks affect the function of a program. Since we lack self-programming computers we also lack autogeneration of blocks. Python's issue is that a non-fundamental aspect of programming has been paired with a fundamental aspect of programming.
Is it just me or is anyone else finding it weird viewing a thread on Discourse from HN? It's basically the same thing IMO (although obviously this is a Discourse site announcement). I just hope this doesn't become a "thing" as it's just essentially same as linking to a forum post.
I just thought it was a way for the Discourse guys to get people here to look at a 'real' thread in Discourse to get a feel for the system. If it is compelling enough to get someone to register and comment its a double benefit.
That said, the annoying ones for me are links to Google+ things, the URL says "google.com" but the content is various.
History repeats itself. This topic reminds me of QWERTY vs. Dvorak. People continue using something because everyone else is and they always have; not because it's the optimal option.
I supported the switch to JavaScript, despite being an avid Coffeescript developer. Why? Because any CoffeeScript developer worth their salt already knows JavaScript, and can translate the JS to CS and back quite simply (admittedly, it's not as nice as hand-written CS, and the compilation loses comments, but I still prefer it to writing the JS by hand if I'm doing a bunch). But many, many JS developers don't know CS, or don't like it.
Now, this only affects the first official client. I imagine that there will be a CS port of the JS client as soon as the switch is made. That's the great thing about using a client to a REST API - you can have several different front-ends. If this was to be the only client, I'm not sure if I would support using JS over CS.
(btw, I'm @benaiah on meta.discourse.org - I'm in the referenced thread)
I think the advantage of this project being open source becomes really clear in situations like this: I'd imagine js2coffee[1] will cover most of their bases, but in the situation that it doesn't, they have a (pretty active) Github community to fall back on for the finicky bits of conversion.
I developped a little layout library ( work in progress ) which is a port of a flash lib. and frankly coffeescript made it really easy and made me wrote far less code that pure javascript.
One can write readable code with Coffeescript , i use parenthesis in big scripts because it is more readable , and i dont use classes where not appropriate.
CS helped me write better javascript without the badparts so i dont need to be a human compilator and fix javascript each time i write it. I should not have to.
It is not for everyone , but significant white spaces are not a problem if one is used to indent his code properly. I tried typescript too , which is good, but i found coffeescript more expressive. The truth is , i enjoy writing CS , i dont writing JS.
[+] [-] ansman|13 years ago|reply
I've been coding CS for over a year now and I like it, I've never found it hard to debug and it's just easier to read.
[+] [-] chime|13 years ago|reply
1. @ = this
2. -> to => solves almost every context problem
3. Object notation by simply using colons ':'
4. statement if condition5. jsondata?[2]?.hierarchy?.url
6. Optional brackets allow very terse/clean code:
7. (function_argument = 'default_value') ->8. Automatic return on last line
9. I also like how CS handles scoping, even though others might not. My very few globals are ALLCAPS and everything else is local scoped. I don't do things like {log, tan} = Math in the global scope just to save a few keystrokes elsewhere.
Add jQuery/Backbone/Underscore/Bootstrap to the mix and you can develop some very large, complex apps with CS in a very clean way. Of course, people may not like some of the above syntax but I love not having to write/parse 2x as much code.
[+] [-] msutherl|13 years ago|reply
For me there's a noticeable productivity and enjoyment boost from the more terse syntax and that makes it more than worth it for me.
[+] [-] eurleif|13 years ago|reply
[+] [-] ricardobeat|13 years ago|reply
[+] [-] sams99|13 years ago|reply
you can get it to work on mobile safari in portrait if you zoom in / out ... but that just too hacky
[+] [-] ben0x539|13 years ago|reply
[+] [-] manojlds|13 years ago|reply
[+] [-] raganwald|13 years ago|reply
I would stick with CoffeeScript until it becomes painful. There is relatively little downside risk. If and when you have great people refusing to contribute code because they hate CoffeeScript, well, that'll be a pain point. On the other hand, what if you get a bunch of other people who like contributing code because they can do it in CoffeeScript?
Are there meaningful statistics collected? Until there are, or at least a weighty collection of anecdotes, I'm sure there's something more important to worry about.
[+] [-] calibraxis|13 years ago|reply
The sheer mass of anti-CoffeeScript FUD ironically makes it more likely that they'll get more contributions if they go back to JavaScript. ;) YOU might know people who seriously consider Erlang and Clojure, but most people respond badly to superficial syntactical differences.
Of course, is "contributions" really the best metric? What about productivity or quality? And can they make it so that people can easily contribute JavaScript?
(Even among people I know, I've heard such irrational FUD against CoffeeScript. And I know it's FUD because none of their boogiemen came true after I aggressively introduced it into their codebase. They now use it every day without concern. Most people hate innovation, including programmers.)
In particular, the ES6 argument sounds like FUD. Did they link to timelines and CoffeeScript developers' opinions? And where's the tradeoff analysis comparing the immediate productivity benefits of CoffeeScript vs some future ES6 event?
[+] [-] laurent123456|13 years ago|reply
Also it looks like one of the core dev doesn't like CS much, which might have precipitated things a bit [1].
[1] http://meta.discourse.org/t/is-it-better-for-discourse-to-us...
[+] [-] bawllz|13 years ago|reply
[+] [-] rooshdi|13 years ago|reply
[+] [-] jtchang|13 years ago|reply
MyApp.president = Ember.Object.create fullName: (-> @get('firstName') + ' ' + @get('lastName') ).property('firstName', 'lastName')
How the hell am I suppose to read that?
[+] [-] aroman|13 years ago|reply
Someone said that CoffeeScript is designed to be more writable than readable, and I'd tend to agree with that. But frankly, after having worked with it for the better part of a year, I prefer reading it than JS for just about everything. It's an acquired taste, but don't knock it till you try it :)
[+] [-] nahname|13 years ago|reply
If you write beautiful javascript, you will write beautiful coffeescript and it will be 20-60% smaller. Reading less lines is less reading, this helps me.
[+] [-] cubicle67|13 years ago|reply
it's not exactly a shining example of good coffeescript, but I think this is equivalent js
I'd probably write it in cs as (ie multi line rather than a single line) but that's very much just stylistic choice. It's also a lousy example of the benefits of cs as the cs version doesn't add any benefit over the plain js one.[+] [-] adamesque|13 years ago|reply
Since Discourse is planning on being around long after ES6 becomes widely available, it was a winning argument.
http://meta.discourse.org/t/is-it-better-for-discourse-to-us...
Also, one of the big reasons the Discourse devs liked CoffeeScript is because it makes it hard to commit common JS errors. Building JSHint into their workflow can help bring this protection back.
[+] [-] jacquesc|13 years ago|reply
There's other perfectly valid reasons to use pure-JS on a large open source project, but the ES6 thing is a red herring IMHO.
[+] [-] zalew|13 years ago|reply
maybe people should stop writing unindented ugly blocks in their non-indent-significant language then?
[+] [-] Danieru|13 years ago|reply
In C if I shift a block of code a quick gg=G will reformat and reindent. Possible because blocks are explicit and whitespace is separate from scope. By the same token autogeneration of {}'s is impossible in C. This is obvious but obfuscated in Python from whitespaces' overloading.
The issue is autogeneration of blocks. In any language blocks are a fundamental aspect of programming. Blocks affect the function of a program. Since we lack self-programming computers we also lack autogeneration of blocks. Python's issue is that a non-fundamental aspect of programming has been paired with a fundamental aspect of programming.
[+] [-] fourstar|13 years ago|reply
[+] [-] eurleif|13 years ago|reply
[+] [-] ChuckMcM|13 years ago|reply
That said, the annoying ones for me are links to Google+ things, the URL says "google.com" but the content is various.
[+] [-] smnrchrds|13 years ago|reply
[+] [-] dsego|13 years ago|reply
[+] [-] benaiah|13 years ago|reply
Now, this only affects the first official client. I imagine that there will be a CS port of the JS client as soon as the switch is made. That's the great thing about using a client to a REST API - you can have several different front-ends. If this was to be the only client, I'm not sure if I would support using JS over CS.
(btw, I'm @benaiah on meta.discourse.org - I'm in the referenced thread)
[+] [-] kmf|13 years ago|reply
[1]: http://js2coffee.org/
[+] [-] jaredmcateer|13 years ago|reply
[+] [-] niggler|13 years ago|reply
[+] [-] Herbert2|13 years ago|reply
[+] [-] itsbits|13 years ago|reply
[+] [-] camus|13 years ago|reply
One can write readable code with Coffeescript , i use parenthesis in big scripts because it is more readable , and i dont use classes where not appropriate.
CS helped me write better javascript without the badparts so i dont need to be a human compilator and fix javascript each time i write it. I should not have to.
http://mparaiso.github.com/Coordinates.js/
It is not for everyone , but significant white spaces are not a problem if one is used to indent his code properly. I tried typescript too , which is good, but i found coffeescript more expressive. The truth is , i enjoy writing CS , i dont writing JS.