Answer the question
In order to leave comments, you need to log in
Which is more efficient for a small application: C++ or Python?
Hello.
After reading this article, which compares the performance of common programming languages, and studying the answers of Toaster users to questions from the category “Which language should I choose?” ( one , two , three , four , five ) thought hard about whether he had made a mistake with the choice of Python for learning and subsequent use in writing small “household” cross-platform applications like a task scheduler or a dictionary.
On the one hand, the conciseness of Python allows you to quickly learn the language and reduce the development time of the application itself. And it's nice to read the code.
On the other hand, C++ is a fairly powerful language that allows you to write fast and economical applications in terms of resource consumption, the size of which will be smaller than that of the "compiled" opponent. However, the time required to study it is depressing.
Since it’s not entirely decent to get into existing discussions with your own questions, and only the opinion of more experienced colleagues can clarify the situation for me, I will venture to the community with the question:
Is the speed of a C ++ application significant enough to give up the ease of use of Python?
PS Without pretensions to professional use in the future, I would like to learn from scratch the language and related libraries that will allow you to create lightweight cross-platform applications with a nice customizable interface. Apparently, there are not so many options here: Python + PyQt (QML) , C++ + Qt (QML) or Java + Zetes .
Python is not fast and C++ is not easy to learn and use. Java, in addition to resource requirements, is poorly associated with use on a home PC, which is why I don’t consider it.
I will be grateful for your opinions, comments and advice.
Thank you.
Answer the question
In order to leave comments, you need to log in
I will support Sergey Protko , the speed of the python is enough in 98% of cases, the remaining 2% are achieved in C, Go, etc. Thus, the development speed and productivity are maintained.
Usually, when a Python programmer realizes that he lacks the speed of the language, he switches to the Go language and begins to enjoy life again.
Every language has its own philosophy.
Study not the tool - study the way of thinking of its creator.
When you understand the big picture, the specifics will be assimilated reflexively.
I will add to the answer of Sergey Lerg that the bottlenecks of the application can always be rewritten in C or the same pluses. Also, do not forget that there are Cython and similar things. And also think about whether the programming language will be a bottleneck in your case? If you really drive in terms of performance, then it’s better to really write most of the logic in python and performance-critical places in C. Example: albertz.github.io/music-player
As for performance in real tasks:
benchmarksgame.alioth.debian.org
As you can see, the python here can lag behind 100 times. If the bottleneck eliminates this difference, then you can write in python. If you need mega accounts or time charts, then Python is not the best solution.
Rust also looks extremely promising, on the one hand continuing the ideology of C \ C ++, but solving their typical problems. At the same time, a language that has not yet reached the first version shows fucking results.
And if we move on to very real tasks, then the issue of development speed primarily rests on the speed of debugging. And if earlier the ratio of 20% of the time we code 80% of the percent we debug, now it has turned into 5-10% of the code, 95-90% we test. And this is where C\C++ static analyzers or Rust features will give odds to the overwhelming number of languages.
So my advice is - python is good, but ignoring C is a bad decision.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question