Languages, Fast and Slow

February 18, 2020

Some months ago I gave a talk at Berliner Hochschule für Technik about the application of JavaScript as a full stack language. I built a tiny application and demonstrated it in front of the audience. It wasn't long before questions were asked and the presentation turned into an open discussion.

One person asked me why one should use JavaScript for programming the backend at all. He said that he could understand the convenience for a frontend developer to be able to write a backend without switching languages, but aside from that he wasn't sure about JavaScript being a good choice.

Knowing the discussion about JavaScript on popular internet posting boards, I anticipated such a question, and prepared myself in advance. My response started with the usual "you should try Typescript". Then, feeling quite clever, I showed some benchmarks comparing program busy times of NodeJS to Python3. NodeJS generally outperforms Python in those kinds of benchmarks. At the time, the "beating C with N lines of Y" meme was at its peak, and I thought that this would be a great argument for JavaScript.

Slower languages take up to 300x as long to execute code as fast languages.

The questioner listened to my arguments, watched the benchmarks and calmly replied that a programming language had nothing to do with performance. Also, he'd try out Typescript.

I was baffled. How could he say such a thing? Obviously the C programming language is much more performant than a scripting language like Python! Just look at all the bloat that gets initialized when Python code is interpreted. Everything is an object, there is a garbage collector, and don't even get me started on typing!

After my presentation was finished, I confronted the questioner with my arguments. He asked me: "Philipp, think of the last time you wrote a slow application. Was it slow because you wrote it in Python rather than in C? Or was slow because you chose the wrong data structure to represent the data? Did you write the algorithm to manipulate the data yourself and messed it up, rather than using what the standard library provides you with? Did you hack together a database rather than putting some thought into a scheme?"

C, Rust and C++ are the 'fastest' languages.

"You're not Netflix", he added. "Or Google or Facebook. Your applications are slow because you don't know how to use your tools properly."

I felt caught. He was right. My code is nowhere near the limit of what the languages I use can do. Instead of learning that exciting new language that's 20x faster than what I use right now, I'm much better off refining my skills with the tools I use at the moment.

Images are taken from benchmarksgame-team.pages.debian.net. Copyright © 2004-2008 Brent Fulgham, 2005-2020 Isaac Gouy. All rights reserved.


Profile picture

By Philipp Jung, data engineer and machine learning researcher.