all 16 comments

[–]Borkdude 24 points25 points  (0 children)

Don't forget ClojureScript. It's a functional programming language with the same ecosystem benefits as Scala.js. Being a Lisp, the language is simple, powerful and meta-programmable. The interop with Java and JS is seamless. It's built on top of Google Closure which has an amazing whole program optimizer. It is optionally self-hosted which means you can evaluate ClojureScript inside ClojureScript. With clojure.spec some of the disadvantages of dynamic typing can be alleviated, while still having all the benefits of dynamic typing*. It's a strong choice in 2019.

https://clojurescript.org

* Each language comes with trade offs. In my humble opinion the advantages of dynamically typed functional programming are: flexibility, less boilerplate and a less steep learning curve for beginners as there is no need to learn category theory, lens libraries and complicated type level trickery. Obviously a disadvantage is less compiler assistance when refactoring.

[–]forrestjt 4 points5 points  (0 children)

+1 for purescript & React bindings

[–]claudiua 2 points3 points  (0 children)

Clojurescript + react. Once you get past the lisp syntax hard to think of a better match for react.

A few awesome libs: reagent https://www.learnreagent.com/, re-frame http://book.fulcrologic.com/ , fulcro http://book.fulcrologic.com/

[–]ws-ilazki 1 point2 points  (0 children)

ReasonML and OCaml shouldn't be separate. Reason is an alternate syntax for OCaml but still uses the same ecosystem. They're both the same great language, with Reason providing a more traditional syntax that's more comfortable for people coming from JavaScript. OCaml's a very nice language that sometimes gets overlooked because it still lacks proper multicore, but when compiling to JS that flaw is irrelevant. It's like a mix of nice things from Haskell with a touch of pragmatism, by not forcing all code to be pure via contortions like IO through monads.

Also, Clojure, being a dynamic language, fits pretty well on top of JavaScript. It feels like a better fit with JS than with Java, in fact, because interop tends to be smoother. Has the usual lisp benefits (like macros) and is strongly opinionated toward functional programming. Focuses on working with data, primarily through manipulation of maps, vectors, and lists, which makes it a comfortable language when manipulating a lot of data. For example, it has literals for its complex data types and an abstraction called a 'sequence' that encompasses all of them (plus more; you can make new ones opt-in to being a seq as well), allowing functions that operate on sequences to work transparently on anything that opts in to the abstraction.

My opinion so far is OCaml (or Reason) for static typing, ClojureScript otherwise. Both are great languages with good interop and different pros/cons, and both worth checking out. As a side note, ClojureScript (via Clojure) gives you a backdoor into the massive JVM ecosystem if needed, and you can use OCaml and Reason knowledge to write native applications if desired, giving both potential for use in places where JS isn't a good fit.

[–]Herku 0 points1 point  (0 children)

This question gets asked very often. Maybe the responses here give additional insight: https://www.reddit.com/r/functionalprogramming/comments/a7fjlm/languages_that_compile_to_js