Tutorials about the Scala programming language.

Recently-added Scala cheat sheets, tutorials, syntax, and examples alvin June 17, 2018 - 6:10pm

As I try to organize things a bit around here, here’s a list of some tutorials I’ve written lately about the Scala collections classes:

Interflow: Scala Native’s upcoming flow-sensitive, profile-guided optimizer alvin June 17, 2018 - 11:53am

Scala Native relies on LLVM as its primary optimizer as of the latest 0.3.7 release. Overall, we’ve found that LLVM fits this role quite well, after all, it is an industry-standard toolchain for AOT compilation of statically typed programming languages. LLVM produces high-quality native code, and the results are getting better with each release.

Scala Array class: methods, examples, and syntax alvin June 16, 2018 - 5:09pm

This page contains a large collection of examples of how to use the methods on the Scala Array class.

How to create a range of characters as a Scala Array alvin June 16, 2018 - 2:51pm

I just noticed this quirk when trying to create an array of characters with the Scala Array.range method:

# works as expected
('a' to 'e').toArray              // Array[Char] = Array(a, b, c, d, e)

# surprise: Array.range always returns Array[Int]
val a = Array.range('a', 'e')     // Array[Int] = Array(97, 98, 99, 100)

I was surprised to see that the Scaladoc for the Array object states that the second example is expected behavior; Array.range always returns an Array[Int]. I suspect this has something to do with a Scala Array being backed by a Java array, but I didn’t dig into the source code to confirm this.

For much more information about arrays, see my Scala Array class examples tutorial.

Why you should know Monix alvin June 15, 2018 - 10:42am

In this short blog post I will try, in 10 minutes or less, to present what Monix library is and convince you that it is good to know it.

Formerly known as Monifu, Monix is a library for asynchronous programming in Scala and Scala.js

Getting started with Shapeless alvin June 15, 2018 - 10:40am

Taken from shapeless' README:

Shapeless is a type class and dependent type based generic programming library for Scala.

To me, Shapeless is a toolkit to leverage Scala's type system at your own profit. You may use it to have more "precise" types, like statically sized list (lists which size is known at compile time), you may also use HList as a better tuple.

More generally, Shapeless can be used to make the compiler work for you, scrape some boilerplate, and gain a little extra typesafety.

Scala: Popular tools, libraries, and frameworks alvin June 15, 2018 - 9:53am
Table of Contents1 - Build tools2 - Testing tools3 - Database4 - Functional Programming5 - Asynchronous/parallel/concurrent programming6 - Web frameworks7 - JSON8 - HTTP clients9 - Configuration/properties10 - Many more

This page is a collection of popular tools, libraries, and frameworks for the Scala programming language.

Back to top

Build tools

Shared state in functional programming alvin June 15, 2018 - 9:09am has a nice article on shared state in functional programming.

A sample Scala/JavaFX application alvin June 13, 2018 - 5:19pm

As a brief note to self, here’s an example JavaFX application written in Scala:

object MainWindow {
    def main(args: Array[String]) {
        Application.launch(classOf[MainWindow], args: _*)

class MainWindow extends Application  {
    override def start(stage: Stage) {
        val borderPane = new MainBorderPane
        val scene = new Scene(borderPane, 600, 400)
        stage.setTitle("Al’s Pizza")
Scala 2.13 Collections Feature Freeze alvin June 12, 2018 - 11:51am

Here’s a note about the Scala 2.13 Collections Feature Freeze., which includes a link to this post on how/why the Scala 2.13 collections were redesigned from scratch.