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 😉
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).
I duplicate the function for each data type. (0 points)
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)
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?
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)
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?
I live with it, it's just one of those things. Nothing is ever perfect. (0 points)
I implement a workaround and publish it as an open-source library. (2 points)
How would you describe yourself?
I do what I'm good at, and I do it the way I'm used to. (0 points)
I'm curious, ambitious and always up for a challenge. (2 point)
What type of technology do you prefer?
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)
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?
They are useful and convenient. (0 points)
They are sometimes bothersome, but I didn't really think about it yet.
NullPointerException
s are just part of life. (0 points)null
is terrible. I'm aware ofjava.util.Optional
, but this is such a controversial subject that I haven't yet committed to it. (1 point)null
belongs in hell, and option types are a useful replacement. I just wishjava.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?
The type system is always in the way. I find it too restrictive. (0 points)
I like static typing, it helps with autocomplete and catches mistakes during compile time. (1 point)
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?
When they occur, I fix them. Nobody can anticipate everything. (0 points)
That's what unit tests are for. (0 points)
I design my code to be robust, and handle any potential exceptions. (1 point)
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?
The Q/A department is responsible for regression testing. (0 points)
I have unit tests with 120% code coverage. (0 points)
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!
Anything in between: Maybe it's worth taking a closer look?
Top comments (0)