C++ vs Python

Joined
Dec 22, 2021
Messages
2
Reaction score
0
Hello. I am considering to learn a new programming language. Currently I am considering Python or C++. If I choose Python and let's say I become an expert in it, is there something that C++ can do and Python no? Thank you.
 
Joined
Mar 3, 2021
Messages
240
Reaction score
30
Those two languages have very little in common and not much overlap. Briefly, C++ is a low level language that is complex, not memory safe, and blazing fast. Python is a scripting language that is very easy to use, has a plethora of powerful libraries, is single threaded, and uses much more resources than C++.

But, I think you're looking at this backwards. You're picking your tool before you pick the project. You should use the most suitable tool for the job. So, what do you want to do with your code?

Python is much faster to develop in and easier to learn. It'll serve you well for server scripts, automation, websites, machine learning, and many other projects.

C++ can do all of those things, but it'll take much longer to code and require more expertise, but will generally run much faster. It's better suited for embedded or kernel development, video games, databases, modeling, simulation, binary data processing, and anything that needs to run as fast as physically possible.

That's it in a nutshell. The good news is that experience in any language helps with most or all other languages because good architecture and design patterns are universal. It's never too late to pick up another language if it's a better tool for the job.
 
Joined
Dec 22, 2021
Messages
2
Reaction score
0
Thank you CodeMonkeyJ for your reply.

In the past I had an era of Pascal and C.

Now I can code well in HTML, CSS, Javascript and PHP but no databases.

Speed is not an issue for me.

Honestly, C++ code looks kind of technical to me. Python code looks like a fairly-tale.

I don't have many goals in mind about what to code. I do not intend to code mobile applications. But I would like to be able to code anything I decide...
 
Joined
Mar 3, 2021
Messages
240
Reaction score
30
Full disclosure, I hate Python. I use it everyday for work and I hate it. I grew up on low level languages and Python never feels like "real programming." That's obviously nonsense, it's just how I feel. But...

Without a specific goal in mind, Python is a safer bet. Regardless of your project, you'll get up and running faster in Python and can build a proof of concept. If it turns out that speed is an actual issue, you can rebuild it in a lower level language (might I also suggest Rust) and you'll be able to build it faster and better already having experience in the specific problem domain. And maybe you just need to build small parts in C/C++ and can call that highly optimized code via Python.

Truly, Python is often like a fairy-tale. It's very easy to learn and code with, but the community has a mantra that there should be one, and only one, correct "Pythonic" way to do something. Frankly, they can be quite hostile about it, which is another reason I'm not a fan. But, honestly, maybe they're right. The most efficient, best implementation isn't always, or often, the cleanest, so even though it's easy to write in, it's not always easy to get right.

Without a specific use case, if you do think of a project that would do well as a library that any or all other languages could use or call, reach for C/C++. Otherwise, start in Python. Anything else is likely "premature optimization."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top