Need advice about which tool to choose?Ask the StackShare community!
Erlang vs Scala: What are the differences?
Introduction
In this article, we will compare and highlight the key differences between Erlang and Scala programming languages.
Concurrency Model: One of the significant differences between Erlang and Scala is their concurrency models. Erlang is built around the concept of lightweight processes, also known as actors, which communicate with each other by message passing. This model allows for scalable and fault-tolerant systems, making Erlang well-suited for building distributed and concurrent applications. On the other hand, Scala uses a combination of shared-memory concurrency and message passing. It provides constructs like Scala Futures and Akka actors to handle concurrency and parallelism.
Functional Programming: Both Erlang and Scala support functional programming, but they have different approaches. Erlang is a pure functional programming language that enforces immutability and encourages the use of pattern matching to handle computations. In contrast, Scala is a hybrid language that combines object-oriented and functional programming paradigms. It allows mutability and provides higher-order functions, lambda expressions, and other functional constructs, while still supporting object-oriented programming.
Scalability and Fault-tolerance: Erlang is known for its built-in support for scalability and fault-tolerance. The actor model and supervision trees in Erlang help in building robust and fault-tolerant systems. It allows for hot code swapping, which enables updates to be made to a running system without any downtime. Scala, on the other hand, relies on external libraries like Akka to provide similar features. While Scala does offer scalability and fault-tolerance, it requires additional configuration and setup compared to Erlang's native support.
Concurrency Granularity: Erlang focuses on fine-grained concurrency by using lightweight processes (actors) that can be created and destroyed quickly. These processes are isolated and have minimal overhead, making it feasible to have millions of them in a single Erlang system. Scala, on the other hand, has a coarser-grained concurrency model. While it provides lightweight threads (Futures) and actor-based concurrency with Akka, the number of concurrent entities in a Scala system is typically lower compared to Erlang.
Tooling and Ecosystem: Erlang's tooling and ecosystem are specifically geared towards building distributed and fault-tolerant systems. It has tools like OTP (Open Telecom Platform) for building reliable systems, along with frameworks like Elixir, which provides a more modern syntax and additional features on top of Erlang. Scala, being a more general-purpose language, has a wider range of tooling and libraries available. It has a vibrant ecosystem with popular frameworks like Play, Akka, and Spark, making it suitable for a variety of applications.
Community and Adoption: Erlang has been around since the 1980s and has been widely adopted by companies in the telecommunications, messaging, and networking domains. It has a strong community and a proven track record in production systems requiring high availability. Scala, although relatively newer, has gained popularity in the Java ecosystem due to its interoperability with existing Java codebases. It has a growing community and is widely used for web development, data processing, and scalable backend systems.
Summary
In summary, Erlang and Scala differ in their concurrency models, with Erlang relying on lightweight processes (actors) and Scala offering a combination of shared-memory concurrency and message passing. Erlang is a pure functional programming language, while Scala combines functional and object-oriented programming. Erlang has native support for scalability and fault-tolerance, whereas Scala requires external libraries. Erlang's concurrency granularity is fine-grained, allowing for millions of lightweight processes, while Scala's concurrency is typically coarser-grained. Erlang's tooling is tailored for building distributed and fault-tolerant systems, while Scala has a wider range of general-purpose tooling and libraries. Finally, Erlang has a strong community and adoption in telecom and networking domains, whereas Scala has gained popularity in the Java ecosystem.
Basically, I am looking for a good language that compiles to Java and JavaScript(and can use their libraries/frameworks). These JVM languages seem good to me, but I have no interest in Android. Which programming language is the best of these? I am looking for one with high money and something functional.
Edit: Kotlin was originally on this list but I removed it since I had no interest in Android
Clojure is a Lisp dialect, so if you like Lisp that's probably the way to go. Scala is more popular and broadly used, and has a larger job market especially for data engineering. Both are functional but Scala is more interoperable with Java libraries, probably a big factor in its popularity. I prefer Scala for a number of reasons, but in terms of jobs Scala is the clear leader.
Scala has more momentum. It is good for back-end programming. The popular big data framework Spark is written in Scala. Spark is a marketable skill.
If you need to program something very dynamic like old school A.I., Clojure is attractive. You would chose Scala if prefer a statically typed language, and Clojure if you prefer a dynamically typed language.
It's not clear exactly what you mean by "high money", you mean financial support to the language, money paid for a job, economic health of the market the language is positioned on?
In any case, it's very hard to give any advice here, since you'd need to provide details on the intended usage, what sector, kind of product/service, team size, potential customer type... Both languages are very general purpose and decently supported, each have its own pros and cons, both are functional as approach, and neither is really mainstream.
Finding the best server-side tool for building a personal information organizer that focuses on performance, simplicity, and scalability.
performance and scalability get a prototype going fast by keeping codebase simple find hosting that is affordable and scales well (Java/Scala-based ones might not be affordable)
I've picked Node.js here but honestly it's a toss up between that and Go around this. It really depends on your background and skillset around "get something going fast" for one of these languages. Based on not knowing that I've suggested Node because it can be easier to prototype quickly and built right is performant enough. The scaffolding provided around Node.js services (Koa, Restify, NestJS) means you can get up and running pretty easily. It's important to note that the tooling surrounding this is good also, such as tracing, metrics et al (important when you're building production ready services).
You'll get more scalability and perf from go, but balancing them out I would say that you'll get pretty far with a well built Node.JS service (our entire site with over 1.5k requests/m scales easily and holds it's own with 4 pods in production.
Without knowing the scale you are building for and the systems you are using around it it's hard to say for certain this is the right route.
We're moving from Java to Kotlin with our Microservice Stack (Spring Boot) because it is excellently supported by framework and tools and the learning curve is not very steep Kotlin is way more straightforward and convenient to use while providing less boilerplate and more strictness, which finally leads to better code, which is more readable, maintainable and less error-prone. We especially like Kotlin's (functional) data structures, which are, e.g. compared to Scala, easier to understand and don't require deep knowledge in functional programming.
I am working in the domain of big data and machine learning. I am helping companies with bringing their machine learning models to the production. In many projects there is a tendency to port Python, PySpark code to Scala and Scala Spark.
This yields to longer time to market and a lot of mistakes due to necessity to understand and re-write the code. Also many libraries/apis that data scientists/machine learning practitioners use are not available in jvm ecosystem.
Simply, refactoring (if necessary) and organising the code of the data scientists by following best practices of software development is less error prone and faster comparing to re-write in Scala.
Pipeline orchestration tools such as Luigi/Airflow is python native and fits well to this picture.
I have heard some arguments against Python such as, it is slow, or it is hard to maintain due to its dynamically typed language. However cost/benefit of time consumed porting python code to java/scala alone would be enough as a counter-argument. ML pipelines rarerly contains a lot of code (if that is not the case, such as complex domain and significant amount of code, then scala would be a better fit).
In terms of performance, I did not see any issues with Python. It is not the fastest runtime around but ML applications are rarely time-critical (majority of them is batch based).
I still prefer Scala for developing APIs and for applications where the domain contains complex logic.
We needed to incorporate Big Data Framework for data stream analysis, specifically Apache Spark / Apache Storm. The three options of languages were most suitable for the job - Python, Java, Scala.
The winner was Python for the top of the class, high-performance data analysis libraries (NumPy, Pandas) written in C, quick learning curve, quick prototyping allowance, and a great connection with other future tools for machine learning as Tensorflow.
The whole code was shorter & more readable which made it easier to develop and maintain.
Pros of Erlang
- Real time, distributed applications62
- Concurrency Support62
- Fault tolerance58
- Soft real-time36
- Open source32
- Message passing22
- Functional programming22
- Immutable data16
- Works as expected14
- Facebook chat uses it at backend6
- Practical5
- Knowledgeable community5
- Bullets included4
- WhatsApp uses it at backend1
Pros of Scala
- Static typing188
- Pattern-matching178
- Jvm175
- Scala is fun172
- Types138
- Concurrency95
- Actor library88
- Solve functional problems86
- Open source81
- Solve concurrency in a safer way80
- Functional44
- Fast24
- Generics23
- It makes me a better engineer18
- Syntactic sugar17
- Scalable13
- First-class functions10
- Type safety10
- Interactive REPL9
- Expressive8
- SBT7
- Case classes6
- Implicit parameters6
- Rapid and Safe Development using Functional Programming4
- JVM, OOP and Functional programming, and static typing4
- Object-oriented4
- Used by Twitter4
- Functional Proframming3
- Spark2
- Beautiful Code2
- Safety2
- Growing Community2
- DSL1
- Rich Static Types System and great Concurrency support1
- Naturally enforce high code quality1
- Akka Streams1
- Akka1
- Reactive Streams1
- Easy embedded DSLs1
- Mill build tool1
- Freedom to choose the right tools for a job0
Sign up to add or upvote prosMake informed product decisions
Cons of Erlang
- Languange is not popular demand1
Cons of Scala
- Slow compilation time11
- Multiple ropes and styles to hang your self7
- Too few developers available6
- Complicated subtyping4
- My coworkers using scala are racist against other stuff2