In 2019, we have two options for running scripts in a Web Browser: JavaScript and WebAssembly.
But imagine a programmer coming from Java, Haskell or even LISP… where is the pure Object Oriented paradigm? And where is the Functional one? And what about the famous LISP syntax?
Of course, JavaScript provides both Object Oriented and Functional paradigms, but when it comes to syntax, some developers just have preferences. Static typing, pattern matching, interfaces… JavaScript does not fit everyone’s needs (yet!).

As we said before, in 2019 we only got two alternatives for running scripts on a Web Browser. But wait… we can target JavaScript while compiling other languages!

Preface

We’re not gonna talk about the history of every language which compiles to JavaScript. JS is such an important language that pretty every other programming language can compile to it.
Instead, we’re gonna see some real life or life-changing programming languages that you can use right now in production, or that you should keep an eye on for its future evolutions.

So, let’s begin!

Kotlin

Kotlin

Kotlin is a young and powerful programming language which targets both the Java Virtual Machine and JavaScript natively.
The greatest thing about Kotlin, is that you’ll have access to all the great and battle tested Java libraries out there!
If you are a Java developer, you should absolutely take a look at it!

fun main(args: Array<String>) {
  println("Hello world from Kotlin!)
}

Scala

Scala

Yet another awesome JVM language, born in 2003 in Geneva.
It takes the good parts of both Object Oriented and Functional programming paradigms and targets both Java bytecode and JavaScript natively!
Like Kotlin, you’ll have access to every Java library, but you’ll also be able to express complex algorithms taking the advantages of a functional programming language!

object HelloWorld extends App {
  println("Hello world from Scala!")
}

Clojure

Clojure

Ok, the last JVM language we’ll talk about.
Clojure is an amazing LISP programming language which compile Java bytecode.
It can compile to JavaScript using ClojureScript!
If you’re coming from Common Lisp, Racket, Scheme or any other LISP programming language, that’s definitely the solution for you.

(ns hello-world.core)
(println "Hello world from ClojureScript!")

TypeScript

TypeScript

TypeScript doesn’t need any kind of presentation. It’s by far the most widely used compile-to-JavaScript language out there.
It adds type signature and other great features to JavaScript.
It can also be compiled to WebAssembly using **WebAssemblyScript**!
Just to let you know how widely used is, keep in mind that Angular.js, **Vue.js (v3), Rx.js, Firebase SDK **and VSCode are written in TypeScript!
You should definitely take a look at it!

const greet: string = "Hello world from TypeScript!";
console.log(greet);

OCaml

OCaml

**Objective Caml (OCaml) is a rock solid implementation of the Caml programming language, coming from the ML family.
It’s known to be an incredible fast programming language (some benchmarks says as fast as C).
It’s intensively used at Facebook these days (just think about Flow, which is written in OCaml) and it’s famous as strong and battle tested programming language.
It can be compiled to JavaScript using **BuckleScript
, a compiler which translates OCaml code to JavaScript!

print_string "Hello world from OCaml!";;

ReasonML

ReasonML

If OCaml is too much for you, here you are ReasonML!
It’s just a new syntax for the OCaml programming language, which takes inspiration from JavaScript.
ReasonML has been developed by a Facebook engineer which is also the same guy who invented React.js!
In fact, at first React.js was designed to be written in StandardML (an ML programming language), so you can imagine how close these two projects are!
ReasonML uses BuckleScript under the hood to transpile ReasonML code to OCaml, then to JavaScript. The future of both web and native development seems to pass from here!

print_string("Hello world from ReasonML!");

F#

F#

F# is an amazing programming language coming from the ML family, which compiles** Microsoft .NET** bytecode.
The greatest advantage of F#, is that you can have access to every .NET library, from C# to VB! Isn’t that amazing?
You can compile F# code to JavaScript using **Fable**, “the compiler that emits JavaScript you can be proud of”!

open System

[<EntryPoint]
let main argv =
  printfn "Hello world from F#!"
  0

Elm

Elm

Elm is a popular programming language highly inspired from Haskell.
It has been specifically designed for building high performance web apps and highly optimized JavaScript code.
It also promise to avoid any kind of runtime exception thanks to an awesome strong type system (highly inspired from Haskell).
Did you know? Redux has been inspired from the Elm Architecture, which is extremely great for reactive web apps!

module HelloWorld exposing(..)
import Html exposing (text)

main =
  text "Hello world from Elm!"

PureScript

PureScript

PureScript is a **strong typed **and pure functional programming language highly inspired from Haskell.
In PureScript, you can reuse any existing JavaScript library, so you don’t have to reinvent the wheel everytime!
If you’re coming from a functional programming experience, PureScript is an awesome way to build rock solid and exception-free web applications!

import Prelude
import Effect.Console (log)

greet :: String -> String
greet name = "Hello, " <> name <> " from PureScript!"

main = log (greet "world")

Dart

Dart

Dart is an Objet Oriented programming language developed by Google which aims to be the greatest JavaScript alternative for web and native development.
Google has recently released Flutter for native app development, which is written in Dart.
If you’re coming from Java, you’ll find it comfortable to write in Dart!

main() {
  print('Hello world from Dart!');
}

C/C++

C/C++

Ok that’s actually incredible: you can convert your existing C/C++ code into JavaScript using **Emscripten!
Of course, you will never reach C/C++ performances with JavaScript, but there are certain projects which would be really hard to be reimplemented from zero. **Tesseract.js
is an awesome example of the C++ Tesseract OCR project! I personally used it and you won’t figure out that the source code has been compiled from C++!

#include <stdio.h>

int main()
{
  printf("Hello world from C!");
  return 0;
}

Clio

Clio

Clio is a pure functional lazy-evaluated programming language targeting decentralized and distributed systems.
It compiles high quality JavaScript code which can be executed both on a browser and a server (using Node.js).
While **Clio** is still under active development, introduces some great and innovative ideas. I would totally bet on this project!

'Hello world from Clio!' -> print 

LiveScript

LiveScript

LiveScript is an amazing programming language that compiles to JavaScript. It has been created by Jeremy Ashkenas, the creator of CoffeeScript.
LiveScript is actually a CoffeeScript evolution which embraces both the Functional and the Object Oriented programming paradigms.
If you are coming from a functional language like Elixir or OCaml, you’ll find it an awesome solution for writing high quality JavaScript apps!

"Hello world from LiveScript!" |> console.log

Conclusion

Today we’ve seen 13 languages that compiles to JavaScript.
It’s clear that development happiness is a major focus point for developers these days, but it’s also clear that JavaScript is an incredibly important language, and community is constantly working on improving its ecosystem.
JavaScript future is brighter than ever!

Did you like this article? Consider becoming a Patron!

This article is CC0 1.0 (Public Domain) licensed.