Hacker News new | ask | show | jobs
by bbcbasic 3952 days ago
The problem with JS is not that is it aesthetically ugly, but the lack of a decent type system. The fact you can add whatever data you like to any object, and the object itself could be the data or a promise to return the data, and you cannot verify that the caller and callee are compatiable at compile time is asking for so much trouble. Let alone the nasty implicit type casting, two types of null value, truthy values etc. It is a real mess for the programmer who likes to reason about their code.
1 comments

It is really difficult to explain the benefits of static analysis and type safety to people who only work in dynamically typed languages.

The JS community is just now being introduced to compilers, and there is significant push back and lots of people crying for "simpler age". I think it will be a while (if ever) until languages like closurescript, scalajs, & typescript start seeing widespread adoption outside of their fiefdoms (google, fb, microsoft).

If you are interested in a typesafe universal js ( or isomorphic js, whatever we are calling it now ) proof of concept you can check out this project using scalajs and scala-js react.

http://ochrons.github.io/scalajs-spa-tutorial/index.html

It depends what you are doing. If you have 10 lines of JS then probably no need for an abstraction. However if you have 1000s of lines of client code, then using a purescript or similar can be very beneficial to maintainability and provability of the code.

But there is a learning curve and unlike Haskell where you just know have to know the language, you have to know both the JS quirks and the compiler's quirks too. It is a leaky abstraction. This is the problem I have with a lot of the compile-to-android frameworks vs. just putting with with Java.