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

Leaving features off the table and just talking about semantic cleanups, here's a few:

* Switch statement doesn't fall-through by default.

* Variables don't need to be declared with "var", and can't ever become global accidentally.

* Equality is strict, using `===`, if you want coercive equality, you coerce the object yourself.

* Loops that are used to generate functions close over their index variables, so that all inner functions don't share the final value of the index. This is the same problem that ECMAScript Harmony introduces "let" to solve.

* Splats largely replace use of the "arguments" object, so you don't get bit by "arguments" only being a faux-array.

* Comparisons can be chained, as in Python -- so you can write: "100 > x > 25", and have the answer be correct.

* Multiline strings are valid without having to escape the newline.

* And the big one: everything in CoffeeScript is an expression. Without having to use temporary variables, you can return the result of an if/else from a function, pass a comprehension (loop) directly into a function call, assign the result of a try/catch, and so on.

I love JavaScript semantics as well. I think it has the cleanest object/function model out there, in terms of scripting languages -- but that's not to say there aren't parts that can use a little touch-up.



Don't get me wrong. As I am learning JavaScript right now I am only interested in the real fixes and not the nice to have features. Chaining comparisons, multiline strings, everything is an expression are IMHO "just" nice features.




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

Search: