Is there a language which transpiles to JavaScript (like TypeScript, CoffeScript etc.) and is almost purely functional (like Haskell, Erlang, F#)?
I know there are libraries which helps maintain immutability (Underscore), and there are a lot of cool array functions and lambdas in ES6. But what I'm looking for is a functional like syntax and transpiler for it, so I can write functional JavaScript with not much effort.
Check out Scala.js, Elm or PureScript.
Other languages include ClojureScript (Clojure) and Funscript (F#)
Of those, I've only really used Scala.js and Elm, both of which work extremely well in my opinion.
In Elm and PureScript functions are curried by default. In Scala Currying can be done very easily by using multiple parameter lists:
def curried(param1: Int)(param2: Int): Int = ...
If you like F# you might like OCaml via js_of_ocaml (better OCaml compatibility) or BuckleScript (better JS interop) or even Reason ML (more modern syntax, including JSX).
If you like Haskell better, you could use GHCJS (it's Haskell, targeting JS), Purescript (strict evaluation means simpler JS), or Elm (who needs type classes anyway).
I'm less sure about Erlang. There seem to have been some attempts (possibly somewhat successful) at targeting JS, but I'm not at all familiar with any of them.
If you are looking to stay at the .NET platform, and would want to use F# as your language to transpile to JavaScript, then I recommend looking at the following:
1.) Fable - Fable brings together the power of the F# compiler and Babel to make JavaScript a true backend for F#. It works directly on F# source code, no compilation needed.
2.) WebSharper - A fundamentally different web framework for developing functional and reactive .NET applications
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With