Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The moment you try to do simple things like concatenating a string you realise that javascript is a bit more tedious than it needs to be.

While nowadays I prefer coffeescript to js, I would rather have some syntactic sugar like scss is for css. I've looked into it but nothing has enough momentum to make me sure it will still be around in two years or so.

As a sidenote, while I mentioned I prefer CS, have you ever tried using a ternary operator? or pass a callback function in jquery (ex. the hover out event)? or just return "this". There are so many things that feel so wrong.



Feel so wrong in... CoffeeScript? Or JavaScript? I think ternaries and callbacks are both much cleaner in CS (with the exception of "callback, something-else" which does end up a little funky unless you add parens). Just naming a variable to return it seems a little wrong to me but you can always leave the "return" in. "Optional" is very different than "never use".


Those last things feel wrong in coffeescript. Honestly, what's more readable:

  x = a ? b : c
or

  x = if a then b else c
And for the last one:

  function() {
    // doing something
    return this;
  }

  ->
    # doing something
    @
Don't get me wrong, I love the fact that I can do nice stuff such as callback?() and some other nifty tricks, but while I'm still having fun using coffeescript, in my experience it's not that great as most people make it up to be.


Just FYI, using standalone `@` isn't considered to be good CoffeeScript style. It's discouraged for this very reason -- just use `this` instead.

The reason why it works in the first place is for consistency ... in every other context, you can use an `@` to replace a `this` or `this.`.


FYI, I usually use this instead of @ myself, but in this case I used @ to empathize a grander issue.

And it's not like there's a warning about it being removed on coffeescript.org where it's being mentioned as an alias for this in the first place.


I prefer words to symbols any day. I think coffee's ternary is better. Also, I have no problem throwing singular @s around cuz they're short and get used so often, but typing out 'this' would be fine too.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: