Why you should learn Scala in 2021?
While going through the internet you can find many questions like: Is it still worth to learn Scala? Is Scala relevant in 2021? What is better than Scala? Java or Scala — comparison anyone? And many many more. You can find many Reddit answers or other blog posts explaining this, but in the article below I’d like to explain why you should start learning Scala from my point of view.
1. Soft transformation to functional programming
Scala supports two paradigms of programming: Object-Oriented approach and Functional programming. For those who are familiar with Java, Kotlin or any other OO programming language it will be really easy to start writing code in Scala in ‘a little bit like Java’ style. At the same time, you will be discovering more and more Scala’s features and its advantage with the FP approach. It’s much easier than Haskell or Lisp. In Scala, you are not meant to get everything right away before writing a single line. At some moment using stuff like monads, case classes or pattern matching will be an obvious choice.
2. Compatibility with Java
Scala ecosystem is constantly growing. The number of great libraries and frameworks is amazing. Scala also supports new technologies like Data Science or Blockchain with its amazing tools. Yet if you have your one favourite Java library you can easily adapt it to Scala’s environment because Scala is running on JVM. Same like Java.
3. Open&Growing Community
No matter if you are a self-learner, want to attend a Bootcamp or just looking for some bits of advice on the internet you’ll find huge and very willing to help Scala community. More and more companies (Twitter, New York Times) decide to use Scala within production because it works.
4. Concise Syntax
Scala has succinct syntax. Let me show you an example.
import java.util.Objects;
public class Product {
private String name;
private double price;
public Product(final String name, final double price) {
this.name = name;
this.price = price;
}
@Override
public int hashCode() {
int hash = 7;
hash = 23 * hash + Objects.hashCode(this.name) Objects.hashCode(this.price);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Product other = (Product) obj;
if (!Objects.equals(this.name, other.name)) {
return false;
}
if (Double.doubleToLongBits(this.price) != Double.doubleToLongBits(other.price)) {
return false;
}
return true;
}
@Override
public String toString() {
return "Product{" + "name=" + name + ", price=" + price + '}';
}
}
While in Scala:
case class Product(name: String, price: double)
Yes, that’s enough! And both examples work in the same way.
5. Market
We all are developers because we love it, we can spend dozens of hours per day and not get paid because coding is our passion, isn’t it? 😉 With things like learning a new language, learning new frameworks&libraries, learning new approach (FP), what you can all do by getting to know Scala, you will grow on the market. Your value will be bigger than people who only know one language or even two, but both OO. When you look at 2019 you’ll see Scala at #1 rank in salaries in the US. And the demand is growing.
6. Productivity
I’m sure that with Scala your productivity will grow. First of all, you can start immediately with some basic knowledge. The second thing is you can deliver much more code while writing less! It’s amazing. Having great tools to start with like IntelliJ (adding a Scala plugin is enough and it’s free) will make your work a pleasure.
Yet you have a few reasons above but you can find many articles similar to this. Why? Because people love Scala, really enjoy coding with it and want to engage more and more people. Just give it a try.
90-251 Łódź