Black lives matter
Portrait Dr. Axel Rauschmayer
Dr. Axel Rauschmayer
Homepage | Twitter
Cover of book “JavaScript for impatient programmers”
Book, exercises, quizzes
(free to read online)
Cover of book “Deep JavaScript”
Book (50% free online)
Cover of book “Tackling TypeScript”
Book (first part free online)
Logo of newsletter “ news”
Newsletter (free)

Writing JavaScript tools in other languages – a new trend?

[2020-10-07] dev, javascript, jstools
(Ad, please don’t block)

Recently, we have seen an uptick of JavaScript tools being written in languages other than JavaScript. This blog post lists a few examples and explains the appeal of not using JavaScript.


I asked on Twitter and these are a few of the examples that people mentioned:

Build tools and compilers:

Linters and code formatters:

Managing command line tools:

Why other languages?  

What are the benefits of using languages other than JavaScript (or languages that compile to JavaScript)?

  • They can be compiled to native binaries which have faster startup times.
  • Native binaries also usually run considerably faster than JavaScript code.
  • Many languages make it much easier to parallelize code.

Additionally, many non-JavaScript languages can now be compiled to WebAssembly, resulting in binaries that are almost as portable as JavaScript – and integrate well with it.

Given that each language has its own specialties, a non-JS language may also be better suited for a given task. For example, OCaml/ReasonML, Haskell, and other functional languages support algebraic data types, which help with processing data structures such as abstract syntax trees that are used when parsing and/or compiling formal languages.

Upsides of using JavaScript  

Using JavaScript also has benefits:

  • It’s easier to find contributors for tools: On one hand, programmers familiar with the non-JS language tend to be less interested in working on JavaScript-related tools. On the other hand, a non-JS language is a considerable hurdle for JavaScript programmers.

  • You can “dog-food” – apply a language tool to the code of the tool itself. As a consequence, working on the tool’s code base gives you a better idea of what you want from the tool.

  • JavaScript has a rich ecosystem with a language specification, much documentation, good tools and many libraries (via npm).

  • For functional programming, TypeScript is not as elegant as specialized languages, but you can get relatively close without losing the JavaScript ecosystem. For example, discriminated union types are slightly more verbose than algebraic data types, but have many of the same benefits (such as compile-time exhaustiveness checks).

If high performance is important, AssemblyScript may be an option: It is a strict variant of TypeScript that is compiled to WebAssembly.