Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the limits of Python? [closed]

Tags:

c++

python

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 ?

like image 438
taabouzeid Avatar asked Nov 24 '09 19:11

taabouzeid


People also ask

Why is Python not used in large projects?

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.

Is Python still relevant 2022?

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.

What are the size limitations for files being managed by Python?

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.


3 Answers

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 :

  • C++ much harder to learn;
  • You can do pretty much any thing you want with Python;
  • You will get quicker result with Python in your projects.

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.

like image 69
e-satis Avatar answered Oct 28 '22 18:10

e-satis


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.

like image 28
Robert Rossney Avatar answered Oct 28 '22 19:10

Robert Rossney


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.

like image 37
int3 Avatar answered Oct 28 '22 19:10

int3