r/learnprogramming • • 4d ago

Why is C++ better than Python?

Hello! I am new to programming. Im in college and we use Python for my classes right now.

I hear people make a lot of jokes about how C++ is more powerful than Python, and should be used instead. But why?

Feel free to give me any tips as well, on things that helped you be a better programmer, or just any insight you may have! Thanks so much

61 Upvotes

175 comments sorted by

152

u/CodeToManagement 4d ago

This is like saying why is a hammer better than a saw. Neither is better or worse depending on what your use case is. They are both tools to get a job done- so pick the right tool for the job

19

u/cmdr_iannorton 4d ago

That is a popular analogy but not quite correct, you literally can write any program in c/c++, you cant do that in python.

Python is suited to a quick development process.

In some cases it can be too slow, and not all computers can run python.

74

u/vegan_antitheist 4d ago

Both are Turing complete. There's nothing C can do that Python can't. The difference is performance. That's why you don't see many computer games written in Python. But someone ported DOOM to Python: https://github.com/hmofet/duum
You could port GTA6 to python and it would run. Just not at 30 fps.

-39

u/mysteryihs 4d ago

There's nothing C can do that Python can't. You could port GTA6 to python and it would run. Just not at 30 fps.

So there is something Python can't do, it can't run games more efficiently than C.

49

u/Talbertross 4d ago

Obviously it means there are no computations that C/C++ can do that Python can't. Pedantic dingus.

16

u/EquipLordBritish 4d ago

Not only that, but it's also (pedantically) incorrect. You could write a python program that outputs a custom executable that is every bit as fast as C code. It would be very annoying to do and I doubt anyone would bother, but it could be done.

1

u/Moscato359 23h ago

That's not really the python hitting the target anymore though is it

It's python making an exe, not the exe being python

1

u/EquipLordBritish 11h ago

Seems like you could say something similar about compiled languages, since the compiler is what actually writes the program.

1

u/Moscato359 11h ago

I mean, sure, technically you can make a python compiler which compilers from python to ML, and then C to ML and say they're the same, but the python language isn't really built for that

Technically feasible, and practical are not the same

1

u/EquipLordBritish 11h ago

That's about what I said in my initial comment.

2

u/Moscato359 23h ago

It's not pedantic when your goal is to have an app within a performance target.

I want to write my game to run at 144fps

Well pure python can't do it

1

u/Talbertross 17h ago

Nah, you're just pulling some "can God make a boulder so big even he can't lift it" bullshit

1

u/Moscato359 11h ago

Uhm... Needing to hit a frame rate target is a very common thing for game development 

1

u/vegan_antitheist 17h ago

And still, it's just as powerful. What you can calculate and how long it takes are two very different questions.

1

u/Moscato359 11h ago

If you're for example, running a PC game, and one of your requirements is a specific frame rate, it's not as powerful

6

u/moratnz 4d ago

"The difference is performance"

32

u/CodeToManagement 4d ago

You can write anything you want in assembly too. It doesn’t mean it’s better than any other language.

That’s why it’s about picking the right tool for the job. C++ is great for applications where you want more control over memory and much more optimised code execution. You don’t need that for some basic crud APIs for instance so it’s highly unlikely you’d benefit from the extra difficulty of using c++ when you could do it in half the time with Python.

15

u/Philluminati 4d ago

Just to be the contrarian (and for fun)… there are arguments that Python is demonstrably faster than C in terms of raw execution speed in certain scenarios.

You know Pythons REPL (console) is excellent. You type 2+2 and it immediately says 4. Way faster than you can compile a C program. Then you can reuse the answer in the next calculation. This is an important concept to keep in mind here.

C programs have their memory laid out at compile time and have a slow compilation phase. They also don’t have that lazy continuation that interpreted languages like Python have. Their REPLs rarely offer both their whole language and the benefits of the REPL itself.

If you want to transform a 10TB json file, Python and C would both be bottlenecked the time it takes to download the file to the machine in question … but since Python is interpreted… it doesn’t need to download the file… the code itself can be distributed without compilation over a 1000 node horizontally scalable Apache Spark cluster as a UDF. Each machine processes 100GB of data. C code basically can’t be, (unless someone write a c interpreter). This is why Python is more prevalent in big data and C isn’t.

Python can’t work with registers and memory layouts and beat C on a single machine, but C is so tightly coupled to a single machine architecture it makes a poor language to describe and implement cluster level computations.

If you don’t buy it, that’s fine. I write this out of boredom.

5

u/higras 4d ago

This was a huge eye as a learner. Each does different things. What do you need done? Morse code like bit assignment for binary could work, but no one does that.

On the other hand, hardware AI physical etched into the chip is potentially an order(s) of magnitude more energy efficient and faster.

You want a manual or automatic transmission? What vehicle works best for this goal, convertible or truck? Should I get you a pen, pencil, or brush to write with?

On one hand, I'm sure op knows there are differences, but from personal experience it took running into the limitations of different languages before it really clicked

3

u/MisterGerry 4d ago

What the hell are you talking about?
No. Just... NO.

2

u/moratnz 4d ago

If the relevant metric is 'time to first successful run of the code' not 'time for a single execution of the code, once you've finished prepping the code', python is a really fast language.

1

u/GarThor_TMK 2d ago

That seems to be philluminatis only metric...

Write once, run once, keep the results, toss everything you did to get the results.

For this, Python excels...

For anything else, it's a wasteful and unoptimized way to run your code.

0

u/moratnz 1d ago

Though much of the time the waste and lack of optimisation is irrelevant.

If C delivers the result in a microsecond and python delivers it in a millisecond then C is a thousand times faster, and for low-scale applications that thousandfold speed difference is completely irrelevant, meaning python's ease of maintenance makes it strictly superior.

2

u/Philluminati 3d ago

Think about it like this:

* A C program has a start and an end. Void main. Between runs the memory is blanked out or in the control of the operating system. C programs have to read and write their state between executions somewhere. Maybe a file, a db, a cache server.

* IF you know you’re going to do 20 manipulations to a csv file you could put it in C program and it would be fast as hell.

* but if you were writing 20 separate C programs (because you didn’t know the next one was until the last one completed) you might end up say chaining them in a bash command like this: ./app1 | ./app2 | ./app3.

With this approach, each C app has to load, parse the csv and buffer it in different memory positions 20 times. Piping a csv file through 20 C programs is arguably slower than 1 C program. ./sort can’t do an in place quicksort on the last apps array for instance.

However fully interpreted languages, repl style (aka not you Java), run without the overhead of the interpreter closing, being able to directly manipulate the memory of the previous program, reuse its live database connection handles without renegotiating the connection security. Therefore beyond a certain point, Python pulls ahead in speed. In essence 1 Python session vs 200 C apps chained together, with foresight being the reason we need 200 C apps instead of one.

