Scala: A Notebook of One (Programmer's) Love Story
In Bayaya, we rely heavily on multiple open-source technologies. I have already briefly shown how we use Three.js. Now it’s time for another cornerstone of our engine building - the Scala programming language.
The beginnings
My first encounter with Scala was in January 2014. The game we were developing back then was very different from its current shape. It was heavily based on SQL databases, which we hoped would help us provide some unique features: we intended to develop a generalized multiplayer mode, with the possibility of being played by two people, each playing at a different time.
Developing server SQL application, Java was a natural choice, but we were looking for some alternatives which would:
- reduce boilerplate
- provide high-level access to the database
- allow us to write concurrent algorithms
Scala (2.10) was relatively new but already usable. It mostly solved problems with binary compatibility, which were plaguing earlier versions. Given our past of programming C++ for decades, we were not afraid of a language which was a bit hardcore. Heck, we are real programmers, no quiche eaters.
It was a time of wild experimentation for us. NetBeans, originally for Java, was replaced with Eclipse and Scala IDE. We soon discovered the Scala Plugin for IntelliJ IDEA, which was quickly maturing at that time. We still use it today for the most part.
Our lack of database programming experience convinced us to switch to more traditional gameplay later, but we fell in love with Scala meanwhile.
Functional programming
The functional programming advocated by Scala was something we liked from the start. Imagine how delighted we were when we saw that solving data access concurrency issues was possible by completely avoiding them using immutable objects! We have experienced the thrill of writing code which is beautiful and elegant, while also simple and efficient.
The utility and beauty of Scala programming truly go together. We are easily able to write great code. This is probably possible in most languages, but the number of times we have shown each other some piece of code: “Come and look at what I just wrote …” is extraordinary. It’s like a complex logical puzzle with a beautiful and simple solution.
Great Scala community
Of course, Scala has had some issues and glitches along the way. The open source community didn’t leave us with them, though. Problems we have reported were often resolved quickly. Moreover, we were always met with respect, politeness and curiosity.
Looking Back
Years later, choosing Scala remains one of our best technical decisions. It has enabled us to write robust, concurrent code while maintaining readability and expressiveness. The language continues to evolve, and we’re excited to explore new features and possibilities it brings to our game development journey.