This is a sequel to my earlier post – Language War – Scala v/s Python where I shared some of the practical yet emotional/instinctive factors that come into play when picking the core language at a startup. We left the story tied at 1 – 1. Read on to see who ultimately won the ZLemma language war.
Libraries and Tools: Scala’s interop with Java makes it very attractive, giving access to a wide range of libraries and tools for algorithms development. Although numerical computation forms the core of our app, we are not compute-bound and are unlikely to be compute-bound anytime soon. It’s easy to be sucked into the scipy mantra because of the nature of our business, but practically this is not the biggest consideration with our product right now.
What’s important is to note that ZLemma is not just about mathematical programming. A web platform and database engineering are key components of our app. Yes, Scala has Play (previous typo – “Lift” – corrected) but it can’t match the maturity of Django. This overrode the benefits of some of the other libraries/tools that Scala/Java have on offer. Python gets ahead again: 2-1.
Team Culture: A good language coupled with elegant paradigms enable us to express the math/business models more naturally and make the process intellectually satisfying as well as rigorous. This has the effect of establishing a strong and consistent culture in the team.
My view is that functional programming and stateless computation is the natural way to think and code. It’s not just about elegance and clarity of thinking. It’s also about “Kill state, and you kill bugs” (okay – I made up that line ). I wanted the team to think along the lines of “lambdas, maps and folds” to build a high-quality software product. While Python gives you lambdas and list-comprehensions, the languages doesn’t really encourage the functional style.
The other factor I thought a lot about was the “If it lints, it’s probably correct” approach to coding – we are all guilty of this, aren’t we? With Scala, the approach often works and we unfortunately end up with a false sense of security and consequent indiscipline. On the other side, this approach to coding doesn’t make any sense for Python, but we still indulge in it! The discipline problems are compounded in Python because the language generally encourages playing offense more than defense (seeking too much instant gratification). Ultimately, I felt Scala leads to a better coding culture in the team. 2-2.
Tried & Tested versus New & Cool: Scala is an impressive language because certain things can be accomplished more easily than in other languages, thanks to features like traits, type variance, lazy evaluation, and actors. However, I reminded myself that it’s a relatively new language and that very few startups have begun with Scala. I feared that we might be too slow in our development and what’s worse, might not even realize that we could be much faster if we had opted for Python.
I also worried that Lift might not be as convenient or versatile as Django. Most importantly, there was the fear of going off the beaten track and encountering something unexpected. The advanced features of Scala are indeed complicated (eg: type variance) – maybe we’d end up tying ourselves in knots trying some of these new things? I was chickening out … So, Python ended up winning the ZLemma language war 3-2.
Looking back: Our platform has been built in Python. But we do use some Scala for independent code outside the platform. The speed with which we have progressed has surpassed my expectations. I am sure it would have taken us much longer to get here had we opted for Scala.
With Python, we get a high from making things work quickly. That’s nice for team morale, but I also get frustrated with the poor defense habits it generates. So I’ve told the team: “Play offense to develop a feature for say a week, then play defense for a couple of days to consolidate (type asserts, exception handling, unit tests etc.), then go back to playing offense on the next feature, and so on …”. This is a happy middle-ground. But the occasional discovery of bugs (mainly due to dynamic typing) gets me ranting about Python. So I’ve decided to rewrite just the core calculation engine in Scala and have the web/data framework remain in Python. REST will bridge the gap. Wish us luck Cmd-Tabbing between Scala in Eclipse and Python in vim