Live data from Hacker News

Why CoffeeScript Isn't the Answer

walkercoderanger.com

11–20 of 148 posts

Re: Why CoffeeScript Isn't the Answer

#11
post #5

Answer to what? What's wrong with Javascript in the first place?

People have documented this many times. It boils down to surprising features of the language.

http://johnkpaul.github.io/presentations/empirejs/javascript...

https://speakerdeck.com/felixge/javascript-the-bad-parts

Re: Why CoffeeScript Isn't the Answer

#12
Ok, so if CoffeeScript is just JavaScript, add the parenthesis. If you need brackets to make a section of code readable or compile to "certain" JavaScript, then add them. Even the programs I work on we add parenthesis, brackets, etc for readability. Use CoffeeScript to increase productivity. Nowhere does CoffeeScript say you must use white space instead of brackets and such. Keep it simple and easy, classes are also nice; I'll be reading those are articles soon as well to gain less of a bias.

Re: Why CoffeeScript Isn't the Answer

#13
I believe there will be a day when converting CoffeeScript to just native JavaScript won't be very difficult, but until that time, it's useful as a way to have neat syntax features without having to wait for browsers to support it. Indeed, many of the features CoffeeScript introduced into the JS developer's mindset are or will be present in the upcoming ECMAScript specifications. We can only assume this trend will continue.

Re: Why CoffeeScript Isn't the Answer

#14
post #7
post #5

Answer to what? What's wrong with Javascript in the first place?

He covers that here: http://www.walkercoderanger.com/blog/2014/02/javascript-mine...

Ironically - he doesn't it's kind of the whole flaw in the series.

How is JavaScript a minefield? Well, JavaScript has all sorts of pitfalls lurking for the developer. Each pitfall is like a mine in the minefield, silently waiting for you to accidentally step on it. Just like the minefield, JavaScript’s mines are hidden in plain sight. Entire books have been written about all the mines present in JavaScript. Maybe I’ll get into what some of those are in future blog posts.

So then he goes into why Typescript/Coffeescript/Dart aren't the answer to the "Javascript minefield" though he doesn't actually describe the mine's he's trying to avoid. He's not even bothering to setup a strawman to knock down. Its kind of hard for any tool to solve an undefined problem.

Re: Why CoffeeScript Isn't the Answer

#15

    delayed: () ->
      -> this.model  # isn't the class
Well, that isn't really fair now, is it? You could have used the fat arrow (`=>`) for binding `this` to the class.

With that in mind, I agree with the author in that CoffeeScript isn't the answer, at least not exactly. With syntax this incredibly similar, how far are we from compiling python (with generators, with statements, imports, ...) to JavaScript?

Re: Why CoffeeScript Isn't the Answer

#16
post #5

Answer to what? What's wrong with Javascript in the first place?

People have documented this many times. It boils down to surprising features of the language. http://johnkpaul.github.io/presentations/empirejs/javascript... https://speakerdeck.com/felixge/javascript-the-bad-parts

[deleted]

Re: Why CoffeeScript Isn't the Answer

#17
post #15

delayed: () -> -> this.model # isn't the class Well, that isn't really fair now, is it? You could have used the fat arrow (`=>`) for binding `this` to the class. With that in mind, I agree with the author in that CoffeeScript isn't the answer, at least not exactly. With syntax this incredibly similar, how far are we from compiling python (with generators, with statements, imports, ...) to JavaScript?

There are a few projects, this is one: http://en.wikipedia.org/wiki/Pyjamas_(software)

Re: Why CoffeeScript Isn't the Answer

#18
Sometimes I think that most CoffeeScript, ClojureScript, etc. programmers are people who were advanced in other languages before they learned JavaScript. There are quite a few programmers who have no issues with these "bad parts" or "really bad parts" because they cut their teeth on them, and these numbers are growing: Most people now learn JavaScript as their first language. JavaScript already won, and things like CoffeeScript are the last gasp of the old regime.

Re: Why CoffeeScript Isn't the Answer

#19

Sometimes I think that most CoffeeScript, ClojureScript, etc. programmers are people who were advanced in other languages before they learned JavaScript. There are quite a few programmers who have no issues with these "bad parts" or "really bad parts" because they cut their teeth on them, and these numbers are growing: Most people now learn JavaScript as their first language. JavaScript already won, and things like C…

As someone from the old regime (cut my teeth on spectrum basic in the 80's, get of my lawn etc etc) I sorta agree.

For years I avoided using javascript beyond wiring little bits of jQuery together because I hated the language but eventually I ran into a project where I could no longer do that and resolved to learn javascript properly.

Many wtf's where had but now looking back I realise that Javascript is a warty language (but then show me a widely used (top 10) language that isn't).

I still don't like it but I don't hate it and I just accept it for what it is.

Re: Why CoffeeScript Isn't the Answer

#20
This article proves not that CoffeeScript is flawed but that Jeff Walker doesn't understand how to use it. For instance, his first example is:

    # BROKEN
    func 5, {
       event: (e) -> 
         if e.something
           36
         else
           45,
       val: 10}
Anyone with more than a day's experience with CoffeeScript knows that it's much better to express this with the simpler:

    # far better
    func 5,
       event: (e) -> 
         if e.something
           36
         else
           45
       val: 10
Note how just dropping the excessive notation makes the intention clearer while also making the code cleaner.

His example on variable capture neatly illustrates a few of the opinions of CoffeeScript that actually make it far easier to reason about code: don't use global variables, and if a variable has the same name, it should refer to the same thing. It's far more confusing to allow rampant variable shadowing. Code that relies on variable shadowing is simply broken.

His last example shows a fundamental misunderstanding of not just CoffeeScript, but JavaScript generally. Granted `this` binding can be sometimes confusing, which is why CoffeeScript has a fat arrow (`=>`) to automatically capture `this`.

Post reply on HN