If you think you can write a long lived C program to overcome the memory sharing issue, you’re either written an interpreter or a database. If you try and overcome the memory session limitation using mmap or memory sharing between processes, it won’t scale elastically or work on a container platform.

Another way to think about it is that interpreters offer global access to long lived shared memory across applications but individual C applications don’t.

Again, I’m not entirely trolling but not entirely serious either.

2

u/baked_salmon 4d ago

Yes you could create a UDF for your data processing, but no one that cares about cost is going to be doing any meaningful data processing with Python that isn't just calling C++ code under the hood.

But it's still a valid point. Python allows you to iterate quickly, but you probably don't want to be doing real work with it.

13

u/baked_salmon 4d ago

Python is Turing complete, wdym you can’t write any program in Python?

4

u/Mwahahahahahaha 4d ago

They aren’t saying you can’t run any Turing complete program in python. They’re really saying python cannot fit certain resource requirements that c/c++ can. I.e., graphically demanding games, intense simulation software, modeling programs, etc.

1

u/100BottlesOfMilk 3d ago

It depends on what you mean by "in python". Python is best used when you're using libraries and the like which are implemented in a faster programming language

-1

u/moratnz 4d ago

That's like saying you can't write some things that you can write in Python in C/C++ because there are things that you can do as a one-liner in Python that take way more code in C/C++.

Performance and lines of code aren't relevant to a strict 'can X be written in Y language' question.

1

u/Moscato359 23h ago

Can x be written in y language, if x is a specific app with a specific performance requirement to be considered x, then yes it is

1

u/Mwahahahahahaha 3d ago

Technically, any C/C++ program can be a one liner. That’s the advantage of actually having ;

1

u/Moscato359 23h ago

There are many things that can't be written in python simply because a feature of the application is it's performance 

2

u/xeow 3d ago

That is a popular analogy but not quite correct, you literally can write any program in c/c++, you cant do that in python.

While I almost 100% agree, I don't think there exists any program you can write in Python that trounces on its own memory and causes as segfault, or dereferences a null reference and crashes the program... At least not in a way that didn't depend on a bug in the Python runtime or a library. But in C/C++, it's perfectly possible to write a program that crashes. (And we've all accidentally done that! :)

1

u/cedarSeagull 3d ago

not all computers can run python

C'mon.... Every computer can run Python. No one counts your Windows Phone as a computer.

1

u/coconut_maan 3d ago

They optimize different things. Python optimizes development speed and maintainability with easy to access tools and easy to interface with services.

C++ optimizes low level real time performance. The tooling can be a bit brittle and time consuming.

If you want to make a shader or robot use c++. If you want to make a web app or aws pipeline use python

1

u/heisthedarchness 23h ago

Name a program you can write in C++ that you cannot write in Python.

1

u/DoraTheHomestuckHomo 3d ago

It's more like comparing a logging axe and a fire axe. They can get the same job done but they have different strengths

49

u/Solnx 4d ago

C++ is a lower-level language than Python, giving developers more control over memory and the system. When used correctly, this can achieve stronger performance. The downside is greater complexity, more opportunities for bugs, and a steeper learning curve compared to Python when getting started.

They have different use cases, but C++ is better suited for OS, game engine, low latency programs, ect compared to using Python.

2

u/Illustrious-Fail1951 12h ago

This is basically the only real answer I've seen here so far

-5

u/ne0n008 4d ago

Isn't Python built on top of C while C++ is extended C making the major difference in performance?

16

u/Solnx 4d ago

CPython is implemented in C yes, but that doesn't explain major differences in performance between C++ and Python. The difference largely comes from how Python executes code. C and C++ generally have comparable runtime performance.

Memory management is one example of the tradeoffs. In C, developers are responsible for manually managing dynamically allocated memory. This can be tedious and error-prone, but it provides greater control and can reduce runtime overhead. Python handles memory management automatically, making development easier at the expense of some performance.

9

u/xarop_pa_toss 4d ago

There's much more to it than that. Python is an interpreted language instead of compiled. What you are thinking of is the Python compiler to bytecode which is called CPython, and that is indeed written in C

1

u/razorree 3d ago

to some extend, but not exactly true.

there is a lot of Python libraries in C/C++ (like all statistics, math etc.) that you can use in Python. so core computations are made using c/c++ and maybe your GPU if you like.

so for data science or some GUI apps - python is good. but for overall performance (like games) it's bad.

11

u/DiabloConQueso 4d ago edited 4d ago

It’s not an either-or choice. You use C++ when appropriate, and you use Python when appropriate. Some things C++ does “better” and some things Python does “better.”

Learn both. Learn as many languages as you can. Don’t pick one. Pick them all. Learn when one is appropriate and learn when another is appropriate.

If you’re learning Python right now, keep at it. Learning C++ isn’t going to help you pass that class. Learn C++ later, in a different class. Or on your own.

You’ll eventually learn the difference between compiled languages and runtime interpreted languages. And other differences. Then you’ll be in a better position to decide what language to use to solve whatever unknown problem or task. There are some things you’ll have many options for, and there are some things where your options are going to be more limited.

You’re probably learning things that aren’t language-specific right now: loops. Conditionals. Functions. Variables. Those things exist in pretty much all languages. The important part right now is getting those fundamentals down pat and Python is a good way to learn them. C++ would be too, but again, that’s not the class you’re taking right now.

27

u/NopileosX2 4d ago

All programming languages which are used are bad and all others are irrelevant. C++ is an overly bloated mess and python has no idea what it even wants to be these days.

Software development is impossible.

9

u/theGaido 3d ago

C++ is more like Magic the Gathering. There is a big legacy of content. Official - full rulebook has hundreds of pages, and it can be overwhelming. But in reality, for comforting play, you need just to know basics and current meta. Other things you will learn with time.

3

u/Ambientmultimedia 3d ago

That's actually a perfect analogy.

1

u/Objective_Suit_4471 3d ago

They have a rule book? Can you inform me of it?

4

u/Affiixed 2d ago

The documentation

1

u/CreativeAlbatross319 10h ago

The rule book is to turn on the static analyzers like clang-tidy or cppcheck.

6

u/vegan_antitheist 4d ago

this is probably the best answer here.

1

u/GreenFox1505 1d ago

I dont disagree with the statement, but is that the best answer for this question to a child aspiring to be a programmer? First day out in the wild and you're here slapping them in the face with cynic nihilism?

1

u/NopileosX2 1d ago

This thread had more than enough serious statements and it is always important to teach the basics. Which are that Programming Sucks and There are only two kinds of languages.

1

