Scala: All Your Questions Answered
If you want to be up to date with all Scala events, sign up for Scalendar, our Event Driven Newsletter.
Whether you’re a developer, a tech lead, or a business owner that needs to decide in which technical direction you need to be heading – in the IT industry, you’re really spoiled for choice. From which languages, libraries, and tech stacks are best for you to which cloud solutions and data storage solutions you should use, there are literally thousands of possibilities to choose from. In this post, we’ll be giving you all the reasons you should be choosing the Scala programming language, why Scala is worth considering, as well as how Scala can be used, and how newcomers can start programming in Scala. We’re sure you will find it valuable. So let’s dive right in!
What is Scala and Why Does it Matter?
Scala – short for Scalable Language – was invented by Martin Odersky and first appeared in 2004. The language is compiled into Java bytecode and executed using a Java virtual machine (JVM). A large range of companies now use Scala to build their software infrastructure, whether it’s consumer products or their own in-house tech stacks, and it has become one of the most popular multi-purpose programming languages in use today. Scala is particularly popular among businesses that rely on a distributed architecture that requires easily-scalable apps due to its conciseness, flexibility, and Java compatibility. One of the main reasons a lot of major companies, such as Duolingo, Zalando, Tubi, and more, have moved over to Scala is that the code has been designed to transition as fluidly as possible. Businesses often choose the Scala option if they want to change their existing software base but are worried about problems with functionality or speed.
Before looking at some examples, here are a few important things you should know about Scala:
- It’s a high-level language
- It’s statically typed
- Its syntax is expressive – concise but still readable
- It supports the object-oriented programming (OOP) paradigm
- It supports the functional programming (FP) paradigm
- It has a sophisticated type inference system
- Scala code has .class files that run on the Java Virtual Machine (JVM)
- Java libraries are easy to use in Scala
Thanks to its expressiveness and correctness, Scala is loved by developers. Check the results of our research here.
Why Scala is a functional programming language
Scala is a popular functional programming language – along with others such as Haskell and Erlang. Functional programming is based on mathematical functions, and these languages are specially designed to handle symbolic computation and list processing.
There are too many functional programming business benefits to list in full here, but suffice it to say that Scala is particularly useful if you have a lot of data or complex data structures and algorithms to deal with. FP languages like Scala are also often used for artificial intelligence applications such as machine learning, language processing, or modeling of speech and vision. All of which is pretty impressive, right?
Why companies use Scala – Scala use cases
Scala is particularly useful in business when it comes to scalability. Functional programming has less code and fewer dependencies, so different parts of your system and business can be developed independently. This is the only reasonable way to scale when it comes especially to dealing with complex systems In addition, it will also mean less code, fewer bugs, and code that is simply more open to parallel computation and concurrent programming.
Let’s take a look at some practical use cases of Scala in various industries and companies. We’ll begin with…
Data processing at scale with Scala
Tubi – one of the biggest companies in the world – benefits from Scala, particularly when it comes to strategies.
In order to provide the best possible experience to its customers, Tubi has to adjust their technology and solutions to ensure it can successfully leverage its huge amount of data.
Scala stepped up to the plate and was able to support the transformation within Tubi.
Startup technical debt paid off with Scala
Duolingo is an app where users can learn all kinds of different languages through the use of various types of exercises in short lessons.
The Session Generator is one of Duolingo’s core features, around since the very beginning. It is the module that decides which educational resources are suitable for each user. As we know, Duolingo has been rapidly gaining in popularity, resulting in massive growth over a very short time. For the startup, this has been both a blessing and a curse. Duolingo’s tech team has had to act quickly, not always with enough time and resources to optimize everything accordingly, leading to significant technical debt. That’s why they decided to turn to Scala.
Python is one of the most popular programming languages in the world, and Duolingo’s backend was originally written in this language.
Scala, however, unlike Python, is a statically-typed language. That means there are no issues with speed, one of the challenges that can come with Python, and that’s why the Duolingo team decided to change to Scala. Scala is widely used in other apps that have to deal with complex big data. One example is Kafka, an app developed by LinkedIn, used to handle real-time data feeds.
How Scala brought flexibility and stability to an E-Commerce giant
When Zalando was on its way to becoming the e-commerce giant it is today, there was a point when they decided to switch from Java to Scala. Despite the massive task and the huge effort it involved, they still did it in less than three months flat.
Switching to Scala helped Zalando boost stability by enabling their engineers to scale down the amount of code while still allowing them to use all the Java Virtual Machine goodies they had been used to using for years.
Scala combines both object-oriented (OOP) and functional programming, and this hybrid approach gives flexibility by allowing a choice between one or the other paradigm, depending on the situation.
One of the great advantages of functional programming is how easy it makes parallelization, but parallel programming is even smoother with Scala as it comes with a Futures API.
Read more: 7 Scala Success Stories
Read more: Distributed Systems in Scala
Looking to learn Scala?
Scala has been getting more and more popular, so now could be just the right time to get to know how you can go about learning this programming language. But even if you’re just curious about what Scala has to offer, here’s some info to get you started:
- Start off with ‘Programming in Scala,’ a book co-written by Martin Odersky, the original creator of the language. Make sure it’s the 4th edition, which covers Scala 2.13. This book is really worth a look, as it thoroughly explains all the features and how to write in Scala. Admittedly, it’s quite a long read, but you don’t need to get through it all in one go!
- Take a look at the ‘7 sins of a Scala beginner’ by our former colleague @kubukoz
- Once you’ve had a bit of practice writing in Scala and you know your way around the language a bit, the next step is to learn about Akka (worth learning the basics and some solutions it can bring to problems of concurrent programming) – take a look at the official documentation.
- Knowing something about persistence frameworks is necessary when it comes to real-time applications. For SQL, Slick and Doobie are two of the most popular. The official documentation we’ve linked to there is the best place to start to get to know them.
- These two books; ‘Functional Programming in Scala’ (the Red Book) and ‘Book of Monads’ – are both definitely worth a look if you want to teach yourself about the basics and general concepts of functional programming.
- The documentation for Cats, Scalaz, and ZIO are all good sources of information about these libraries, as well as ‘Functional Programming for Mortals’, which covers specifically the Scalaz library, and ‘Scala with Cats’, which covers – obviously – Cats
- There are several courses specializing in Scala on Coursera, but particularly worth a look is the ‘Functional Programming Principles in Scala’ course.
- But we could not go without mentioning our Scala training Scala beginners, Scala pros, Java to Scala, and ZIO.
- And finally, there’s a particularly useful list of blogs about functional programming and Scala here on Functional Works on Medium, not to mention, of course, Scalac’s vast Scala/ZIO section of the blog.
Getting to know Scala and all about functional programming? Then why not check out the resources we’ve listed below?
Information Regarding Scala
- Official Website
- Try Scala Online with
Scastie or ScalaFiddle
- Contribute to Scala
- Scala Center (not-for-profit scala org)
- StackOverflow Recent Questions
- Official Scala Gitter Channel
- Official Scala User Forum
- Official Scala Contributors Forum
- Unofficial Scala Discord
IDES / Programming Environments
- IntelliJ with Scala Plugin
- Ammonite Scripting, REPL, System shell
- Metals (VSCode, Sublime, etc.)
- ScalaIDE (Eclipse Plugin)
Code Formatting / Linting
Free Books, Tutorials, and Guides
- Scala Exercises
- Twitter’s Scala School
- Scala Tutorial
- Programming in Scala, First Edition
- Hands-on Scala.js
- Underscore.io books (many free books)
- 47Degrees Scala Exercises
- The Neophyte’s Guide to Scala
Free Scala Courses
- Functional Programming Principles in Scala
- Functional Program Design in Scala
- Parallel Programming
- Big Data Analysis with Scala and Spark
- Introduction to Programming with Dependent Types in Scala
Scala Training by Scalac.io
- Scala 3 for Scala Developers
- Functional Effects (ZIO)
- Scala 2 for Java Developers
- Scala 2 for Frontend Developers
- Typelevel Summits (Misc.)
- Scala by the Bay (USA)
- flatMap (Norway)
- Scala Up North (Canada)
- Scala Days (USA, Europe)
- Scala World (UK)
- Scala Swarm (Portugal)
- Scala.io (France)
- Scalar (Central Europe)
- Scala Sphere (Poland)
- nescala (USA)
- LX SCALA (South-West Europe)
- ScalaConf (Russia)
- Functional World
Web Development and Microservices
- Akka HTTP
- Sttp (HTTP Client)
- Udash – Frontend and Backend
- Sangria – GraphQL
Web Front End (Scala.js)
- Anorm (RDBMS)
- ScalikeJDBC (RDBMS)
- Doobie (RDBMS)
- Quill (RDBMS + Cassandra)
- Phantom (Cassandra)
- ReactiveMongo (MongoDB)
- Elastic4s (ElasticSearch)
- Slick (RDBMS)
Concurrency / Parallelism
Open Source Applications written in Scala
- Lichess (chess)
- Graphcool (GraphQL)
- Apache Kafka
- Crypto Coin Alerts
- Hepek – Static Site Generator
- Official Scala blog
- Scalendar, Event-Driven Newsletter
- David Barri aka /u/japgolly
- Scala Times (weekly news)