Which Programming Language?
It’s harder than ever to decide which programming language to use nowadays.
Python is nice and readable, but it runs too slow. C and C++ are a pain in the neck to read. Java is syntactically bloated and takes too much CPU. Haskell? Good luck finding support for that.
Before you read on, I must put a disclaimer here: I’m totally biased because my primary programming language is Python, but just because I’m biased doesn’t mean I can’t give unsolicited programming advice to strangers. :)
Anyway, in this article, we’ll be comparing the 4 arguably most used programming languages (excluding JS):
- C
- C++
- Java
- Python
Python
Pros: Easy to read, easy to understand, its standard library is larger than you think, and the open source ecosystem/community is great. Literally everyone has a Python API these days.
Cons: It’s just too darn slow
Fix: Use C/C++ extensions if you really need that speed boost. If your program doesn’t really have insane speed requirements (most desktop applications don’t), then rethink how your program is coded. Also, Cython is great — it uses static typing and compiled shared object files to improve python’s speed by a scary factor (up to 150x for some parts…yeah I know…)
C
Pros: It’s fast, and it’s been around forever.
Cons: It doesn’t have any object oriented support. There’s a pretty big chance you’ll end up wading through old websites from the 90s trying to find documentation. It can also be extremely hard to read and understand compared to the other languages.
Fix: Use it in conjunction with another language like Python or C++ (although mixing C and C++ code is a different bag of worms entirely, so be warned!)
C++
Pros: It’s almost as fast as C, and the STL is great. There’s also plenty of support for it. There’s also object oriented support.
Cons: It still has some leftover C paradigms, and it can be confusing to newcomers. It’s also still not as readable as Python. It’s not great for prototyping, or when the objective is what the code is doing, not the code itself (automation, data science.)
Fix: Use in conjunction with Python. Or just don’t; properly written C++ code with namespaces and documentation is readable enough.
Java
Pros: It’s supported basically everywhere. It enforces object oriented paradigms. It has a large standard library.
Cons: It’s bloated. It’s slow. The JVM is taxing on you processor(and RAM). You need to define a class for literally everything, which can be daunting to less experienced coders, and a royal pain.
Fix: If you need Java support for something, just bite the bullet and try and reduce bloat in your code as much as you can. However, if you don’t absolutely need Java, try one of the other languages. Kotlin is a great alternative, but lacks the universal support. However, its great for new projects.
Summary
If you don’t really need performance, Python’s great — the simple structure of Python code means faster development and a more readable codebase. If you need performance for something, Python has C extensions — or, if the codebase is small enough, just write it in C++. If you need Java support, you’ll have to stick with Java.