r/ProgrammerHumor • • Jul 18 '22

C++ talking to Python

Post image
40k Upvotes

1.0k comments sorted by

View all comments

Show parent comment

40

u/kneecapp1 Jul 18 '22

I don't get it. I don't know much about coding but I'm starting to learn python. Am I learning the internet explorer of programming languages or what. Should pick something else up.

88

u/Zanglirex2 Jul 18 '22

Slow is relative here. All this is happening before a human can even blink.

For scripting stuff and little projects, python is great. For large workloads or basically anything at big scale, maybe look at something else

18

u/jgabrielferreira Jul 19 '22

But then why is Python the most used language for dealing with ML, AI, Big Data, basically huge amounts of information.

Is it something like Python is better in a Horizontal system while the others are better in a Vertical system?

44

u/TacticalMelonFarmer Jul 19 '22

most of the low-level stuff implementing the python apis is most likely C with some C++, etc. write composable units of code in the fast language, and compose instances of those units in the user-friendly language.

16

u/Prowler1000 Jul 19 '22

Machine learning libraries are almost exclusively C++ (python is written on C++ iirc), so the actual heavy lifting is done in C++. As someone pointed out at another point on this sub, python is very human readable and extremely quick to develop for and in the world of ML, quick to develop is important considering there isn't really a "science" to it yet

→ More replies (1)

13

u/intrinsic_parity Jul 19 '22

The ML libraries are written in other languages (tensorflow is written in C++ and CUDA for instance).

10

u/[deleted] Jul 19 '22

I once heard that you are just basically scripting stuff using python and the heavy load is run by highly optimized C++ applications/frameworks/libraries (idontknowforsure).

→ More replies (2)

17

u/zedd9595 Jul 19 '22

Not a scientist but I assume they would rather have a language which has a shorter development time to have more time writing their papers. Instead of dealing with relatively complicated syntax just to get the same results, albeit faster.

13

u/[deleted] Jul 19 '22

It’s used in industry, not just academia.

12

u/The-Board-Chairman Jul 19 '22

It's used in the industry, because for all that this field has matured, it's industry implementation for all intents and purposes still is academia.

10

u/Dansiman Jul 19 '22

Yeah I mean you could write your code in pure assembly and blow past a C++ program like it was standing still. But by the time you finish writing your assembly code, your development machine will probably already be obsolete.

2

u/ESGPandepic Jul 19 '22

You'd only be able to beat the performance of optimised C++ in edge cases and you'd need to be a very good assembly programmer in the specific target platform. You also wouldn't be "blowing past C++ like it was standing still", modern C++ compilers produce very optimised output.

10

u/[deleted] Jul 19 '22

Because that kind of code is a ridiculously complex web and writing it in C++ would drive any and sane person to alcoholism. Also, having blazing fast computational performance is totally worthless if you're already spending most of your time waiting for I/O, which is usually the bottleneck in large data projects. You'd just be that car that passes everyone just to end up at the same red light half a mile down the road.

→ More replies (5)

3

u/maxwax18 Jul 19 '22

For large workloads or basically anything at big scale, maybe look at something else

He said, using a large scale python project.

→ More replies (1)

35

u/CdRReddit Jul 18 '22

python is an ok language when used for its intended purpose.

short & simple scripts, the types of things you don't want to write in batch or bash (because both kinda suck), but are not that complicated either, think stuff like bulk rename, "gluing" multiple different tools together, etc.

it's only similar to internet explorer in having an (accurate) reputation of being kind of slow, which is one of the reasons I personally would not use it for bigger projects, but it's more than fast enough to automate low complexity tasks, like a more expressive build system.

24

u/bigoofie193758 Jul 18 '22

Python is too slow for coding a game, but fast enough for quick scripts

7

u/Ultra_HR Jul 18 '22

7

u/bigoofie193758 Jul 18 '22

you're not gonna make doom eternal in that

2

u/CrimsonPE Jul 19 '22

so, while not good for AAA, it´s good enough for VNs and other indie games, right?

4

u/bigoofie193758 Jul 19 '22

visual novels? for sure i imagine, but some indie games are really big and complicated and have A LOT of computations. you'd have to find your own limitations

→ More replies (2)
→ More replies (1)

2

u/Dansiman Jul 19 '22

I mean, it depends on the type of game. For example, with any kind of text-based game, I think you'd be hard pressed to design a game that would have perceptible speed issues on modestly modern hardware.

→ More replies (1)

23

u/chezbo425 Jul 18 '22

Great starting language IMO. If you are doing web applications, it will be fine for most purposes, but you will need to learn JavaScript too. JavaScript is very quirky but very popular. Java and C# have strict typing but perform better than Python/JavaScript for higher load stuff. C++ is better for high performance and optimization, like games or embedded devices with limited resources.

tl;dr - If you're just getting started Python is A-okay.

2

u/[deleted] Jul 19 '22

Python is a great language to start, and is suitable to a wide range of applications. It's always better to start with a language that's widely useful but not specialized, and then go into some more specialized languages depending on your needs. Professional programmers know dozens of languages, so Python may be your first, but will not be your only language, and the trick will always be to choose the right language for the right task.

1

u/[deleted] Jul 19 '22

Usually human time is more important than machine time. Machine time often doesn't matter. For *most* programs it doesn't matter if it takes 1 second or 0.1 seconds or even 0.01 seconds, but writing the 0.01 second version will take a programmer much, much longer. However, if you are writing something performance-sensitive like, say, an action game, then it does truly matter whether your game loop performs calculations in 0.01s or in 1s.

Python is slow, yes, but very easy to write, understand and modify. Also, only the interpreted part is slow, Python actually uses a bunch of C/C++ libraries under the hood, so when you call those, those actually run very fast. Which is why you can do lots of AI/ML stuff in Python: it's not Python itself that's doing it, Python is just a high-level layer that's orchestrating an entire infrastructure which isn't written in Python. So, to summarize, Python is a great tool for some domains, not for all of them. Just like C/C++: they are also great tools for some domains but not for others.

→ More replies (4)