Is Polyglot Programming a Good Thing?
Is Polyglot Programming a Good Thing?
Join the DZone community and get the full member experience.Join For Free
Is the concept of adopting a continuous everything model a daunting task for your fast moving business? Read this whitepaper to break down and understand one of the key pillars of this model in Continuous Governance: The Guardrails for Continuous Everything.
You have a lot of technologies on your CV in your last role. Java, Python, Scala, Node. What are your thoughts on Polyglot programming? Is it a good or a bad thing?
TL;DR: Right tool for the right job, but chances are the right tool is Java. Don’t choose a language because you want to try something new: it’s going to be a maintenance nightmare.
I’m not sure if you’ve noticed, but recently there seems to be an awful lot of noise about the death of Java and the rise of the JVM. Scala, Clojure, Groovy, Jython have all recently gone through being the language choice du jour (Although this great article shows how Java still rules the roost by a long way). More and more projects in these languages are appearing on the job boards and in projects at bigger and bigger companies.
But, is this a good thing or not?
As a massive nerd, I love trying new programming languages. New things are shiny. I like shiny. Last year when I started doing the “functional programming principals in Scala” course on coursera (it’s free!) run by Martin Odersky, the creator of Scala, I was convinced Scala was going to be the answer to all of my Java based problems. “Look ma, the syntax is so much more concise! And now I understand why immutable is so awesome!”. It’s this kind of hedonism which is why more and more projects are getting started in these languages. Bored programmers want to try new things out, and so a new language is brought into the company.
This is a terrible idea.
The sales pitch is “right tool for the job”. And that’s absolutely correct. Much like how in the early days of Java, if you needed really low latency you had to go to C++. It was the right tool for the job. There are absolutely valid cases for where functional programming is a better fit than object-oriented. But you need to be able to properly justify this up front with strong reasoning. The answer shouldn’t be “I fancied trying something new”. There’s a great post on Yegor256 called “It is not a school” which goes into depth about the fact that projects should hire people who already have the skills for the job:
“However, if you make your projects spend their money on your education, that’s theft. And a good project manager should stop you, saying “This is not a school!”
This is a hard truth to swallow because I want to learn new stuff on the job, but the brutal fact is that it’s not in the best interests of the firm to have to spend time and money to teach me new skills.
Even if you already know the language in question it’s still probably a bad idea to use it. Your code will outlive your stay at an organisation. Irrelevant of language, people are going to curse your name when they have to maintain it, because as programmers it’s much easier to blame the person that came before us. Our jobs are hard enough when we have to take over Java code. Taking over an old codebase in a brand new language is going to be that much harder. If this is on a big project, then the organisation is going to have to hire people that specifically know the language. For now at least, these people are few and far between, and often expensive because of their niche.
As if that weren’t reason enough to think twice, you need to consider tooling. Java has been around for a really long time and has an incredible set of tools and libraries around it. IntelliJ is all powerful; the verbosity of Java is irrelevant thanks to Keyboard shortcuts and intellisense which make me immensely productive. Tooling like this doesn’t exist in a mature fashion in any other language (if you’ve ever tried to debug a gradle script you will know my pain). There’s also a lack of documentation and online support; it’s safe to say that most common Java problems have been answered on StackOverflow. Newer languages are improving, but they’re not there yet.
This isn’t to disparage polyglot programmers. I think being able to program in multiple languages is an absolute must and is something I look for on a CV. It shows a wider interest in programming and it’s a great way to change your mindset around your coding style. Spending the time to try out functional programming has absolutely changed my approach to Java and I write better code for it. I feel educated enough in the languages I know so that when the right use case comes up, I can and will use the right tool for the right job. But it won’t just be because I fancy giving Clojure a go (which I really do).
Now, I’m sure this is going to draw a lot of ire from the community. Which is why it’s important to remember that in the context of interviews, you need to present whatever your own opinion is but justify it in the context of the arguments above. It’s perfectly valid to argue that Java is a ridiculously verbose language and it’s not as suitable for a lot of tasks; highly parallelised data processing or complex multi threading could be better suited to Scala and Akka for example. You can argue the gains in using other languages outweigh the costs of introducing new languages to be maintained, particularly as developers we should be willing and able to retrain ourselves in those languages. Just make sure you can articulate your viewpoint and the arguments against it properly.
Published at DZone with permission of Sam Atkinson , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.