u/GreenFox1505 1d ago

This was the top comment though. 

1

u/Illustrious-Fail1951 12h ago

To op most software devs are not actually this guy at all

1

u/pandorazboxx 3d ago

ah, have you met my friend Rust?

11

u/thisismyfavoritename 4d ago

languages are tools. There are tools that are better suited for specific jobs. Python can be a better choice than C++ and vice versa

1

u/Happy-GoLucky365 4d ago

Wow, well this has been some really helpful advice. Thank you to everybody who gave me more insight!

5

u/huuaaang 4d ago

The performance benefits of C++ are real and undeniable, but it's not enough to consider one "better" than the other. Python is good for scripted type things that don't really have to do heavy processing of their own. To have to think about memory management and data types and all that might be unnecessary overhead. Even the ML work people with with Python, which sounds like something C++ would be better suited for, is mainly running compiled code on GPUs. The Python just orchestrating that. C++ wouldn't buy you much.

Python: Faster to write

C++: Faster to execute

5

u/Retsyn 4d ago

You have to chose what the job is before evaluating the tool as "good or bad".

I use both at my work-- When I use Python, I may lament that it can't do hard math or crunch big numbers at high speed, where as the C++ would blast through the big calculations in milliseconds.

When I use C++ I lament that I need digital signatures and compilation to deploy to users, where as the Python ports anywhere and the interpreter just goes.

5

u/pixel293 4d ago

As you get better at programming you will find that the language doesn't matter. You can pick up a language in a weekend. The basics are all the same, they all use math, logic, functions, and sometimes classes. You just need to read a primer on how you declare these things and off you go.

Learning a programming language is not learning to program. You USE it to learn to program, programming is breaking large problems down to smaller steps and thinking logically. When the time comes and the languages you know don't meet your needs, you can pick up a new one quickly as long as you know how to program.

5

u/code29451 3d ago

The people making those jokes don't understand programming languages and are just regurgitating what they read in stupid memes

4

u/_th3oth3rjak3_ 4d ago

Yeah Python is like an automatic sedan with good gas mileage. It’s easy to use, reasonably decent for performance, easy to start up and get going. C++ is like a formula one car. It’s really fast and really dangerous if you don’t know what you’re doing. It’s a complex language with lots of historical baggage. Both are great, but use the right one where it’s needed.

4

u/unlucky_ducky 3d ago

Honestly, people in college classes typically just parrot what they've heard other people saying. Both C++ and Python has their use cases and one is not strictly better than the other.

3

u/Iowa50401 3d ago

Define “better”. It depends on what you want done.

3

u/QuadWingedCrane 4d ago

Google could have been quicker

2

u/No_Winter4806 4d ago

People on Reddit try to use their little reddit minions to answer the most googleable question of all time

1

u/Material_Lion_9554 4d ago

Karma farm

2

u/Happy-GoLucky365 3d ago

The only reason I didnt Google is because im trying to speak with real people who have a clue as to what they're talking about. Even if its just rudimentary questions like this, who better to ask than those more experienced? If i was "karma farming" id want to seriously consider my life choices.

2

u/No_Winter4806 4d ago

And all that for 8 upvotes!

2

u/good_name_0 4d ago

Google results are all ai slop. Least there's some humans in here

6

u/AnonymousGamerAcc 4d ago

Idk what people are yapping about in this thread but essentially what they usually mean by c++ is more powerful than python comes down to how the languages work "behind the scenes".

Python is made to be super simple, fast to use, and readable. Because of this, certain things have to be handled in a very "heavy" way, like for example making every variable a "guess" instead of specified. It also routinely runs a so called "garbage collector" in the background, causing spikes in performance, and lastly, python runs on top of another program, and not directly on the machine. 

On the other hand, languages like c++ are made to have the program itself be pretty fast, not so much the process. In c++ you give every variable you create a specific type (with some nuance), making it so the CPU knows exactly how to handle the variable instead of guessing. And unlike python, c++ runs more or less directly on the machine, meaning it can take full use of it. 

Now this is a kinda short and easy version for an explanation, so if you're more interested you should do some research!

1

u/vegan_antitheist 4d ago

Both are exactly as powerful as all the programming languages, including Brainfuck.
A CPU doesn't know about types. It offers registers. Some are general-purpose registers. On many CPUs you have 80bit for floating point. Some have SIMD registers. C++ gives you several ways to influence register usage, but the compiler ultimately decides which physical registers to use. Python doesn't give you any way to influence register usage because your code runs on a virtual machine that is an abstraction of a physical computer. But both C++ and Python can do way more operations that are required to be Turing complete and can therefore do the same calculations, just in different ways. With assembly you can even say which register to use, but that still doesn't make it more powerful, only faster in some cases.

2

u/Pengwin0 4d ago

More powerful doesn’t necessarily refer to Turning completeness to be fair. Scratch is turning complete. But if I say Python is a more powerful language than Scratch, I’m saying that it is much faster and in a much better ecosystem to actually develop in.

1

u/vegan_antitheist 3d ago

Faster? How much is that in km/h?

1

u/AnonymousGamerAcc 3d ago

Powerpoint is Turing complete. So maybe we should all start using that instead of all these hard programming languages.

1

u/vegan_antitheist 3d ago

Brainfuck is way easier. Just eight simple commands.

2

u/Altruistic-Toe-5990 4d ago

It comes down to the advanced-ness. It's better than Python, but worse than Python++. Google could've answered this for you

2

u/vegan_antitheist 4d ago

Finally...
🧑🏿‍🔬
Python++

