Quiz: Is Scala for me?
Tags: scala
Published: 2021-03-19 13:42:25

You're currently programming in Java (or any other language for that matter), and wonder whether learning Scala might be worth the effort? Here's a little quiz to help you decide.

Disclaimer: This is just a rough guide based on my experience, and should be taken with two grains of salt :wink:

#### You have a function that calculates the sum of a list of numbers. You have to provide the same functionality for lists of strings (concatenate) and lists of lists (append).

1. I duplicate the function for each data type. *(0 points)*

1. I think about how to make the function generic so that it operates on these three data types, then I refactor it accordingly. *(1 point)*

1. I implement a monoid type (or include a library which provides one) and change the function to operate on lists of monoids. *(2 point)*

#### When writing software, do you think in short or long terms?

1. I want to get things done now. Maybe I will never touch this code again, and my program will be irrelevant next year. *(0 points)*

1. My code will outlast me. New requirements after five years? I'm not worried, I deliberately design my code to be maintainable. *(2 point)*

#### What do you do when you something bothers you in a programming language?

1. I live with it, it's just one of those things. Nothing is ever perfect. *(0 points)*

1. I implement a workaround and publish it as an open-source library. *(2 points)*

#### How would you describe yourself?

1. I do what I'm good at, and I do it the way I'm used to. *(0 points)*

1. I'm curious, ambitious and always up for a challenge. *(2 point)*

#### What type of technology do you prefer?

1. I want to be productive immediately, without learning new concepts. I don't know when I have to switch to something else again. *(0 points)*

1. I'm willing to invest some time to learn unfamiliar concepts, if I see the long-term benefits. *(2 points)*

#### What is your opinion on `null` references?

1. They are useful and convenient. *(0 points)*

1. They are sometimes bothersome, but I didn't really think about it yet. `NullPointerException`s are just part of life. *(0 points)*

1. `null` is terrible. I'm aware of `java.util.Optional`, but this is such a controversial subject that I haven't yet committed to it. *(1 point)*

1. `null` belongs in hell, and option types are a useful replacement. I just wish `java.util.Optional` wouldn't be so limited, and that it would be used everywhere. *(2 points)*

#### How do you feel about static vs dynamic typing?

1. The type system is always in the way. I find it too restrictive. *(0 points)*

1. I like static typing, it helps with autocomplete and catches mistakes during compile time. *(1 point)*

1. An expressive static type system allows me to build safe and consistent domain models, and to write better code in general. *(2 points)*

#### What is your opinion on runtime errors?

1. When they occur, I fix them. Nobody can anticipate everything. *(0 points)*

1. That's what unit tests are for. *(0 points)*

1. I design my code to be robust, and handle any potential exceptions. *(1 point)*

1. Code safety is one of my major design concerns. By accurately modelling my data and treating errors as first-class citizens I can avoid runtime errors almost entirely. *(2 points)*

#### How do you prevent regressions?

1. The Q/A department is responsible for regression testing. *(0 points)*

1. I have unit tests with 120% code coverage. *(0 points)*

1. I have carefully designed the domain model using advanced type system features based on category theory, and I implemented a guarded finite state machine DSL that allows me to generate the workflow code directly from the specification. *(2 points)*

### Results

0 points: Don't touch Scala with a long stick.

18 points: Head straight to the [download page](https://www.scala-lang.org)!

Anything in between: Maybe it's worth taking a closer look?