Python is 57x slower than C++ (and 45x worse for the planet)
Banks and other financial institutions like to make a big deal about their environmental efforts through their ESG teams, but that doesn't mean they're climatically benign. Their engineering teams are generating big emissions merely through the code they write.
A 2017 paper published alongside the ACM SIGPLAN Engineering Language Conference tested a number of the most prevalent programming languages in use today to determine, among other things, how much energy they used. The results showed that Python, despite its popularity was a massive energy hog using 45 times as much energy (4390 joules) as C++ (77 joules) to execute its programs.
Python is an interpreted language. While compiled languages like Ada, C++ and Rust directly translate to instructions for the machine, Python must be read by a separate program first before being translated into machine instructions. Interpreted languages are generally far easier to learn and simpler to use, but this comes at the cost of energy in a big way.
Python is very well-loved in finance. Investment firm Man Group for example have called it the "second language" of the firm. On eFinancialCareers, of the 5,072 jobs currently available for quants and technologists, 1217 mention Python. If not Python, most banks like using alternative interpreted languages; Goldman Sachs' love affair with Slang, is well documented.
The same phenomenon can also be seen in fintech. Stripe, for example, relies heavily on Ruby, which is only narrowly faster than Python. If this evident energy gap exists in small, optimized benchmarking programs, one can only imagine how much additional energy is produced in Stripe's 50 million lines of code.
C++ may be kind on the environment, but it is far from kind on its developers. C++ is very difficult to work with by nature, which is what makes its elite engineers so valuable to hedge funds and high frequency trading firms. Rust, on the other hand, is similarly energy efficient, but is known for being a lot more enjoyable to work with. However, it lacks a serious presence in finance beyond some crypto roles.
The most peculiar phenomenon is Java. The only language in the top five for energy consumption not to be a pure-compiled language. While it is somewhat low level and capable of ultra low-latency code, Java also operates using the Java Virtual Machine (JVM) which makes it much easier for developers to work with.
Have a confidential story, tip, or comment you’d like to share? Contact: +44 7537 182250 (SMS, Whatsapp or voicemail). Telegram: @SarahButcher. Click here to fill in our anonymous form, or email email@example.com. Signal also available
Bear with us if you leave a comment at the bottom of this article: all our comments are moderated by human beings. Sometimes these humans might be asleep, or away from their desks, so it may take a while for your comment to appear. Eventually it will – unless it’s offensive or libelous (in which case it won’t.)