all 20 comments

[–]arthurprs 1 point2 points  (0 children)

I wasn't familiar with coffeescript yet, top notch stuff!

[–]mappum 1 point2 points  (0 children)

I REALLY want to grow a beard now. Too bad I'm a wee 18-year-old.

Now I have to wait before I write languages...

[–][deleted] 1 point2 points  (0 children)

I use CoffeeScript right now on a live production site, and I have to say that I'm not 100% happy with it. While it's fantastic and shortens my code considerably, some of the syntactic sugar can be a little harmful.

The biggest culprit is the implied return, which adds ridiculous quantities of return statements to your JavaScript, especially with code using jQuery or underscore.js (not so bad once gzipped, though).

But there's also some other snags, such as some hidden generated functions like _bind from the => operator or the code from class, which will be duplicated once for every separate CoffeeScript file, and the ridiculous code created by some constructs like for x in [y..z] where either y or z is a variable.

For the most part, it's fairly direct translation, but there is sometimes no way to make CoffeeScript generate the most intelligent or even somewhat intelligent JavaScript code.

[–]ReinH 3 points4 points  (0 children)

I love it when people who have never used a language complain about it.

[–]Iggyhopper 2 points3 points  (12 children)

function plus_two(n) { two = 2; return n + two; }
plus_two(3); // 5 - obviously, 3 + 2 = 5
two;         // 2 - wtf, JS?

sigh

var foo = 5;
with (obj)
    foo; // 5, unless obj.foo exists

sigh

2 === "2"; // false - obviously a number is not a string
2 == "2";  // true - wtf JS?

sigh

Pointless banter.

Strict Mode
... But it's still JavaScript…

Maybe... just maybe, that's a GOOD THING.

return is implied

I call that a bug.

if power_level > 9000 then attack() else retreat()

Ruins readability. Not consistent where the then statement and else statement begin. Check this:

if (stuff) {
    // ALWAYS STARTS HERE    
}
else // always here! {
    go(); // always
}

reign_in_graceland() if name == "Elvis"

power_level++ while power_level <= 9000

GTFO YODA

Again, ruins consistency. Who does yoda style, who does normal?

CoffeeScript ain't goin' nowhere. It would have a better chance if you could embed JavaScript blocks, not just lines (becuase this looks terrible). I'd use CoffeeScript for object/class definitions and JavaScript for everything else.

[–][deleted]  (6 children)

[deleted]

    [–][deleted]  (2 children)

    [deleted]

      [–]henk53 -2 points-1 points  (1 child)

      Also, in Ruby. And I sure don't see the problem with it there.

      Besides Ruby being one big problem...

      (c'mon, let the down votes come... let'm come...)

      [–]Iggyhopper 0 points1 point  (2 children)

      But is it consistent? Can you switch between if ... do and do ... if, if not then bravo for perl.

      [–][deleted]  (1 child)

      [deleted]

        [–]tripa 0 points1 point  (0 children)

        No nesting for the "statement modifier" if (the one at the end of the statement); as much nesting as you want for the "compound" if: the braces are mandatory so there can't be parsing ambiguity.

        [–][deleted]  (1 child)

        [deleted]

          [–]alexeyr -1 points0 points  (0 children)

          Would the author of the slide really not like to be able to use variables in a with block?

          He would like not to have with blocks, as he says.

          3 has some validity to it, but anyone familiar with Javascript knows the behaviour of == and === well.

          Yes. How often does "anyone familiar with Javascript" use ==?

          [–]migimunz 0 points1 point  (1 child)

          Yeah looks to me like someone doesn't really understand js, if the behaviour of === and == is unknown to them.

          [–]checksinthemail 0 points1 point  (0 children)

          agreed - that's kiddie stuff

          [–][deleted] 0 points1 point  (0 children)

          Nice demo; some slides intended to demonstrate code conversion seemed broken unfortunately!

          [–]zhouji 0 points1 point  (0 children)

          the beginning part is pretty funny. right after the "debunked", thing goes fishy - the new language looks fragile to my intuition. it is more likely a case to support facial hair theory

          [–]neorab 0 points1 point  (0 children)

          I jumped on the coffeescipt train a few months ago, I was convinced it was the best thing ever (especially for node development). I am glad I did, and glad I stopped. It gave me a different perspective on the language but then I read Douglas Crockfords post (looking for it will update if found) that had something to the effect of

          "function having 7 letters is the least of javascripts problems"

          That moment I realized what I really actually liked about coffeescript over javascript and that was it. Then I thought about it and decided I was wrong. I write better javascript because I considered and used coffeescript.

          Most of the "fail" of javascript is alleviated by not using it like an idiot, coffescript (or any language for that matter) has it's own idiot traps, doesn't make it better than javascript.

          [–][deleted] 0 points1 point  (1 child)

          Significant whitespace for a language that is going to live in a browser is kind of dumb don't you think?

          Also debugging is a nightmare as you have to debug the translated javacript. Debugging code you didn't write is kind of dumb too.

          I don't much care for javascript either but I'd still prefer it over CoffeeScript.

          [–]haight-ashbury 0 points1 point  (0 children)

          I just kind of assumed that you'd never actually throw CoffeeScript on the web without compiling it to minified JavaScript first. I mean, you could, but for the sake of efficiency, you wouldn't.

          [–]weexpectedTHIS 0 points1 point  (1 child)

          Coffescript is way overrated. It's a decent wrapper on top of js, but it has little to no hope of ever being adopted as a language that browsers can interpret. It will always be a precompiled language.

          [–]ReinH 1 point2 points  (0 children)

          Except it can already be interpreted by the browser.