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.
Ranked in these QuestionsQuestion Ranking
Pro Huge language supports most everything
C++ is a large language with an even larger community and following. It has libraries for every kind of task that is possible to do with C++
Pro Powerful memory management
Allows puting large arrays on the "heap" to avoid "stack overflow".
Pro Teaches fundamental OOP
Teaches you to leverage object oriented programming.
Pro Excellent compiler optimization
Both open source compilers (such as Clang and GCC), and proprietary ones (like Intel's and Microsoft's) are very good at analyzing program flow and program optimization. This is mostly due to the widespread usage of C/C++ applications running everything from mobile/desktop/server Operating Systems, to search engines and webserver software, and the demand for performance.
Pro Teaches problem solving
The great STL is the most powerful Data Structure and Algorithms Library. It would benefit you very much in problem solving, your main main way to love programming. The code is much compact compared to Java and C#. No unnecessary classes are in your way; yet when you need classes they are available unlike C. The code runs very fast.
Pro Best way to understand algorithms
Pro C code can be used in C++ code
Most C code will work as C++
Pro STD is often updated
The functionalities keep growing throughout the years. C++11 gave us a soft type of garbage collecting with the smart pointers.
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.
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 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 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 Dead-code elimination
Scala.js performs dead-code elimination out of the box (when running in the "fullOpts" mode).
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.
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.
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.).
Con Huge language gets in the way of learning
C++ is such an atrociously over-complicated language that its learning curve may get in the way of learning fundamentals. Learning C++ well is a ten-year project, and even experts are frequently surprised by the language.
Con Module system is not great
C++ uses the
#include mechanism provided by C. Which unfortunately is a poor way of accessing the API of a library. Some of the reasons why the module system is weak are:
Compile time scalability: The compiler must preprocess every header included in a file, and every header included in those headers. This process must be repeated for every translation unit in the program. As can be imagined, this doesn't scale very well. For each header added you are increasing the compilation time exponentially.
Fragile: modules included are treated as textual imports by the compiler. This causes all sorts of problems since they are subject to any macro definitions in the time of the inclusion. If any of these macro definitions collide with a name in the library it can break the library API .
Con Undefined behavior
Subtle errors can render the entire program "undefined" by the complicated C++ standard. The standard imposes no requirements in such cases. Thus C++ compiler writers are free to ignore the existence of such cases and Bad Things are prone to happen instead. Even experts can't reliably avoid undefined cases in C++, so how can beginners be expected to do so?
Con No two programmers can agree on which 10% subset of C++ to use
C++ is such a huge and complicated language, that programmers have to learn a disciplined subset of it to reliably get anything done. The problem is, no-one can agree on which subset to use and they can't understand each other.
Con Retains nearly all bad habits of C
Con Complicated types
Con Bugs easily corrupt the memory you need to find them
You can usually get a core dump, but often the call stack gets completely overwritten. Compilers are not even consistent in how they map the binary objects to code.
Con No reflection
C++ objects are frustratingly opaque. This makes debugging especially difficult, something beginners have to do a lot.
Con Tough to learn as the first language
Many of the concepts are hard to grasp if you have no prior programming experience.
Con Painfully slow compilation
Beginners need fast feedback
Con Standard library missing important features
Con Arcane binding rules
Con No way to locate definitions
No modules, just files, and no way to tell where anything came from.
Con Exceptions incompatible with C++ manual memory management
Con Incomprehensible operator overloading resoution
Con Duplicates C features in incompatible ways
Arrays, strings, pointers, etc. have both C and C++ versions. Sometimes the C++ versions are worse. This is more useless trivia beginners have to sort through.
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