Scala runs on...

  • JVM
  • JavaScript in your browser
  • Natively with LLVM beta

Scala in a Nutshell

click the boxes below to see Scala in action!

Seamless Java Interop

Scala runs on the JVM, so Java and Scala stacks can be freely mixed for totally seamless integration.

Type Inference

So the type system doesn’t feel so static. Don’t work for the type system. Let the type system work for you!

Concurrency & Distribution

Use data-parallel operations on collections, use actors for concurrency and distribution, or futures for asynchronous programming.

Author.scala
class Author(val firstName: String,
    val lastName: String) extends Comparable[Author] {

  override def compareTo(that: Author) = {
    val lastNameComp = this.lastName compareTo that.lastName
    if (lastNameComp != 0) lastNameComp
    else this.firstName compareTo that.firstName
  }
}

object Author {
  def loadAuthorsFromFile(file: java.io.File): List[Author] = ???
}
App.java
import static scala.collection.JavaConversions.asJavaCollection;

public class App {
    public List<Author> loadAuthorsFromFile(File file) {
        return new ArrayList<Author>(asJavaCollection(
            Author.loadAuthorsFromFile(file)));
    }

    public void sortAuthors(List<Author> authors) {
        Collections.sort(authors);
    }

    public void displaySortedAuthors(File file) {
        List<Author> authors = loadAuthorsFromFile(file);
        sortAuthors(authors);
        for (Author author : authors) {
            System.out.println(
                author.lastName() + ", " + author.firstName());
        }
    }
}

Combine Scala and Java seamlessly

Scala classes are ultimately JVM classes. You can create Java objects, call their methods and inherit from Java classes transparently from Scala. Similarly, Java code can reference Scala classes and objects.


In this example, the Scala class Author implements the Java interface Comparable<T> and works with Java Files. The Java code uses a method from the companion object Author, and accesses fields of the Author class. It also uses JavaConversions to convert between Scala collections and Java collections.

Type inference
scala> class Person(val name: String, val age: Int) {
     |   override def toString = s"$name ($age)"
     | }
defined class Person

scala> def underagePeopleNames(persons: List[Person]) = {
     |   for (person <- persons; if person.age < 18)
     |     yield person.name
     | }
underagePeopleNames: (persons: List[Person])List[String]

scala> def createRandomPeople() = {
     |   val names = List("Alice", "Bob", "Carol",
     |       "Dave", "Eve", "Frank")
     |   for (name <- names) yield {
     |     val age = (Random.nextGaussian()*8 + 20).toInt
     |     new Person(name, age)
     |   }
     | }
createRandomPeople: ()List[Person]

scala> val people = createRandomPeople()
people: List[Person] = List(Alice (16), Bob (16), Carol (19), Dave (18), Eve (26), Frank (11))

scala> underagePeopleNames(people)
res1: List[String] = List(Alice, Bob, Frank)

Let the compiler figure out the types for you

The Scala compiler is smart about static types. Most of the time, you need not tell it the types of your variables. Instead, its powerful type inference will figure them out for you.

In this interactive REPL session (Read-Eval-Print-Loop), we define a class and two functions. You can observe that the compiler infers the result types of the functions automatically, as well as all the intermediate values.

Concurrent/Distributed
val x = Future { someExpensiveComputation() }
val y = Future { someOtherExpensiveComputation() }
val z = for (a <- x; b <- y) yield a*b
for (c <- z) println("Result: " + c)
println("Meanwhile, the main thread goes on!")

Go Concurrent or Distributed with Futures & Promises

In Scala, futures and promises can be used to process data asynchronously, making it easier to parallelize or even distribute your application.

In this example, the Future{} construct evaluates its argument asynchronously, and returns a handle to the asynchronous result as a Future[Int]. For-comprehensions can be used to register new callbacks (to post new things to do) when the future is completed, i.e., when the computation is finished. And since all this is executed asynchronously, without blocking, the main program thread can continue doing other work in the meantime.

Traits

Combine the flexibility of Java-style interfaces with the power of classes. Think principled multiple-inheritance.

Pattern Matching

Think “switch” on steroids. Match against class hierarchies, sequences, and more.

Higher-order functions

Functions are first-class objects. Compose them with guaranteed type safety. Use them anywhere, pass them to anything.

Traits
abstract class Spacecraft {
  def engage(): Unit
}
trait CommandoBridge extends Spacecraft {
  def engage(): Unit = {
    for (_ <- 1 to 3)
      speedUp()
  }
  def speedUp(): Unit
}
trait PulseEngine extends Spacecraft {
  val maxPulse: Int
  var currentPulse: Int = 0
  def speedUp(): Unit = {
    if (currentPulse < maxPulse)
      currentPulse += 1
  }
}
class StarCruiser extends Spacecraft
                     with CommandoBridge
                     with PulseEngine {
  val maxPulse = 200
}

Flexibly Combine Interface & Behavior

In Scala, multiple traits can be mixed into a class to combine their interface and their behavior.

