When comparing Elm vs Scala.js, the Slant community recommends Elm for most people. In the question“What are the best languages that compile to JavaScript? ”Elm is ranked 1st while Scala.js is ranked 10th. The most important reason people chose Elm is:

Lack of run-time exceptions makes it easy to produce large swathes of reliable front-end code without drowning in tests.

Pros

Pro

No run-time exceptions

Lack of run-time exceptions makes it easy to produce large swathes of reliable front-end code without drowning in tests.

Pro

Inferred static typing

ML static typing is great because it's always there, you just choose how explicit you want to be and how much you want the compiler to do.

Pro

Designed around high-level front-end development

As Elm was designed as a front-end langauge, it has out of the box support for things like DOM-element creation, letting programmers focus on their application logic, rather than implementation details specific to the web.

Pro

Great and simple way to learn Purely Functional Programming

You can try to apply some functional programming ideas in other languages that have an imperative basis, but you haven't seen the real power unless you tried it in the environment of purely functional programming. Elm is a simple language with great learning resources and easy graphical output, which makes it easy to explore the power of functional programming. Plus programming in Elm is very readable.

Pro

Growing community

Pro

Good documentation

Elm is gaining popularity, somewhat faster than many of the other solutions here. This translates to more code examples, more documentation, and more libraries.

Pro

Super easy refactoring with very helpful compiler errors

In no other language you can refactor so easy without any worries, since the compiler will guide you through. It is like TDD but than compiler-error driven.

Pro

High-level Functional-Reactive Code

Build animations, games, and interactions with an incredibly small amount of terse, readable code.

Pro

Good tooling

All major editors have great support. With Atom for example, Elm plugins are available for linting, formatting, make/compiler support and Elmjutsu will simply overflow you with super useful functions, like navigate to referenced definition and show expression type.

Pro

Missing Syntactic sugar

Easy to learn, most functions have only one way, not 5 alternatives where you must study where to best use what.

Pro

Interactive Programming and Hot Swapping

Support for hot swapping and interactive programming is included.

Pro

Not quite Haskell semantics

Luckily you do not have to learn Haskell to be able to do any Elm. It is meant to be a language that compiles to Javascript, so for Javascript programmers (Front end) not for CS students who want to learn as many different algorithms as possible.

Pro

Batteries included

The Elm Architecture means you don't need to spend valuable time and effort choosing the right frameworks, state management libraries, or build tooling. It's all built in.

Pro

Type inference

Scala offers type inference, which, while giving the same safety as Java's type system, allows programmers to focus on the code itself, rather than on updating type annotations.

Pro

Implements a mature language

In contrast to other options, Scala.js is a compiler plugin for an already existing and mature language: Scala.As such, it benefits automatically from the existing compiler, from the language design choices made for Scala, which exists and is established in the industry since years.

Pro

Immutable values

The immutable values make it perfect for working with concurrency.

Pro

Easy, type-safe, interop with JavaScript

The JavaScript-interop of Scala.js is very direct and lightweight.

Pro

The strength of Scala on the server

The strength of Scala (JVM) on the server can not be underestimated, and is probably superior to any other choice listed here (where applicable; many have no server-side equivalent).

Being able to use such a powerful language (and ecosystem) on the server AND on the client, and sharing code between the two, is a big advantage.

Pro

Extensive standard libraries

Scala.js implements most of the Scala standard library and many parts of the Java one. Among others, it supports Scala's rich collection library.

Pro

Macros

Because Scala.js is a plugin to the Scala compiler, the whole power of the Scala language is available at compile-time. Which includes macros. Very expressive things can be done, in a type-safe way, which are difficult or impossible in other languages.

Pro

Dead-code elimination

Scala.js performs dead-code elimination out of the box (when running in the "fullOpts" mode).

Pro

Multiparadigm

Scala supports both Functional and Object Oriented styles of programming. Beginners can learn both paradigms without having to learn a new language, and experts can switch between the two according to what best suits their needs at the time.

Pro

Crossbuilding

Keeps your client and server sources in sync.

Pro

Incremental compilation

Through SBT, Scala.js supports incremental compilation out of the box. That is: SBT automatically picks-up the changes (think "watch" in other tools) and only recompiles what is needed.

This makes the development cycle fast and very pleasant to work with.

Pro

Excellent tooling (IDE) support

The same good and mature tooling that can be used for Scala can be used for Scala.js out of the box (code-completion, refactoring, immediate feedback, etc.).

Pro

Simple build system compared to Javascript

While SBT is arguably not as simple as Maven, it beats the chaos of the JavaScript build ecosystem.

Ad

Cons

Con

Lack of typeclasses

Elm doesn't have typeclasses which means some code needs to be duplicated. A fix in a function that needs typeclasses means all of the duplicates need to be fixed too.

Con

Poor Windows support

Few if any of Elm's core contributors are Windows users and breaking bugs are sometimes left for weeks or months.

Con

Not database-friendly

It is lots of work to make a server or database your "one source of truth", as Elm makes you write endless JSON parse boilerplate to talk to the server.

Con

Adds an additional layer of abstraction

Some users claim that Elm adds an additional layer of abstraction, meaning that it is one more hurdle between the brain and the product.

Con

Can be intimidating for beginners

Scala is an industrial language. It brings functional programming to the JVM. All books/tutorials cover friendly aspects of Scala, but there are corners of the language that one can wander into that are not friendly to beginners.

Con

A complex language with a lot of incidental complexity that results in significant mental overhead

Con

Combines OOP and functional programming for a hodge-podge paradigm

Its excellent mix of functional and OOP programming just like Python to use the tool best suited

Alternative Products

Each month, over 2.8 million people use Slant to find the best products and share their knowledge. Pick the tags you’re passionate about to get a personalized feed and begin contributing your knowledge.