r/AskProgramming • • 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

42 comments sorted by

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.

-3

u/Blazej_kb Aug 27 '26

In cpp there is alternative to pointer which is reference (it’s used in c# because pointer don’t exist) and it’s safer than pointers

1

u/DesapirSquid Aug 28 '26

c# has pointers [unsafe] triggers them, but you better know what your doing.

8

u/[deleted] Aug 27 '26

[removed] — view removed comment

1

u/Blazej_kb Aug 27 '26

I get it but I don’t mean 1 use script (for which python is perfect IMO) I mean full on apps

7

u/GlassCommission4916 Aug 27 '26

Then never. Python is awful for larger applications. Don't ask me how I know, I don't want to talk about it.

1

u/terletsky Aug 29 '26

Because you have no idea where Python is used.

1

u/Old_County5271 Aug 31 '26

I think we all know where python is used, and yes, its impressive, but also, its a pain to deal with any dynamic language and a big application this has always been true, python is no exception.

1

u/binocular_gems Aug 28 '26

Something that’s pretty common in the applied programming is starting with an idea, that idea develops into a prototype, you want feedback early so you launch the prototype as an MVP, and then that MVP matures into a production application at scale, and while you always meant to refactor the MVP, other priorities take over. Investors demand features, customers report bugs, and you lose the budget for a full scale refactor as things get more and more complex.

1

u/Old_County5271 Aug 31 '26

Processing a csv is faster in awk than python, probably perl is also better. Pulling data from an API is probably better in python.

But I understand, yes, python is a great prototyping language. but there is an after prototyping phase.

-1

u/YMK1234 Aug 28 '26

False dichotomy, as if python and c++ were the only options. And most other languages have very easy to use libraries for the tasks you describe, and let's not even talk about those where python sucks ass (funny you should mention APIs, the default JSON interpreter is a hot mess that only works through dicts instead of classes)

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.

-1

u/Blazej_kb Aug 27 '26

I like how easy it is to use C written libraries in python, unfortunately it’s harder other way around

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

1

u/Several-Marsupial-27 Aug 28 '26

Nah, even if it’s easier for him to write in C++, python still better in some ways. Also these things are tools, not personality traits, and knowing how to use the tools is valuable.

Python has a massive ecosystem and have many third party features which don’t exist in C++, or are as mature as in Python. Doing any rather difficult mvp will take a week in Python, but months in C++. Like web scraping, pdf->excel, machine learning, image processing, ... Therefore it’s often wiser to prototype some functionality in Python before going lower level.

Many companies also likes to complement production C++ code with Python code for testing, tooling, and building. In this area Python is generally preferred, since it’s much nicer to implement scripts in and won’t be shipped to prod. Actively avoiding Python might therefore hurt your chances getting a job as a C++ developer.

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

For what purposes is python useful?

It is general purpose language so you can use for whatever you want..currently it is quite popular with AI and Data Science.

Where is it more convenient or necessary to use python instead of for example C# / C++ / Rust?

Everywhere where squeezing performance and memory management is not an issue/requirement.

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.

Interesting, good for you.

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?

Ignoring human factor, assembly is best.

Edit: I don’t talk about one time use scripts or prototypes (which python is good for), I mean full on apps

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.

4

u/[deleted] Aug 27 '26

[removed] — view removed comment

2

u/moss-nogg Aug 28 '26

That’s where linters come in clutch

-2

u/Ok_Pirate_2714 Aug 27 '26

I make sure it is indented. But I don't fuss over tab vs space.

But Python most certainly does.

That is why I despise it.

3

u/[deleted] Aug 27 '26

[removed] — view removed comment

0

u/Ok_Pirate_2714 Aug 28 '26

If I wanted to use an IDE, I would code in a real programming language.

I use Python, when I have to, for quick prototyping and automation

6

u/CorpT Aug 28 '26

Using Python and not an IDE is certainly a choice.

0

u/Ok_Pirate_2714 Aug 28 '26

I only reluctantly use Python, when there is no other choice. I'm not going to set up another IDE for a language that I don't enjoy using.

0

u/naemorhaedus Aug 28 '26

For what purposes is python useful?

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.

are they things that python can do that cpp cant?

for certain tasks it's probably quicker and easier to get off the ground.

I mean full on apps

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