úterý 18. srpna 2015

A case against polyglot programming

We have been doing polyglot programming at GoodData even before Micro services get traction and honestly it was probably one of the biggest mistake we ever did. At the beginning (2008) our platform was simple LAMP stack with REST interface and bunch of JavaScript. We have been adding more and more languages as we followed a golden rule use right tool for right job. We add Erlang because what language to use for a distributed system. We add C++ because what language to use for fine tuned computations. Since 2008 our stack was getting bigger and bigger - Perl, Java, JavaScript, Erlang, C++, Python, Ruby. In such heterogenous environment was critical to encapsulate every service/component with an API in order to keep interoperability. All our services expose a REST API so programming language is an implementation detail of them. Someone could appreciate such diversity, but from my 5 year experience it’s a nightmare.

First of all, once you start developing features spanning more than one service you need a team with experts in more than one or two languages. It’s absolutely ok to use one language for backend (pick your favorite) and one for fronted (JavaScript rule them all), but setup a team with Java, Perl, Erlang, JavaScript developers is complicated. You need more than one developer for every language because of redundancy. Those developers are mostly experts in one language meaning you can train them for other languages, but it takes a lot of time and money. Developers have to see the given language and not only language but also the whole ecosystem as a career opportunity. You not need a newbie who learn HelloWorld, but someone who is able produce production ready code. You can hire them if they are available and you have enough time goes through gazillion of CVs, interviews and not counting their boot time to domain problems your company tries to solve. It’s not a technical choice, but more a people/culture choice.

Second, what polyglot programming really offers? It’s worth to see 50 lines of Java code can be reduced 10 lines of Clojure code but for what. At least at the backend most of the code do nothing more than run few or more SQL queries, transform result to XML or JSON. Do we really need different programming languages for that? I doubt and you should too. Most of the programming tasks can be accomplished in single language without loosing any comfort and productivity because of existing frameworks, tools or libraries. I don’t think we should use one language for everything, but using different languages even sexy languages for very similar use cases is waste of time and resource.