I spent a few days reading about C++ and Python and I found that Python is so much simpler and easy to learn.
So I wonder does it really worth spending time learning it? Or should I invest that time learning C++ instead?
What can C++ do and Python can't ?
Python is substantially slower than other programming languages like Java , C++, PHP, Javascript , Swift, and others when it comes to execution time. This is a major concern for programmers when creating huge programmes with many lines of code. Python is a programming language with dynamic typing.
Python ranked first among Stack Overflow's “most wanted” languages for 2021. It is the third most popular technology, according to the same developers' survey. As of May 2022, it is no. 1 in the TIOBE Index.
There is no reachable maximum on the size of a file Python can open. People regularly load gigabytes of data into memory. Depending on your computer's RAM and whether it's 64- or 32- bit OS/processor, the practical maximum for you may be anywhere from 1 GB up before you get a MemoryError.
Some Python limits :
- Python is slow. It can be improved in many ways (see other answers) but the bare bone cPython is 100 times slower that C/C++.
This problem is getter more and more mitigated. With Numpy, Pypy and asyncio, most performance problems are not covered, and only very specific use cases are a bottleneck in Python anymore.
- Python is opened to anything. It's really hard to protect / obfuscate / limit Python code.
- Python is not hype. Unlike Ruby, there is no "cool wave" around Python, and it's still much harder to find a experienced Python coder, than, let's say, a Java or a PHP pro.
- After using Python, a lot of languages seems to be a pain to use. You'd think it's good, but believe me, not always. When you have to go Javascript after a Python project, your eyes are in tears for at least 3 days. Really hard to get started.
- It's harder to find web hosting than for popular solutions, such as PHP.
- As a dynamic language, you don't have the very handy refactoring tools you could get with Java and Eclipse or C# and VS.
- For the same reason, you can't rely on type checking as a safety net. This is why pythonistas tend to follow best practice and write unit tests more often than others.
- It seems I just can't find an IDE with a decent code completion. PyDev, Gedit, Komodo, SPE, etc. just don't do it as good as it could be.
With Python 3 types hints and tools like PyCharm or Sublime Text+Anaconda, the situation has changed a lot.
- The best docs are still in English only. Some people don't deal well with it.
- You have to get use to the syntax. Not only you get spaces and line breaks instead of bracets, but you can forget about long lambdas, --i, and ternary operation.
Now, to me, these are not reasons to not learn a tool that will make you produce more while having more fun. But maybe it's just me :-)
Honestly, given that :
Unless you have professional issues involving C++, you'd better learn Python first, it's more motivating. You still can learn C++ later, it's a useful language for system programming, embedded devices and such.
Don't try to learn both at the same times, multitasking rarely ends well.
Here's why it's worth learning Python:
A comparatively small number of problems are constrained by the speed of the algorithm. A comparatively large number of problems are bounded by the speed of the developer.
Why don't you ask the converse question? Unlike C++, Python can give you antigravity and summon souls via its import
command. On the other hand, C++'s 'equivalent' -- #include
-- only allows you to get some boring I/O and math libraries.
Seriously though.. C++ allows you to do more low-level stuff e.g. kernel programming, and allows you to write programs that run much faster (approximately ~20x). You can use it to create real threads that can take advantage of multiple-cored processors, while Python (due to its design) can generally only run its simulated threads on a single core.
IMHO you should learn both; Python for web development and quick-and-dirty scripts, C++ to write systems code, desktop applications, as well as to have a better low-level understanding of the computer. If you're just starting out, then Python; it's much easier to begin with.
More concrete measurements on the speed difference can be found here.
Edit: Seems like my information on multi-threading is out of date; see John Paulett's comment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With