typescipt, clojurescript, flow, scalajs, haskell and other type-oriented javascript transpilers

It is well known that it can be difficult to develop javascript applications due to the lack of a static typechecking transpilation stage. While it is a strength that javascript is typeless, many types of programming tasks and applications greatly benefits from typechecking. There are good reasons to completely ignore static type checking, such as in most javascript programs or clojurescript programs. However, even common lisp has static (and dynamic) type checking (it's not well known that the compiler can type check).

Typescript, adopted and promoted by the google angular team, has become very popular especially in the past few months. Its been organically growing for many years and its a good example of Microsoft contributing to the open source community. Typescript is a light layer on top of javascript that allows you to typecheck your programs. Perhaps some of the features in typescript will be moved into the javascript standard, perhaps not. Flow, facebook's typechecker, is similar.

The issue with all statically typed languages written on javascript is not so much the application you are developing, but the bindings to the large, and growing larger, ecosystem of javascript libraries.

Typescript has an entire site dedicated to typescript modules for common libraries (github typescript umbrella project). The same issue applies to scalajs, a scala implementation running on javascript. A recent project provides comprehensive bindings for the standard nodejs library: (github scalajs nodejs comprehensive bindings). scalajs has a compiler that translates typescript bindings to scalajs bindings and is a great starter (github typescript to scalajs bindings converter). "Definitely scala" has used it to auto generate many scalajs bindings similar to the collection of typescript bindings (here).

These bindings are really the difficult part of using a typechecked javascript. scalajs has a nice bundlor that uses webpack and npm to grab any npm library you need. It's easy! But, you have to find those bindings. Over time, this should be less of an issue, but the bindings do have to be updated as a library's javascript API evolves---and tracking changes is not a strong suit for many open source projects. It does make me wish for some features in common lisp where you could incrementally add type information to your programs.

I tend to think that the bindings are key parts of driving adoption. That's why the scalajs nodejs bindings could be a game changer as nodejs becomes, arguably, the third major platform architecture like the JVM and .NET.


Comments

Popular posts from this blog

quick note on scala.js, react hooks, monix, auth

zio environment and modules pattern: zio, scala.js, react, query management

user experience, scala.js, cats-effect, IO