Here, a StarCruiser is a Spacecraft with a CommandoBridge that knows how to engage the ship (provided a means to speed up) and a PulseEngine that specifies how to speed up.

Switch on the structure of your data

In Scala, case classes are used to represent structural data types. They implicitly equip the class with meaningful toString, equals and hashCode methods, as well as the ability to be deconstructed with pattern matching.


In this example, we define a small set of case classes that represent binary trees of integers (the generic version is omitted for simplicity here). In inOrder, the match construct chooses the right branch, depending on the type of t, and at the same time deconstructs the arguments of a Node.

Pattern matching
// Define a set of case classes for representing binary trees.
sealed abstract class Tree
case class Node(elem: Int, left: Tree, right: Tree) extends Tree
case object Leaf extends Tree

// Return the in-order traversal sequence of a given tree.
def inOrder(t: Tree): List[Int] = t match {
  case Node(e, l, r) => inOrder(l) ::: List(e) ::: inOrder(r)
  case Leaf          => List()
}

Go Functional with Higher-Order Functions

In Scala, functions are values, and can be defined as anonymous functions with a concise syntax.

Scala
val people: Array[Person]

// Partition `people` into two arrays `minors` and `adults`.
// Use the anonymous function `(_.age < 18)` as a predicate for partitioning.
val (minors, adults) = people partition (_.age < 18)
Java
List<Person> people;

List<Person> minors = new ArrayList<Person>(people.size());
List<Person> adults = new ArrayList<Person>(people.size());
for (Person person : people) {
    if (person.getAge() < 18)
        minors.add(person);
    else
        adults.add(person);
}

Run Scala in your browser

Scastie is Scala + sbt in your browser! You can use any version of Scala, or even alternate backends such as Dotty, Scala.js, Scala Native, and Typelevel Scala. You can use any published library. You can save and share Scala programs/builds with anybody.

Run Scala code interactively

Online Courses

Functional Programming Principles in Scala

  • Free (optional paid certificate)
  • New sessions starting every 2 weeks!

Functional Program Design in Scala

  • Free (optional paid certificate)
  • New sessions starting every 2 weeks!

Parallel Programming

  • Free (optional paid certificate)
  • New sessions starting every 2 weeks!

Big Data Analysis with Scala and Spark

  • Free (optional paid certificate)
  • New sessions starting every 2 weeks!

Functional Programming in Scala Capstone

  • Free (optional paid certificate)
  • New sessions starting every 2 weeks!

Programming Reactive Systems

  • Free (optional paid certificate)
  • 18 Feb 2019

Upcoming Training

Scala ecosystem

The Scala Library Index (or Scaladex) is a representation of a map of all published Scala libraries. With Scaladex, a developer can now query more than 175,000 releases of Scala libraries. Scaladex is officially supported by Scala Center.

The Scala Library Index

What’s New

BLOG

Scala Days 2019 - Celebrating Collaborative Success

Thursday, January 17, 2019

EPFL Logo

Scala Days 2019 Logo

This blog aims to answer various questions we’ve been asked in the last 6 months, such as “Why is Scala Days in Lausanne?”, “Will it be more expensive because it takes place in Switzerland?”, “Who is organising it this year?”, “How will the community be involved?”, “Will there be speaker support; diversity scholarship?”, “Is my partner welcome?” and more. All these questions helped the Scala Days organising team shape a truly inclusive event. We chose to cover many aspects, which is reflected in the lengthiness of this blog post - there’s no judgment if you decide to jump to the sections that interest you the most. Let’s begin…

A note to the Scala Community

Dear Scala User, Contributor, Library Author, Community Member, Former and Future Community Member, dear Tech Lead, Manager, Sponsor, Marketing Team, Recruiter, Start-up Founder, Event Manager, Admin Staff, Spouse, dear Professor, Student, Teaching Assistant, SUG Organiser, dear EPFL LAMP team, dear Scala team at Lightbend, Scala Center Team,

Dear Scala Enthusiasts all around the world,

Thank you for being a part of the Scala tech evolution for the past 15 years, for being an active part of its success story. Scala Days 2019, the 10th edition, is designed to acknowledge and celebrate this collaborative success, so read closely and discover how You can join and make the celebration that much special! Jump to Call for action section for concrete details.

A little bit of history (or: Why only a Lausanne edition in 2019)

Scala Days was first organised in 2010 at EPFL by the, at-the-time team, Prof. Odersky’s lab in Lausanne, Switzerland, with 155 participants and 33 talks over 2 days.

In the last 10 years Scala Days grew to become the leading Scala conference, gathering 1500 participants each year, 70+ talks and various workshops on 2 continents and supported on average by 20 sponsors.

Since EPFL is the “home” of Scala and Scala Days, it was a natural choice for this special edition. Not to mention the magnificent setting, blend between high-tech and raw-nature that Lausanne offers. But there is an additional reason: EPFL is also celebrating a big anniversary in 2019 → 50 years since it became a Swiss federal school.

