Discover your dream Career
For Recruiters

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.

Click here to create a profile on eFinancialCareers. Comment ANONYMOUSLY on articles and make yourself visible to recruiters hiring for top jobs in technology and finance. 

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 editortips@efinancialcareers.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.)

author-card-avatar
AUTHORAlex McMurray Editor
  • To
    Toto1234
    9 July 2023

    Really good idea !! I also propose to make the same comparison with the hoe and the tractor for the farmer !

  • ph
    photobug56
    5 July 2023

    I love these language favorite of the month club fights. Computer languages don't themselves, as noted, have carbon emissions. Some languages have features others don't. Some are easier to program for certain situations. Some are more cpu and / or RAM and / or IO efficient. NONE do well if poorly coded.


    When computers cost a lot more, good coders learned to program tight, efficient yet well documented and reusable code. When you had a tiny address space (think early DOS, Windows, PDP-11's, etc., you wrote code overlay instructions, with just about everything callable other than the main repeating loop. As you got more ram, you learned to use that ram to improve the performance of tape and disk drives. Keep in mind that most processing then was of large quantity of transactions. Interactive systems require different approaches. But the point is clear; the language you use, how you code a particular program or system should be based on what works best for your purpose, not a random, popular selection from the Fad Of The Month Club.

  • Ed
    EdC
    5 July 2023

    I think this post shows a misunderstanding of both of raw algorithmic execution relation to emissions, and of Python. Part of this blog post tries to explain that https://edcrewe.blogspot.com/2023/07/sustainable-coding-and-how-do-i-apply.html

  • Dr
    Dr. Ngyn
    5 July 2023

    PYTHON has zero carbon emissions and efforts to reduce carbon emissions should be focused on real carbon emitters like airplanes and coal power plants. Focusing on zero-emission consumers like electric vehicles and computing power is unscientific.


    Electricity producers’ carbon emissions are already accounted for as “Scope 1” direct emissions per the U.S. EPA. A developer running Python doesn't cause the turbine of coal fired power plant to magically spin faster; the energy used is being generated regardless. 


    Any abstraction of emissions or environmental impact beyond energy production is absurd. If one chooses to pursue such abstraction, the one inevitably conflates efficiency with subjective values. 

    Whether it’s "legitimate" to spend any of society’s energy resources on anything is a decision for individuals. 


    I can't believe this nonsense is on here.

  • Ge
    Geoff
    2 July 2023

    Java is definitely no easier to develop than C++.


    And if you write complex algorithms in a scripting language, of course it's slower and less energy-efficient. Use languages for what they're intended - python, perl etc are great for file and string manipulation, though, or (as others have said) for glueing together compiled modules.

Sign up to our Newsletter

The essential daily roundup of news and analysis read by everyone from senior bankers and traders to new recruits.

Boost your career

Find thousands of job opportunities by signing up to eFinancialCareers today.
Recommended Jobs
Garrison Associates, LLC
Quantitative Developer
Garrison Associates, LLC
Manhattan, United States
Paritas Recruitment - Data & Tech
Quantitative Researcher (Systematic Fund)
Paritas Recruitment - Data & Tech
London, United Kingdom
Tandem Search
Quantitative researcher - Top Hedge Fund
Tandem Search
London, United Kingdom
Leverton Search
Junior Global Equity Analyst
Leverton Search
London Borough of Bromley, United Kingdom

Sign up to our Newsletter

The essential daily roundup of news and analysis read by everyone from senior bankers and traders to new recruits.