4 ms·
Disclosure: I have never used CoffeeScript. However, based on the article, the death-knell against CoffeeScript for me was the variable scoping rules. With no
by Roboprog 13y ago
Disclosure: I have never used CoffeeScript. However, based on the article, the death-knell against CoffeeScript for me was the variable scoping rules.
With no variable declaration keyword (a la var, my, local, private), adding a variable assignment anywhere could radically change the variable scoping.
I'm done, this isn't suitable for prime-time, time to go somewhere else.
I spent too many years in the 80s working with xBase. I've been shafted too many times by calling a (coworker's) routine that forgot to declare its variables "private", which stomped over one of my variables. (private in xBase is similar to local in Perl 4) To have a language which doesn't let you declare the intended scope of a variable - ugh.
- ryanatkn 13y agoLiveScript fixes scoping and adds a ton of other nice features including let and const variable declaration keywords.
- kaonashi 13y agoI've used coffeescript extensively for years, and I have never had that be an issue. Not sure if it's because I rarely write a file longer than ~200 lines, or I'm careful about variable names and global scope. More generally I've found that coffeescript mixes much better with a functional style than with an imperitive one.
- varkson 13y agoThese sort of problems crop up a lot more the larger a codebase gets and the more people working on it. Being careful with your variable naming and global scope are necessary to working well with CS.
- kaonashi 13y agoThe biggest problems I find with bad coffeescript that I don't generally find in bad javascript are extensive inheritance hierarchies, overbroad class design, and explicit dependencies. Generally the same kinds of problems I find with bad ruby/java.
- peterashford 13y agoThis, to me, sounds just like Douglas Crockford when he dismisses all the evils of Javascript as "things that never happen to him". Which is interesting, given that they occur to me and my work mates on a fairly regular basis.
- kaonashi 13y agoI don't think the gist is that there aren't problems with these languages, but that with a little carefully placed construction tape, you can avoid falling into the large holes.
- peterashford 13y agoYeah, people say the same thing about C++. It's great when you have your own carefully curated subset of the language.... and then you have to deal with other programmers & libraries
- kaonashi 13y agoThe difference being, you can't avoid javascript (if you want to target the browser); you can either write it directly, or use it as a compile target. Each has it's strengths and drawbacks.
- mikewhy 13y ago> With no variable declaration keyword (a la var, my, local, private), adding a variable assignment anywhere could radically change the variable scoping. > I'm done, this isn't suitable for prime-time, time to go somewhere else. So does that mean Python and Ruby are out the window too? It's really never been an issue in either of the three languages.
- jkrems 13y agoThe problem in Python and Ruby is less obvious because you rarely have big, nested closures. In JavaScript those are pretty common (module pattern, mocha test suites, etc.).
- __david__ 13y agoThe scoping issue is real, but it's very easy to mitigate. I think the real issue is to make sure you just don't ever use (file) global variables. You should enforce scope with the "do" operator: changeValue = do -> value = 42 lastValue = null (newValue) -> lastValue = value value = newValue That hides the new variables in a closure and they no longer leak to the the enclosing scope. This is cleaner code overall since you no longer have some variables at the top level where you can't be sure of how many functions are using them without searching.
- ilaksh 13y agoI think the death-knell was that you didn't want to bother learning CoffeeScript so that you can actually make an informed decision.