r/AskProgramming • u/Blazej_kb • Aug 27 '26
Python For what purposes is python useful?
Where is it more convenient or necessary to use python instead of for example C# / C++ / Rust? I really can’t understand it, for me it’s easier to write in C++ than in python and I know that for other people it’s the other way around. But ignoring human factor, when program is better / faster in python than in cpp or are they things that python can do that cpp cant?
Edit: I don’t talk about one time use scripts or prototypes (which python is good for), I mean full on apps
0
Upvotes
7
u/Old_County5271 Aug 27 '26
It's more difficult to get a Segfault on python than C, but compared to rust? Probably nothing, if anything, due to type safety rust/c#/go is overall better.
6
u/huuaaang Aug 27 '26 edited Aug 28 '26
Python would be more for smaller scripted tasks than applications. IF you are more comfortable in compiled languages, just use that.
That said, Python might have some specialized libraries that you can't easily get in other languages and would have to write it yourself. This is mainly why Python is so popular in ML. It's not that it's a better language for it. It's just that the ML libraries for Python are so mature.
25
u/turn-based-games Aug 27 '26
C++ fast. Python convenient. If it is truly easier for you to write in C++, then Python is useless to you, although that is quite a bold claim from my experience with both
26
u/CorpT Aug 27 '26
Why ignore the human factor? Why not just write in assembly?
4
u/Knubbelwurst Aug 27 '26
Generally i use python for quick and simple scripting that I don't want any setup or compilation for.
It's a perfectly fine language for when performance is not important.
3
u/StaticFanatic3 Aug 28 '26
When is it more convenient?
Almost every single time.
Even if you “ignore the human factor” your agent can make the exact same function in Python in 1/4 the tokens
5
u/FarYam3061 Aug 27 '26
It's great for people who only know python.
2
u/Dorkdogdonki Aug 28 '26
I use Python for automation purposes where performance isn’t an issue at all, and i just need it to work reasonably well. That’s it.
3
u/brazen768 Aug 28 '26
Its great for ai/ml. There is a library for everything.
When I was connecting a local llm to my python app, instead of using fastAPI they already had a library on the repo lmao. Literally like 3 lines and im moving. Pretty cool(i hate reading python tho)
1
u/Agreeable-Scholar916 28d ago
to make websites because reddit, instagram,netflix are built in python
1
u/BranchLatter4294 Aug 27 '26
It's more about the libraries than the language for the most part.
1
u/Interesting-Way-9966 Aug 27 '26
🐍🐍🐍🐍🐍🐍
1
u/itemluminouswadison Aug 28 '26
the availability of libraries. the language itself is whatever
1
u/TryingToGetTheFOut Aug 28 '26
On the technical side: python is very flexible, and a lot of big libraries are implemented in C, C++, rust, etc. So, python becomes a kind of remote controller for C code.
On the business side: python has one of the smallest Time To Market. A lot of time, having the best product is not nearly as important as being first. So using python instead of C++ might mean a slower app. But much much faster and cheaper to create.
1
u/Brok3nHalo Aug 28 '26
In general it’s easier and cleaner to write almost anything in Python than the languages you mentioned, especially C++. I don’t have much experience with C# or Rust so most of this will be in comparison to C++.
The syntax is clean and designed to do a lot of things with very little code. It gets rid of a lot of the bootstrapping and cruft you have to do with those other languages.
Creation and cleanup of variable is managed and simple without having to use a bunch of archaic special types to handle it.
Its language features make reading and manipulating data super simple compared to C++. Dealing with JSON or YAML is practically native. File IO and database stuff is also seamless and simpler than other languages.
Its string manipulation is top tier with full support of Unicode.
Threading, is stupid easy in Python, due to the GIL you don’t have to worry about any of the usual memory manipulation issues you do in other languages.
Doing anything web or otherwise network related is super simple. Tons of easy to use libraries for consuming or creating APIs for example. Or just generally building http posts and gets.
The language itself is one of the most flexible available. With everything being an object and manipulatable at runtime you can do some interesting stuff not possible in languages like C++. Testing and dependency injection are also super simple because of this.
Since the language doesn’t need to be compiled there’s almost no down time between coding and testing your code. And generally ultra portable so you can write code and have it run without modification on different operating systems.
For around 6 years my job was on a team developing a large scale multi protocol instant messenger/email/social networking client called Digsby. It was largely in Python with some C or C++ on occasion for parts that needed to be more efficient or run without the interpreter. It was definitely much easier to initially write and maintain in Python than it would have been in C++.
I also built a continuous integration system in Python between an enterprise code repository management software and XCode server using Python.
Really Python is not a bad choice for applications as long as speed isn’t a limiting factor. I’d never suggest writing a game in it, but it’s plenty fast enough for most standard UI desktop apps and web backend use cases.
1
u/Adorable-Strangerx Aug 28 '26
It is general purpose language so you can use for whatever you want..currently it is quite popular with AI and Data Science.
Everywhere where squeezing performance and memory management is not an issue/requirement.
Interesting, good for you.
Ignoring human factor, assembly is best.
Have you ever written any app with complex domain?
1
u/Beneficial-Neat-6200 Aug 28 '26
Many python users I know cite numpy as a primary reason
1
u/ConsciousBath5203 Aug 28 '26
It's the second best language for everything. That's about it lol
-1
u/Ok_Pirate_2714 Aug 27 '26
It does an excellent job of pissing me off when I leave out a space somewhere, or accidentally use a TAB when I shouldn't have.
0
u/naemorhaedus Aug 28 '26
lots of things. It is very strongly portable and cross platform. Easy to learn. Abundant libraries and community resources available. Obviously it doesn't replace C++, but it complements it nicely.
for certain tasks it's probably quicker and easier to get off the ground.
then No. That's not what it's for.
0
u/karurosagu Aug 28 '26
Python is all about development speed, because it's a scripting language, and scripting languages use an interpreter rather than a compiler, it's easy to work fast with an interpreter
You can make anything in python but at the same time you should NOT try to make anything in python (JS didn't get the memo on this one btw)
That said, there are lots of hacks and legit ways of making python way faster than it is by default, such as automated transpilations/optimizations to faster languages, LLVM stuff and JIT interpreters; obviously these solutions have their catch and won't make the code as fast as C/C++ but the performance boost is still insane
But speed isn't everything, there's tons of packages for almost anything you want