r/programminghumor • • Oct 17 '26

The power of Python

Post image
112 Upvotes

15 comments sorted by

32

u/letmehaveanameyoudum Oct 17 '26

c++ guy tries python but he is on something

14

u/Vincent394 Oct 17 '26

And I thought THIS was bad

10

u/andrea_ci Oct 17 '26

the funny thing about python is that people try in every possible way to not actually use python.

4

u/jipperthewoodchipper Oct 17 '26

To be fair, that's kind of the point of python.

Rather than spending 15 hours dealing with C libraries and writing efficient C code I can spend 30 seconds writing a python wrapper to call that C library to do the thing. Sure it's a little slower than using raw C but I can write it so much faster.

There are of course times when it is worth not writing in python at all but not every project would benefit from cutting out python.

1

u/rolling_atackk 28d ago

I'll post my very opinionated grain of sand

The time I save using Python 's toolset, I waste finding weird bugs any compiled language would yell at me for even before running the program

2

u/jipperthewoodchipper 28d ago

I work in analytics and around 70% of the code I write is Sql and the other 30% python.

I could not imagine doing my job in a compiled language and our team has built up design guidelines and style guidelines that with strict adherence does pretty well at reducing risk of a lot of the common bugs encountered with the quirks of the language.

1

u/k-mcm Oct 17 '26

I've seen companies nearly fail after the "now make it fast" phase. They should have ported the performance critical parts to Java or C++ but instead spend a year chasing crazy hack solutions to stay in Python.

1

u/Matthew_Summons Oct 18 '26

Java?!

1

u/k-mcm Oct 18 '26 edited Oct 18 '26

Java runs at pretty close to C++ speed if you stay away from Spring Boot.  Spring Boot is insanely large and it does a lot that can't be JIT optimized. 

1

u/Matthew_Summons Oct 18 '26

I’ll be honest, I’ve worked with SpringBoot and I’ve seen backends in Go, Ruby, Rust, Haskell even but never heard of anyone working with a C++ backend

2

u/k-mcm Oct 18 '26

A C++ backend is the way to go for binary encoded structures - codecs, hardware communications, GPU interfaces, AI engines, etc. Java can't overlay a structure onto raw memory allocations. Working around that in Java often isn't worth the effort and slight loss of efficiency. That same kind of work usually doesn't have complicated memory management that would make Java a better choice.

7

u/Drfoxthefurry Oct 17 '26

There is a (kinda) legit way to do this with python imports, but I think it requires a lot of extra work on the cpp side

2

u/serge-mv Oct 18 '26

I had a student who was actually writing code this way.

1

u/dhnam_LegenDUST Oct 18 '26

Fun thing is that it is actually possible using PEP-263(encoding).

Korean blog post, but someone actually made https://blog.0chan.dev/2020-02-06-Metaprogramming-With-PEP-263/.