We believe that 2019 is the perfect year for you to (re)visit The Olympic Capital and this wonderful university, be a part of a historical celebration and, of course, take a selfie in front of the Scala stairs (o:

Vision

The Scala Days 2019 organising team’s vision drew much of its inspiration from your feedback over the years. Our vision captured in one word would be Inclusiveness. In more than one: celebrating diversity and honoring contributions. How does this translate in reality?

  • Up to 30% lower ticket prices than usual, and student ticket prices - courtesy of EPFL subsidy;
  • Diversity scholarship and speaker support are part of the overall budget. By purchasing the ticket or sponsoring you are participating in this initiative;
  • Daycare during the conference and an accompanying option for your partners will be available;
  • Free community events, such as a Scala spree and ScalaBrige, will take place before and after the conference, bringing participants and local community members together to teach and learn for a day;
  • 2018 and 2019 Phil Bagwell Community Awards will be given during the conference.

Add to this list many social events we have in store and we can comfortably rename Scala Days to Scala Week 2019.

All events

Even if you are not attending the main event, the Scala Days conference, 11th-13th June you might be interested in a couple of surrounding events starting already on Monday, 10th June, and are mostly free. Check out the table below and keep in mind that definitive schedule should be expected by March 2019:

Scala Days 2019 Events

The Community dinner and guided tours are included in the price of the Conference ticket, entry fee applies if you chose to join only one of those.

Call for action

Submit a proposal until 20th of January

We encourage you to submit one or more proposals, even if you never gave a talk before. Here are some arguments:

  • We ask for about 600 characters for an abstract for now, so your talk doesn’t need to be ready - just your idea! Share it with us. If your proposal gets accepted you will still have 4 months to develop a presentation, maybe even try it out in a local Meetup.
  • Yes, Scala Days is known to have “heavy weighters” speaking, but do not get intimidated. Zahari Dichev gave his first talk ever at the Scala Days 2018, and here is his advice: “I looked at the talks and realized that the conference is very welcoming and being a scala guru who regularly hacks on the compiler was not a prerequisite for giving a talk”
  • Speaker support is part of the overall budget. Please see below for details;
  • If you are a part of a Scala tech team, the best way to get visibility and new international Scala friends is to present your talk. On top of that you get a “look behind the scenes” + an invitation to the special Speakers dinner on a boat on lake Geneva (Lac Léman as it is locally known).

So take an hour or two and fill in this simple CfP by the 20th of January. Let’s put the Program Committee to work (o:

Buy a ticket

As mentioned, this year’s ticket prices are lower than usual. The reason being that we are privileged to create the event as an university entity and therefore eligible for financial support.

The registration opens beginning of February, stay tuned!

Diversity & Inclusion

We encourage people from under-represented groups in programming to attend Scala Days and the related events, specifically by providing student ticket prices and diversity scholarships.

For ticket and travel support, we will add our event to DiversityTickets once the registration opens. The same form can also be used to apply for a ticket to the Typelevel Summit that happens the day after Scala Days. If you’re unsure whether you’d be eligible, or if you have any other questions, please contact events@typelevel.org.

Become a volunteer

We are looking for motivated, enthusiastic, Scala loving volunteers. And not only during the conference, but during the whole week. Volunteers would help us to cover the ground at Scala Days, welcome participants, be the first point of contact, assisting with directions and much more. We are looking for 10 to 15 individuals that are up for the challenge! If you want to help and get the free entrance, submit your proposal here and we will get back to you by the end of February.

Speaker support

To be eligible for speaker support, you first need to get your proposal accepted. If your company or university are not supporting you, please just reply to your “Accepted” email listing the reasons you would need a support and what kind. Our team will be communicating with you until all elements for the decision are in place and give you an answer in due time.

Become a Sponsor

Please send us a direct email to initiate this conversation. This year we are also encouraging Scala Startups to come forward as we have reserved a special space to showcase brave, young Scala companies.

More

We would like to showcase some of the history. Please share your “throwbacks” and tag us on Twitter @ScalaDays, we would like to hear from you and include some of your stories and photos in overall promotion.

Even MORE

If you don’t find yourself in any of the above, you can always hit that button: share, write - spread the word #happybirthdayscala. Follow us: @scaladays @darjutak @scala_lang @EPFLevents for up-to-date information.

2019 Organising team and partners

The Scala Center at EPFL is the main coordinator and producer of the 2019 Scala Days conference. Lightbend is a co-producer, along with Dajana Günther and many community leaders constitutes our most important advisory group. No decision is made without considering their wisdom. The Scala Center also wisely chose onsite and community partners to provide the best experience for all involved in Scala Days 2019.

SwissTech Convention Center, Lausanne Tourisme, Typelevel, Scala User Group Organisers and official Sponsors.

We are very much looking forward to hosting you and your closest. In the meantime, as Martin would say, “Have Fun With Scala”!

Twitter Feed

See more tweets, or

Follow Scala on twitter

The Scala language is maintained by

  • Scala Center
  • Lightbend

Scala Center is supported by

EPFL IBM Verizon Goldman Sachs 47 Degrees SAP Twitter Your company