(i'd post the actual meme if pics were allowed on this sub)

2

u/Dazzling_Music_2411 4d ago

Rather ask your fellow student jokers.

We have no way of understanding their joke.

2

u/zeekar 4d ago

In general, you can't say "programming language X is better than programming language Y". Different languages do different things well, so the most you can say is "X is better than Y for task Z", and even that is a matter of opinion. I mean, PHP and JavaScript are widely considered badly-designed, but that didn't stop them from taking over the whole web. The language you can run most easily tends to be the language you wind up using.

C++ programs will generally run faster than Python programs because C++ is compiled. When you run a Python program, what you're really running is a program called python - the Python interpreter. That program reads your Python code and carries out the instructions it contains. It's an extra level of indirection between the computer and the code you want to run. C++ (and its parent language C, which Python is written in) has no interpreter; the entire program is translated ahead of time into an executable that the computer can run directly.

This results in a tremendous speed advantage. A simple Python do-nothing loop that counts to 100 million takes over 2 seconds to run on my computer; a C++ program (compiled without optimization so that it actually does the counting instead of noticing that the code doesn't do anything useful and just skipping it entirely) does the same job in 120 milliseconds. But maybe for your problem, speed isn't critical, or is sufficiently less critical that the various Python modules that include compiled pieces to speed them up are fast enough.

There are downsides - a Python program can be fed to a Python executable on any kind of computer and it will run; a C++ program must first be compiled separately for each type of computer (not just Linux vs macOS vs Windows, but also x86 vs ARM...).

Another consideration on the "more powerful" claim is that because C++ compiles to a native executable, the program has full access to everything the computer can do. If needed, you can even switch into writing code in assembly, though that will be even less portable as you'll have to rewrite it for each one of the targets, not just recompile.

From Python, you only have access to things that have a Python interface. Which at this point is most things - if the interpreter doesn't come with one bundled, someone has probably made a module you can install with pip. But with C++ that capability comes out of the box.

2

u/Imagine-Dragons-Fan9 4d ago

All coding languages fall within a spectrum between High Level(Very simple for humans like scratch) or low level(Very simple to computers but complicated to humans like assmbly). Since Higher level languages are less similar to computer logic, they have to do a lot of translating, which is less effecient and takes more processing power. Python is esier to learn because it is high level, but C++ is more powerful since it’s more similar to computer logic.

2

u/Embarrassed-Green898 3d ago

it is not.

Different languages have different purpose.

2

u/Classic-Rate-5104 3d ago

Comparing apples and bananas

2

u/OutrageousCrab9224 3d ago

There is no linear world in which one major language is better than another in every way

2

u/SprinklesFresh5693 3d ago

Nothing is better , its just different, and for different purposes.

2

u/tin2426 2d ago

Many people answered the question. But, what I would like to add. Try not to get too caught up in discussions about what is better than what.

At the end of the day, these are tools. You should choose whatever is best for the problem you are trying to solve.

Good luck on your studies!

2

u/Skibidibob4 2d ago

They are completely different languages tho

2

u/Humble_Anxiety_9534 1d ago

has this question been answered enough times! C++ is a fast to run compiled language. python is a fast to write slower to run interpreter language. C++ gives you binaries that you can run on the machine you compiled for python you have to install python where you run it. python is written in C++ mostly. they are both powerful these days. most of the people who make fun of python, need to keep up. facts not opinions please!

2

u/xarop_pa_toss 4d ago

C++ and Python focus on completely different things. They are built almost as opposite to each other as possible.

C++ is a compiled language and it gives you real control over the hardware to a very minute level. This is both very good because you can optimize a lot but also much harder to use for high-level things.

Python is interpreted instead of compiled and the way it works is a lot more abstracted with layers of things you can't see underneath that let you focus on a different set of things. By design it is very modular and you will more often than not find yourself importing all sorts of libraries a.k.a. modules to perform data analysis or whatever python people do.

The languages focus on completely different types of objectives. If I wanted to write a program that needs to fit in a small chip that controls some machine, I probably wouldn't write it in Python because I need to optimize memory a lot. At the same time, if I wanted to analyze some dataset and chart some graphs, I'd probably just import Pandas and Numpy into a Python program and be done with it.

Edit: if you're interested, Google about the time difference of a basic for loop in different languages and why the difference is so big.

-1

u/vegan_antitheist 4d ago

it gives you real control over the hardware to a very minute level. 

Does it? Compare to Python it certainly does. But it's high level compared to assembly.

 time difference of a basic for loop

I don't think that's a good idea. Beginners just end up on some shitty website written by beginners who don't know shit, or someone just writing to get traffic to sell more ads who also doesn't know shit. And it would be misleading if it claims that it's different. Some Python implementations have JIT and then a simple loop should be just as fast. Too simplistic loops might even end up replaced by a constant by a good C++ compiler. Then the time complexity is literally O(0). You probably don't get that in Python even with JIT. It doesn't even optimise tail recursion as far as I know and the reason is that debugging would be confusing when your recursion doesn't actually do any recursion.

4

u/YouPeopleCantBeReal4 4d ago

Assembly is pretty high level compared to logic gates

0

u/xarop_pa_toss 4d ago

There's always the "assembly is the real low level language" guy isn't there? The post was about the differences between C++ and Python so that's the basis for my comment. Maybe we should all just program with NAND gates...

And a beginner isn't going to understand all the stuff your said and probably not even find it. But there are nice comparisons out there that show clear differences, which leads to other explanations on compiled vs interpreted languages for example. It's not that deep man

2

u/moratnz 4d ago

Given the amount of speculative execution, memory caching etc., that goes on in modern CPUs, no languages are 'low level' in the sense that people generally mean. Even good old C is numerous abstraction layers away from what the actual hardware is doing.

1

u/CowBoyDanIndie 3d ago

Ya, no modern high power cpu runs its instructions set natively, they are all emulated by microcode.

0

u/vegan_antitheist 3d ago

C++ is a high-level programming language. That's just a fact. A high-level language provides abstractions that allow you to express computations without directly dealing with the processor's instructions and hardware details. C++ does that. Loops, variables, types, even simple operators, like a+b, are high-level. The compiler handles instruction selection, register allocation and many other hardware-specific details.

This is a fact and your down vote doesn't change that.

2

u/NotACoderPleaseHelp 4d ago

C++ is closer to the silicon, you have far more control and far more responsibility.

Python is what happens if you decide to make pseudocode into a language. It is the language that is closer to us.

Unless it is being implemented in scale, in a performance critical application or touching the hardware directly you are generally just fine with python.

Hell, if you write it in python and need more speed there are options as well, You can toss pypy at it (if it works) You can use one of a number of transpilers that convert the abstract syntax tree from one language to another language.

0

u/vegan_antitheist 4d ago

That question makes as much sens as "Why is a screw driver better than a hammer?"

C++ is more powerful than Python

This is objectively wrong. Both are Turing complete and therefore as powerful as any programming language.

The jokes are probably about how C++ allows you do write much more efficient, optimised and complex code.

C++ prioritizes performance and control. Python prioritizes simplicity and development speed. Python has less boilerplate, no explicit type declarations, automatic memory management, and a simpler syntax. This means less control and because it's higher level you can't optimise as much when you write code for the python virtual machine, while in C++ you can optimise for specific hardware.

Feel free to give me any tips as well, on things that helped you be a better programmer,

What helps is ignoring those who just make these stupid jokes and instead concentrate on actually learning all the concepts, patterns, tools, methodologies, etc. Programming is hard. But for those who like doing it, it's a lot of fun.

1

u/Happy-GoLucky365 4d ago

It sounds like a lot of the difference comes down to speed and control between the two languages. I guess my next question would be: Does the time difference really matter that much? I completely understand why someone would want more control on their programs, but the time thing is still leaving me a bit confuzzled.That may sound like a dumb thing to ask, but im just trying to learn. Thanks for your advice! I'll happily take it and make sure to keep researching on my own time.

1

u/vegan_antitheist 4d ago

Does the time difference really matter that much?

In most projects it's not at all or very much.

For computer games and other programs that have to do something without delay you need something like C++ or Rust.
Java, C#/.NET, Python etc use automatic memory management. That means they regularly have to "collect the garbage" (free unused memory) and that takes time. It slows everything down. In C++ you can count references or even simpler just free the memory when the method returns. You can also use smart pointers or lots of other ways to manage the lifetime of some data. In C++ you have to know a lot about how you allocate the memory, initialise it, use it, and eventually free it. In Python you don't care that much about it because you can't really influence it anyway. You just try to prevent certain things that make it difficult or even impossible for Python to free the memory. Sometimes it keeps you from writing good software when you have to think about memory management all the time instead of concentrating on your use cases and use experience. In other cases it keeps you from writing good software when you don't have enough control over memory management to make sure it is efficient, deterministic and reliable enough for some real-time application, such as a medical life-support system.

1

u/Happy-GoLucky365 4d ago

This is a great explanation, again thank you! Makes a lot more sense now.

1

u/GlassLost 4d ago

So speed is one thing and it's often important but code sharing, and architecture, also are worth mentioning. C is designed to be "bootstrapped" onto a new architecture, and c++ can be bootstrapped with C (this isn't quite true but it's close, bootstrapping means you only need to implement a few assembly commands before the compiler works) so if you have new hardware you need a lower level language. Higher level languages, like Python, require entire operating systems which are built with C and C++.

So there's a speed difference but just as importantly (and highly related) there is a dependency difference. Python needs quite a bit to ever work. You could get your c code working with less than a dozen lines of assembly in many cases (without access to things like libc though).

1

u/binarycow 4d ago

Does the time difference really matter that much?

As with everything, it depends.

If your app processes real-time data like a phone call, it's super important. Because if you take too long, you've already missed stuff

If your app is a tool that runs once a day, to trigger a backup job (but doesn't perform the backup itself), then it matters absolutely zero.


The app I work on has some stuff where you wouldn't normally think it's a big deal, but because of our use case, it does.

For example, there was a thing that took 10 minutes total. I made one change (caching regexes) that made it take 5 minutes total. That's great - but what makes it even better is that was just my local small scale test. Our customers are running that same task, but 100 times bigger. So their ~16 hour task shrunk to ~8 hours. That's a huge savings.

1

u/Katana_Steel 4d ago

For simple tasks no, the differences doesn't matter. They'll both get the job done at that point it's what's most comfortable to read.

For data processing and large volumes of data having a strict typed language like C++ is usually faster in execution. Which is why the library like Numpy and Pandas are mainly written in C/C++.

1

u/Rythim 4d ago

C++ works out

1

u/atarivcs 4d ago

c++ programs have much faster execution time, maybe that's what they meant by "more powerful".

1

u/beb0 4d ago

It's not it just has more bits and bobs to twiddle and lower level pitfalls

1

u/BranchLatter4294 4d ago

Use the right tool for the job.

1

u/Atmosck 4d ago

C++ is not better (or worse) than python. They are very different languages with very different purposes. It's true that if you write code that does some number crunching in a loop, C++ will be way faster. That's becuase that kind of work isn't what python is for.

C++ is a compiled systems language. It gives you direct control of low-level system stuff like memory allocation, which is both powerful and dangerous. Compiling code can take a while, but that means the compiler can spend all the time it needs to optimize your code.

Python is an interpreted scripting language. With python there are more layers of abstraction between you and the hardware. You lose the low-level control of a systems language, but gain a lot flexibility, safety, and ease of use for it. Interpreted means the code is compiled in real-time while you use it*, which means a faster development workflow with no waiting for the compiler, but also slower code.

As a scripting language, python's job is to be an easy, flexible interface for orchestrating other things. Crucially, it dispatches to compiled extensions written in other languages for performance sensitive things. Much of the python standard library is C under the hood. Python's ecosystem is full of libraries that use extensions written in C, fortran or rust. That slow number crunching loop that's way faster in C++ - the right way to do that in python is to use a library like numpy and it's vectorized functions instead of a python loop, and you'll get similar speeds.

*(The python interpreter really uses a two-stage process with an intermediate representation called bytecode. Typically, the first stage is compiled to bytecode ahead of time - that's what a .whl file is. Then the python virtual machine does the second stage - translating bytecode into machine code - in real time.)

1

u/hasanyoneseenmyshirt 4d ago

it not better or worst. it just means has different uses. If I wanted speed, lets say if I was building a HFT algo, I would use C/C++. if I wanted to prototype a simple program, it would be much easier for me to write a quick and dirty program in python, like if i wanted a simple web scrapper. Most python libraries are written in C/C++ if they are computationally heavy, I think you can do operation on NumPy arrays faster than native Python lists but do not quote me on that, so you get the best of both worlds of easy syntax to low level performance. I bet people think assembly language is better that C++ because it the closest thing to actually writing in machine code.

In the end of the day, it really just matters on what you plan on doing and what tools/langauge you feel most comfortable with.

1

u/Reasonable_Slide6304 4d ago

Python is like you're driving car and can only sit on the driver's seat, you have the pedals and stuff to fiddle with and they do things, but you don't really know what's happening in the engine space.

In C/C++ you open the hood and fiddle with the engine and see what happens there, the downsize is that some of the car controls might be missing and you need to build them yourself, but you have intimate knowledge on how they are connected to the engine and can also improve how they work.

I think in python some functions use C/C++ without the user knowing just to get better performance, performance being memory usage and more efficient use of CPU cycles.

Now a days as computers are really performance you don't really notice the difference with some basic programs, but if you need to make something massive and performance then python is like driving a tractor on a freeway, it moves but people aren't happy about it being there.

Also if you're ever interested in integrated systems where memory and disk space can actually be very limited, using the hardware in the best way possible requires understanding memory usage and the processor architecture.

In python the languages deals with the memory, in C/C++ you're the one handling reserving and freeing it.

1

u/Sad_Quote1522 4d ago

The simplest explanation is Python is slower.  We live at a time where this doesn't matter much for hobbyists and many real world applications, but for the few times where it does matter python feels sluggish compared to C++.  

On the other hand Python is easier to use.  I'm assuming in the workplace AI has pretty much bridged the gap between the difficulty of different languages but if you are coding by hand C++ gives you more control, but therefore more ways to screw up.  

1

u/da2Pakaveli 4d ago edited 4d ago

Each one has its use case. C++ for highly demanding systems, such as game engines. Python is convienent for data science related applications (although the libraries are often C/C++ under the hood such as Pytorch) cause you don't need to deal with the "burdens" of C++. The interpreter is great for interactively working with your data without having to recompile the app.

1

u/notactuallyme93 4d ago

A fluid-fueled rocket engine is far more powerful than a four-stroke petrol-engine, but for some reason most people still use the latter in their cars, those pathetic losers! Some even ride a bicycle instead of a car, or indeed a rocket powered missile.

Of course as students just beginning to learn something, you should absolutely use the most powerful thing ever - anything else would just be silly. I mean, you don't start in kindergarten digging in the sand with a shovel and bucket do you, when the much more powerful Liebherr R9800 exists! Every child should drive one of those!

Sarcasm aside - every language is different, C++ has been designed to be extremely close to the hardware, especially suited for applications where every clockcycle counts, and where you, the programmer, wants or needs to be in charge of exactly what happens to your memory, which registers are prefered, what kind of operations the CPU selects, and so on. As close to machine language you can get, without going into assembly. Python is designed to be extremely quick and easy to write applications that handle arbitrary collections of data in various ways, and utilize a lot of different libraries to offload the details from the mind of the programmer.

"Powerful" doesn't mean anything, unless you decide who gets that power to do what. You become more powerful as a programmer in Python, because it lets you write better code. You can be more powerful in C++, because you can access hardware directly. You can write less powerful programs in Python, because they might compile to less efficient code. You can write less powerful programs in C++, because you don't know what you are doing, and have to take care of everything memory and performance-related yourself ... so ...

No school with any amount of self-respect would try to teach C++ as the first programming language, and no student would ever write any software throughout their entire educational career, where the difference between languages would be noticable in the final product.

1

u/Boot_Burner 4d ago

They're entirely different toolkits. One isn't inherently better. C++ might be more challenging to learn but that's because it's a lower level language than python.

1

u/Electronic-Equal-616 4d ago

c++ is mostly considered more powerful because it runs way faster and gives you direct control over memory and hardware. python handles all that in the background, which makes it much slower, but ten times faster to actually write and learn. neither is objectively better, they just have completely different trade-offs.

1

u/Difficult-Tutor7855 4d ago

Firstly, you need to understand that a programming language is created as solution to particular problem(s). So, each programming language have its strength area. New solutions always emerges from inefficiencies of existing solutions. No programming language was created out of boredom or because one language is simply too old. it will interest you to know that most Banks still rely on FORTRAN till this day despite how old FORTRAN is. Different programming languages exists for different purposes. However, C++ is the languages that created most languages today and all modern languages are inspired by C++. and like all other languages, C++ has its limitation as well. This is how you look at programming languages

1

u/peterjohnvernon936 4d ago

Python is easier to learn and easier to use. C++ runs faster but it takes longer to develop a C++ program. If your program is dealing with a lot of data or processing and needs to be fast then use C++ otherwise use Python.

1

u/dlamblin 4d ago

There's actually many different Pythons, and IIRC several different C and C++ systems. So... The default Python releases are CPython, which just kind of illustrates how C is often more broadly available for an architecture and is preferred to bootstrap a lot of other systems in, though, yes, most compiled languages aim to get to the self-hosted state where they build their own source. I had some hope that Grumpy would seriously try to take up Python 3, but I believe it exists to possibly run some of the py 2.7 code inherited in the YouTube acquisition. And ended up not being too successful at that long term. GitHub - google/grumpy: Grumpy is a Python to Go source code transcompiler and runtime. · GitHub

Neither is better. Each language out there, generally, exists for a purpose where it made more sense to have a new language than to twist the other available ones into the purpose. Not that they don't change, grow, then overlap and get blurry here and there. Learn at least beginner level of a few languages, particularly if they're different paradigms, so that at the start of each project you have some idea of whether you're picking the right toolset for this project.

1

u/coder155ml 3d ago

You’ll learn

1

u/Familiar_Kale_7357 3d ago

Because IT won't allow me to install Python on their servers.

But what's really great about Python is I can do a sloppy proof-of-concept in Python and know that nobody's going to tell me to polish it up and ship it, cause we can't ship Python. That's gold.

1

u/Still_Membership2640 3d ago

I wouldn't say C++ is necessarily better than Python. They both have different strengths and use cases. C++ gives you more control over memory and hardware, making it great for performance-critical applications, game engines, embedded systems, and system programming. Python, on the other hand, is much easier to learn, has simpler syntax, and is widely used in AI/ML, automation, data science, and web development.

My advice would be to focus on mastering programming fundamentals first rather than worrying about which language is superior. Learn data structures, algorithms, problem-solving, OOP, and how things work under the hood. Once you understand these concepts, switching between languages becomes much easier.

Python is a great starting point, and learning C++ later can give you a deeper understanding of how computers work. Don't fall into language wars; a good programmer knows how to choose the right tool for the problem!

1

u/xpusostomos 3d ago

They're both terrible, but at least C++ is fast. Python is supposedly good at quickly throwing together a script.

1

u/sswam 3d ago

Why is C++ better than Python?

C++ is not better than Python. C++ is a horrendous mess of a language, Python is relatively well designed. If you want something more performant, try C, Go, or Rust, all of which are better designed than C++.

1

u/k1v1uq 3d ago edited 3d ago

As everyone else has already pointed out, it depends on what you're trying to do.

C++ is definitely better suited for direct memory management.

Suppose you write a password generator. You have to make sure the password is wiped from memory after the program terminates. You also need to ensure the machine doesn't spill that memory to disk (due to memory pressure, i.e., swapping), which could expose the password as well.

Unlimited memory access is what makes C and C++ stand out. Only Assembly gives you more direct access. But the power of C and C++ comes with a price: managing memory ownership by hand does create new security risks.

https://github.com/openssl/openssl/pull/33652

Python OTOH - Go, Java and many other languages - come with memory management built in or impose strict rules around it (Rust).

People choose Python for ease of programming (data engineering, machine learning), and C++ or C for critical code paths.

1

u/cthulhu944 3d ago

In the world of AI programming, I don't think this is the case anymore, but here goes it.

C++ is a very powerful compiled system language. It is compiled and has strong OOP capabilities while still having access/control of lower level, machine level constructs. With that power comes great responsibility. You have to watch what you are doing with memory allocations and some of the higher level operations and data structures are a bit awkward.

Python is a ubiquitous interpreted language. If there is anything like a cpu in it, there is probably a python interpreter for it. It has a robust standard library and is generally easy to learn.

Both are fantastic, powerful languages and the each have their pluses and minuses. If I were developing a real time embeded system, an operating system or a graphics intensive game, I'd probably pick c++. If i were writing just about anything else I'd probably go with python.

The important thing is that you pick the right tool for the job based on the problem you are trying to solve. There isn't an ultimate programming language. Be good at programming, engineering, and computer science. If you manage that, the language will sort itself out.

1

u/_4rcadia 3d ago

TL;DR

It is not. They are for different scenarios. However, as a beginner, starting with Python will be more comfortable.

1

u/qwyss 3d ago

Because americans do not pronounce it funny.

1

u/mredding 3d ago

I hear people make a lot of jokes about how C++ is more powerful than Python, and should be used instead. But why?

It's a meaningless claim. It's just not useful. They're both Turing Complete, so by definition one cannot be more powerful than the other, both can implement each other. The theory of computation does not care about reading, writing, or executing programs. It's all the same.

Python is interpreted, so there's a runtime cost. C++ runs on bare metal and doesn't have to pay an intermediate tax of interpretation before operation. Fine. But WHAT IS the cost..?

Python gets about 80% of raw C++ compute speed. This is because 90% of all Python modules are themselves written in Python, 3% are written in C, and 7% are written in C++. And BOY... That last 10 percent represents the foundations of all Python performance. Almost every other module is implemented in terms of that 10% either directly or indirectly. Ultimately what's happening is Python is offloading as much heavy compute and instructions to the C++ modules at a time as possible, so it really minimizes how much overhead is required to orchestrate the modules, and there's a minimum of marshaling data over boundaries.

So they want to flex for 20%? I don't care. I'm principally a C++ engineer myself, I've worked in trading systems, video games, cloud infrastructure, databases, and robots, and python is plenty fast for all of that. That 20% isn't nothing, and sometimes you want that, but to choose C++, you need some other technical requirement that makes it a better fit, or maybe you're working on a mature platform older than Python; you don't just migrate entire code bases on a whim unless you're a Rust engineer.

1

u/Paxtian 3d ago

It's inaccurate to say C++ is more powerful than Python, because both are Turing complete, so anything you can build in one can be built in the other.

That said, C++ gives you much more direct control over what's going on under the hood. So if you need to build something that needs to operate as fast as possible, you'd choose something like C++ or C or Rust.

The downside is, then you as the code author are responsible for handling memory management. Python can take care of that for you. Also, Python has an absolutely massive library of packages, so you can just add them to your package and stitch their functionality together.

But that might lead to bloat if one of those packages depends on 20 other packages to do what it needs to do. So you might prefer to use C/C++ and just implement the specific functionality you need as your own distinct set of packages.

But THEN you need to learn about proper header files and Make and makefiles. So you might say screw it, I'm learning Rust. But THEN you need to learn lifetimes and the borrow checker and async. And that takes a long time and it's a pain.

So then you just learn Java and deal with its cumbersome syntax.

1

u/MasterpieceNovel3619 3d ago

It's much faster (pre-compiles, whereas Python compiles "just-in-time"), has been developed more, and the fact that you have to manage the memory of your variables leads to better understanding and better programming practices.

1

u/AlbertoBigglesworth 2d ago

Why is orange juice better than salt?

1

u/Holiday_Finding_ 2d ago

Compiled languages translate the entire source code into native machine code before execution, resulting in fast execution speeds but platform-dependent binaries and a slower development cycle due to the compile step. Examples include C, C++, Rust, and Go.

Interpreted languages execute source code line-by-line at runtime using an interpreter, offering high portability and rapid development but suffering from slower performance because translation occurs during execution. Examples include Python, JavaScript, and Ruby.

Bytecode represents a hybrid approach where source code is compiled into an intermediate, platform-independent format (bytecode) that runs on a Virtual Machine (VM). The VM typically interprets this bytecode or uses Just-In-Time (JIT) compilation to convert "hot" code paths into native machine code for better performance. Examples include Java (JVM) and C# (.NET CLR).

1

u/Iron_Man652 2d ago

It heavily depends on what you want to do.

1

u/Yarrowleaf 2d ago

Different languages for different things, python is great for back end and scripting and little projects, c++ I use for embedded, don't really like anything else or have needed to for what I like to do. Use whatever you like for the things you like doing

1

u/Medo-2002 2d ago

i think because old than python

1

u/veronique637 1d ago

Try a tiny program in both: make it work in Python, then remake it in C++ and compare what you had to specify. That makes the tradeoff concrete.

1

u/onlyhumaninthehouse 1d ago

In college learn everything. Learn C++ even more because you will not get opportunity to work on it. Learn Python because even kids know it now a days. Learn Rust because that will help humans against AI in future.

1

u/paralepsy 1d ago

as barney starsoup (creator of c++, source: trust me bro) once said: "there are only two types of programming languages; the ones nobody uses, and the ones everybody hates"

1

u/Either-Name-6285 1d ago

Neither is worse or better but as a first year student, C++ made python easier to learn for me

1

u/OldSchoolCSci 1d ago

As many people have written here, "better" depend on your task and context.

However, if the context is "learning programming from the beginning," Python is a good choice because:

  • it is built to be simpler and more readable;
  • there is a robust standard library;
  • there are free compilers and tools available for schools

I actually had this debate with my son's high school when he lwas taking the intro classes, and they were using Java - which I think is a poor choice for an intro class. His college classes started in Python before moving to C. Intro programming students need to learn the fundamentals without getting bogged down in complex syntax and indirect programming techniques that are often hard for beginners to understand. Once you've learned those things, you can pick up a new language without difficulty. But if you're lost in a "too many rules, too many options" environment, you won't learn the basics well.

1

u/trajtemberg 1d ago

At work we use to prototype in py and deliver in cpp. Nowadays it's all done in Go, even when asm or c is involved.

1

u/Small-Dig-8233 1d ago

just comes down to the access each language gives to u. python keeps things simple by NOT handing u dynamic memory allocation to solve problems related to double freeing, hanging pointers, accessing after freeing kinda errors instead the interpreter does the job for it.

python or really any other interpreted language like JS has this program called a garbage collector and in a nutshell it scans the object tree from the root and what ever is not traced to the root it is freed and now a days its not like this anymore but there are still garbage collector pauses in a program.

C++ is not jst fast but consistently fast AND predictable like a GC pause on python is rare but even a 2ms pause on a physics sim or a kernel can throw things off real quick but in C++ u know EXACTLY when ur freeing memory and how ur freeing memory so everything stays predictable.

now with python around u really dont need C++ for EVERYTHING like prototyping or jst using python as a scaffhold while ur real important code runs in C++ (numpy and pytorch) that is totally fine and its used in machine learning too.

TLDR: the answer is not a clear line that divides python from C++ cleanly saying python is bad and C++ good or vice versa but each has its use case.

1

u/MpVpRb 1d ago

Python is great for quickly creating stuff.

C and C++ run faster, but require more skill to use.

1

u/heisthedarchness 23h ago

"More powerful" does not mean "better" -- and either of these languages could be seen as more powerful than the other depending on context.

Engineering is the discipline of trade-offs, of using the right tool for the job and building a better tool if none that exist have the characteristics you need. We don't have a variety of tools because some are better or worse. We have a variety of tools because we confront a variety of problems.

C++ is better than Python at some things (mostly having to do with efficiency). Python is better than C++ at some things (mostly having to do with safety and portability).

For purposes of learning how programming works, Python is great because it hides a lot of the details of how a computer works. But no one who is serious about the field stops at just one language, just like no carpenter uses only one tool.

1

u/et_theextratestic1e 22h ago

There is no such thing as a programming language that is better than another for every situation.

You're comparing apples to oranges - yes they're both fruit, and that's where similarities stop.

Think of it this way: you can write Python modules in C++, but to do the converse is simply perverse (and very slow). Data scientists like Python because you need to know far less than you do compared to C++. This is normally true when comparing scripted languages to compiled languages (think portability, memory management, etc).

1

u/Wowie-Zowieee 19h ago edited 18h ago

C++ is better than Python in the same way that an airplane is better than a car. Airplanes fly faster than cars, but cars weren’t built to fly in the first place. It all depends on what you need.

C++ was made to be fast and efficient, whereas Python was made specifically to make programming easier. Speed was never the goal for Python.

1

u/bearpaw- 10h ago

Cpp is powerful for being able to do pretty much everything, but it doesn't mean that it is the best tool for every task. Cpp code gets nasty and soon becomes a mine field and you would spend a huge amount of time dealing with landmines. I would prefer Python if I have to focus on algorithm, data, app development. By the way Rust kinda provides pros from the both world, you can use it in a python way (good readability, not as good performance) or Cpp way (performance first)

1

u/BasilKatz 8h ago

Depends what you are doing, I think python is a great general purpose programing language. Lots of people use Java in industry for internal tools or C# and Microsofts .NET framework. I have a friend who programs interfaces for people to interact with large industrial machines.... in UNITY(A Game engine) with C#.

I really love C for programing microcontrollers, It is just a great simple language, but it is by no means the best tool for everything.... it is probably the best tool for very little of what i do, but i like it.

1

u/Fine-Comparison-2949 4d ago

It's not "better" or "worse", and anyone who tells you that really doesn't understand computer science since there are multiple facets to what could be better or worse.

So, C is typically seen as the best for speed. The C compiler assembles the code into machine code, so when you build a C program, it's as raw of a file as you can get in terms of optimization.

Python is "interpreted". You can search this up, but it has it's own Python Virtual Machine, that reads python code (and it's bytecode) and runs it. The virtual machine is somewhat wonky since it's not exactly the same as assembled machine code.

This is also somewhat goofy, because most python code that is dependent on speed, actually wraps C code. The joke about python is it's a C wrapper.

In the end though, most of the speed arguments are silly. For 90% of code, the bottleneck is network speed. Faster code in general does not mean your whole application is fast.

0

u/blahthebiste 4d ago

Also, modern computers are millions of times more powerful than what existed back when C was the hot new thing. Saving 4 bytes of memory matters a whole lot less when the average smartphone has multiple gigabytes available.

1

u/Kajitani-Eizan 3d ago

Certainly not literally millions

And while taking up 20%, or even 100% more memory than what was available back then is no issue nowadays, bloat can grow faster than hardware capabilities if people are not careful. We have literally 1000 times more memory nowadays compared to 30 years ago. We are not doing 1000 times more stuff than 30 years ago.

1

u/blahthebiste 3d ago

A gigabyte is 1 million times bigger than a kilobyte. Computers DID have kilobyte memories at one point.

>bloat can grow faster than hardware capabilities if people are not careful.

The thing is, using C or another lower level language doesn't really prevent this. In fact, most higher level languages are built to manage memory pretty efficiently these days.

1

u/Kajitani-Eizan 3d ago

You said "more powerful", which generally refers to processing power and not memory. Unless you think we had ~3 kHz processors back in the 70s

Using a lower level language generally does prevent this, because users of higher level languages or frameworks generally think or care less about this issue and just do whatever assuming they have infinite memory. Electron is a great example of this

1

u/Fine-Comparison-2949 3d ago

Just download more RAM.

1

u/Qwsdxcbjking 3d ago

If you're planning to run your code on an actual pc. If you want to do embedded stuff it can get pretty strict pretty quick on size and memory requirements.

1

u/blahthebiste 3d ago

I work in embedded stuff, and yeah we still use C for some things, but I don't have to like it

1

u/Qwsdxcbjking 3d ago

Personally like it, but totally get not liking it lol, and for pretty much any other programming realm it's not really needed anymore like you said before.

0

u/johlae 4d ago
Hello! I am new to programming.

That's why. C++ can do a lot of things more efficiently than Python, and Python can do a lot of things more efficiently than C++.

It's up to you to figure out when to use what.

0

u/FuggaDucker 4d ago

Python is written in C.
Could have easily been C++.
Think about that.

0

u/flumphit 4d ago edited 4d ago

C++ runs more efficiently than Python, around 100x faster.

Lots of the stuff you might do in Python does all the time-consuming work inside efficient libraries, which are probably written in C++ or C. Often you’ll wind up writing slow Python code to shuffle data between fast libraries, but overall your program spends all its time in the libraries, so it doesn’t matter that your Python is slow.

Python is Turing-complete, meaning you can write any program in it, just like C++. Python is slower, which you don’t usually care about. And Python is loosey-goosey and dwim which makes development faster — until your program gets big enough that you want the compiler rigorously keeping more details straight for you.

0

u/geks8 3d ago

Give C a try, that is true programming

-2

u/ninhaomah 4d ago

And OP never replies to any of the posts.

Sorry but this looks like a ragebait post to get human traffic to reddit.

Ask "Why is AI good or bad ? I am very new to AI . Pls help."

And you will get tons of training data.

2

u/Happy-GoLucky365 4d ago

Im sorry, im genuinely confused? Are you replying to something? I always reply to any post I make. And ragebait? This shouldn't be enraging, im just asking a question.

-2

u/ninhaomah 4d ago

Ok my bad., I see you reply to some of them 35 min ago but when I see this post before that I see people replied to you 2 hours ago but no replied from you.

Your post was 2 hours ago and u/codetomanagement and others replied 2 hours ago. but your earlies reply I see is 37 min ago.

so for more than an hour , no replies from you.

1

u/MudFrosty1869 1d ago

"My dad could beat up your dad" in programming. Never gets old.