25

Monday 07 – JavaScript Alternatives!

 5 years ago
source link: https://www.tuicool.com/articles/hit/EJFJzyJ
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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!

QJN7N32.png!web2aEbuej.png!web

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!

R3Mryu3.png!webbQR7Bji.png!web
mUJjeu7.png!webUZ7zMnm.png!web

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!

77JJNnR.png!webBr63mqM.png!web
2EvAbmy.png!webNnMFN3I.png!web

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.

me63maF.png!web
iEvYN3E.png!webBzQ32av.png!web

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!

YjqQVbr.png!webAfyuayB.png!web
V7zUNzn.png!webQzEVrmE.png!web

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!

jM7fMbN.png!web
UnqU7jZ.png!webnuumMrr.png!web

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.

ReasonMLhas 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!

V7JNnmQ.png!web
32qEnuy.png!webaMFFFvy.png!web

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” !

3qMVjq7.png!webzI3Mz2y.png!web
Mb22iqY.png!webU7buIbY.png!web

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!

eyIRNzu.png!webFbUriyR.png!web
Uvimqua.png!web2UfmAff.png!web

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!

i6jMjmM.png!webYJfuUzB.png!web
IfU3uaI.png!webB3UvimA.png!web

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!

yErmIf3.png!webQ3yMzyE.png!web
3iMfyye.png!webjM32Ijj.png!web

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++!

Mzy6bib.png!webQZ7fy2N.png!web
FF3eEjA.png!webauIRZn3.png!web

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!

M3yiAbj.png!web
jMVRfaI.png!webbyaiQfV.png!web

LiveScript

LiveScript is an amazing programming language that compiles to JavaScript. It has been created by Jeremy Ashkenas , the creator of CoffeeScript .

LiveScriptis 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!

q63qmeE.png!web

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!

See you next week with a new episode of Js Monday!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK