Scala: All Your Questions Answered

Introduction

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, 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 to 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 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 because the code has been designed to transition as fluidly as possible. Businesses often choose the Scala option if they are looking 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.

Read more: Is Scala Right for You? Overview, Benefits & Case Studies

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.

Every function in Scala is a value. That may sound a tad weird or even crazy, but it is a programming style or paradigm which means Scala can support a whole new world of functional programming. But Scala isn’t just a language that offers support for functional programming, such as JavaScript or Python. Scala’s implementations of functional programming abstractions are some of the most extensive and ambitious among modern programming languages. 

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?

Read more: What is functional programming and why it matters for your business?

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 make sure it can successfully leverage its huge amount of data.  

Scala stepped up to the plate and was able to support the transformation within Tubi. 

Read the Full Case Study

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.

Read Full Case Study

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 the Full Case Study

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:

  1. 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!
  1. Get to know testing frameworks (ScalaTest, ScalaCheck, or perhaps  ZIO Test) and SBT basics.
  1. Take a look at the ‘7 sins of a Scala beginner by our former colleague @kubukoz 
  1. 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.
  1. 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.
  1.  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.
  1. 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
  1. There are several courses specializing in Scala on Coursera, but particularly worth a look is the ‘Functional Programming Principles in Scala’ course.
  2. But we could not go without mentioning our Scala training Scala beginners, Scala pros, Java to Scala, and ZIO. 
  3. 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.

Scala Resources

Getting to know Scala and all about functional programming? Then why not check out the resources we’ve listed below? 

Information Regarding Scala

Platforms

Community

Coding Tools

IDES / Programming Environments

Build Tools

Code Formatting / Linting

Free Books, Tutorials, and Guides

Non-free Books

Free Scala Courses

Scala Training by Scalac.io 

Scala Conferences

Podcasts

Scala Jobs

Scala Libraries

Web Development and Microservices

Web Front End (Scala.js)

Database Access

Functional Programming

Concurrency / Parallelism

Mathematics

Distributed Computing

Blockchain

Open Source Applications written in Scala

Communities

Blogs/Periodicals:

See also

Scala isn’t Hard: How to Master Scala Step by Step

Authors

Daria Karasek

Marketing Hero at Scalac. I strongly believe in creating opportunities rather than waiting for them to come. As befits Scalac team member I'm a hard worker, I always try to do the right thing and have a lot of fun! I'm an awesome friend and content writer, in that order. When I'm out of the office, I love to cook delicious Italian food and play board games with my friends. #boardgamegeek

Latest Blogposts

18.10.2021 / By Agata Nowak

Looking at a piece of the Functional World

Functional World is an internal event that Scalac created to exist as a place for the programming community and functional freaks who will communicate with people from all over the world. Functional World comes to the rescue in times of a pandemic –  the online conference formula is streamed on Twitch and YouTube. The first […]

14.10.2021 / By Agata Nowak

Meet Scalac At Web Summit 2021 in Lisbon!

This fall, prepare to meet Scalac at the best and largest annual technology conference worldwide – Web Summit 2021.  The organization is prestigious and professional on its own. Usually, this event doesn’t need much introduction. It’s practically everything startups wish to get involved with – an event that will let you grow your business, make […]

11.10.2021 / By Agata Nowak

In the center of Scalar

Scalar is one of the largest conferences in Central Europe. It started its activities in 2014. The Scalar community focuses on supporting people interested in the Scala programming language. It allows them to develop their programming skills, learning Scala, and delve into more and more theories with practical use. From 2014 to 2019, the conference was […]

Need a successful project?

Estimate project