(A comment gone long, I decided to turn this into its own post)
Robert Fischer, We Aren’t Too Stupid for Polyglot Programming
I think Robert’s absolutely right in that we use many languages all the time, the questions are 1) why and 2) is it the right thing to do.
In my experience, polyglotism falls into a few patterns:
- Low level + scripting language driver (C + Lua)
- Frontend + Backend (Web)
- Core product + automation (Make, perl)
- Well establish DSL + general language (SQL, regexps)
In all cases polyglotism provides some obvious benefit. For the first two, that benefit is that it allows the project to work. If Lua were fast enough and Ruby ran in the browser… For #3: mixed language automation is an artifact of low-level languages. Make is a good build tool for C but Ruby’s build tool is Ruby (Rake). Given a change in technology and the right language, these could all be monoglot.
In the last case the DSL’s are chosen for convienence: SQL is better than hand B-tree manipulation and regexps better than FSA‘s.
Using multiple languages isn’t without cost. An obvious one is that learning languages is hard. Most developers know SQL but how many are good at tuning queries? Knowing a language also isn’t the same as fluency. Until you’re fluent in both languages, you’re likely to favor one. See the object/relational–not to mention FP/OOP–divide for examples.
There’s also the technical costs in translating data. XML, Protocol Buffers, Thrift, etc. are all valid interchange formats, but they’re not free. Robert’s emphasis on JVM languages does ease this hurdle, since I believe all the JVM languages can pass objects.
Finally there’s the cost of tools & debugging. You now need tooling–compilers, debuggers, syntax-aware editors–for several languages. More languages can lead to more complexity. Making matters worse, error messages across language boundaries are often cryptic, even when both languages are on the JVM.
So should we all be polyglot? As a matter of personal improvement, I’m all for learning new languages & techniques. But in terms of actually writing good software quickly, it probably only applies if
- There’s obvious, quick benefit
- There’s a clear separation
- None of the other costs are too high
Personally, I think the big efficiency gains are in monoglot solutions. In the web world, glot-supremicists–i.e. Lisp and Smalltalk–have come up with some interesting web frameworks. Polyglotism is a fallback when abstractions leak.