Susan Potter
software: Created / Updated

Scala versus Erlang for Managers

The demise of Moore's Law has brought forth a new era of multi-core processors. As software professionals, we must confront the daunting task of adapting to this hardware paradigm shift having direct implications for the performance and reliability of the software we develop. In this article, we delve into the debate between Scala and Erlang, two languages at the forefront of addressing the multi-core challenge.

Embracing the Power of Multi-Cores

How do we leverage the advantages afforded by these new hardware capabilities? To effectively tackle this question, we consider two distinct scenarios: software projects with large, intricate systems already built using languages like Java, and startups with the freedom to adopt long-term solutions from the outset, such as Erlang.

The Legacy Enterprise

Utilizing JVM threading (whether in Java or JVM-based languages like Scala) presents challenges, particularly when dealing with third-party code or existing Java/JVM code that may lack thread-safety. While migrating or porting such systems to a truly concurrent language like Erlang may appear daunting, it is crucial to identify key bottlenecks where threading issues can be addressed to enhance throughput and CPU utilization. Taking a pragmatic approach, many engineers and architects are unlikely to advocate a complete rewrite in an unfamiliar language. However, it is essential to recognize that sticking to stopgap measures, such as Scala, may eventually reach a tipping point, necessitating a transition to a pure concurrent language like Erlang.

For the medium-term, hybrid solutions can offer a viable path forward. By employing Service-Oriented Architecture (SOA) principles, it is possible to design a meaningful architecture that declutters the system and allows for targeted Erlang porting or rewriting of bottlenecked components. This approach provides a low-risk Proof of Concept (PoC) project, enabling you, as a manager, to evaluate Erlang's suitability for your enterprise.

Drawing from my experience with legacy enterprise projects, I understand that management often favors monkey patch solutions (e.g., Scala) when the short-term pain of threading existing code is perceived as less than the effort required for a comprehensive rewrite. However, it is important to convey to management that this is likely a temporary solution. Over time, the pool of skilled engineers and architects well-versed in truly concurrent languages like Erlang is bound to grow, making a transition less risky. Nonetheless, during this transitional period, unless you opt to overbuy hardware, both your hardware and software may not fully exploit their potential. In conservative IT enterprises, augmenting hardware capabilities while preparing for a future move may prove a prudent near-term approach.

Startups

For startups or those commencing from scratch, the landscape offers a mix of positive and less favorable aspects.

Greenfield projects hold great promise, as they allow for a fresh start with the potential to get things right from day one. In this context, I strongly advise considering Erlang as a low-risk choice. This recommendation stems from several factors:

  • Erlang is a mature language and environment, having been tested extensively in large-scale, complex real-world systems, especially within the telecommunications industry, where reliability and scalability are paramount.
  • Although Erlang's documentation and educational resources may currently be somewhat limited, there are valuable books available that facilitate the transition to Erlang and Functional Programming.
  • The Erlang community has developed a robust framework called OTP (Open Telephony Platform), designed and deployed for services across various industries. OTP's applicability extends well beyond telephony applications, making it a versatile and proven solution.

Admittedly, one challenge associated with Erlang is the scarcity of experienced practitioners in the field of pure concurrent languages. To mitigate project risks, it is essential to hire at least one Erlang specialist who can guide your team, helping them navigate potential pitfalls and ensuring a successful outcome. While the cost of such expertise may not be insignificant, the investment pays off in terms of risk mitigation, particularly during the early stages of a project.

Another consideration is that using Java classes directly within Erlang is not straightforward. However, this challenge can be addressed by encapsulating Java code within an SOA framework. Such an approach allows for subsystem decoupling and decluttering—an essential aspect regardless of the legacy solution you choose.

Summing up

As you embark on the multi-core journey, remember that the decision between Scala and Erlang depends on various factors, including the context of your project, the presence of legacy code, and the skill sets available within your team. By carefully evaluating these aspects and remaining attuned to industry trends, you can make informed choices that maximize the potential of multi-core hardware and enable scalable, reliable software solutions.

Resources

Programming Erlang: Software for a Concurrent World by Joe Armstrong

This book, for the moment, is the definitive guide for Erlang. If you have already decided to go the Erlang route then you will not mind (or perhaps not even notice) the "selling" of Erlang throughout the book. Overall this is an essential book to anyone learning Erlang at this point.

If you enjoyed this content, please consider sharing this link with a friend, following my GitHub, Twitter/X or LinkedIn accounts, or subscribing to my RSS feed.