r/learnprogramming • • 16d ago

Is Python a good choice for backend development ?

I'm considering learning Python for backend development and would like to hear from developers who use it in their daily work.

How good is Python for building backend applications in production? Are there any significant drawbacks compared to languages like Go, C#, or Java?

2 Upvotes

62 comments sorted by

9

u/pak9rabid 16d ago

Python with FastAPI, and writing things to take full advantage of asyncio isn’t a bad route to take. I’m doing that now with good results.

3

u/E3ek1el07 16d ago

Came here for FastApi too.

1

u/trahsemaj 10d ago

I don't understand why fastapi is not considered 'good enough'? What kind of use cases is fastapi not sufficient for?

4

u/Rafadazdoit 15d ago

Python is good for early prototypes, but it’s dogshit for long term, usually for long term I’d recommend Rust or C++

2

u/Least_Chicken_9561 14d ago

not c++ for back-end stuff, better rust and go for back-end

1

u/Rafadazdoit 14d ago

Say whatever you want but I work with a lot of systems where the choice is c++ or Python for full backend stuff, and fuckkkkk Python for that noise

4

u/Least_Chicken_9561 14d ago

interesting, what kind of frameworks do you use in c++ for the backend?

1

u/Rafadazdoit 14d ago edited 14d ago

Small electric motor based control systems, certain components can specifically use Rust, but overall the only two languages that they all share libraries are Python and C++, though for some reason I’ve got certain ones that support C# as one of their primaries?

Like I have one component that specifically uses C++, C#, Python, and fuckin Matlab. I could, in theory, utilize Rust’s c++ translation layer for it, but given this is just being setup, there’s no reason to risk adding an additional failure level at the prototyping stage, maybe eventually when it’s finished certain bits can be transitioned

3

u/boomkablamo 14d ago

This is a completely incoherent answer to the question.

0

u/Rafadazdoit 14d ago

If you cannot read, that is not my problem, sorry my man

8

u/boomkablamo 14d ago

Oh I can read. That's how I know there isn't a single backend cpp framework in that response. Unless you think a "small electric motor based control system" is a backend framework, which you apparently do.

3

u/Pale_Height_1251 16d ago

It's OK but I'd prefer Go, C# or Java.

3

u/Human-Possession135 16d ago

Yeah for most things python is fine. Django is easy to learn and forces you to do things right.

Given you sound like a beginner and not someone scaling to 1 million users right now. Don’t sweat it.

6

u/rcls0053 16d ago

It works. It's easy to learn. There's frameworks like Django etc. that enable you to get started fast.

But I would not recommend it for any enterprise for backend services. Not having type safety in your application is an absolute pain. It's a fine language for certain use cases, but I just wouldn't build anything big on top of it really. Unless you set up strict rules for proper type hinting in your codebase and ensure it's followed. But imo there's just better languages and platforms for that.

2

u/terletsky 10d ago

Meanwhile Instagram and Threads are on Django

2

u/fixermark 16d ago

Modern Python is type-safe. Every major library has a static type declaration file, and all you have to do to static type your own code is use the type annotations and run a static checker over it.

You can choose to use it without the type safety, and that does introduce complexity that other languages don't have because the option exists, but the "Python doesn't have static types" idea is outdated signal.

2

u/TheSilentFreeway 16d ago

as your traffic isn't very high and you don't care much about performance or memory efficiency. it's good for quick prototyping and iteration.

2

u/razorree 16d ago edited 16d ago

check job offers in your area. I know a few companies that use python in backend, even big, well, I work ever for one currently (however I don't like it, it's an abomination that starts to bite in the ass, but no-one wants to admit it and switch language or start creating microservices, and it's about the time. I worked with Java/Kotlin for >15y before. Instead monolith is slowly rewritten to asyncio (so everything is mixed), a lot of code is run in separate cron launch deployments, the whole stack takes like 1-2TB of RAM ...).

Java/Kotlin - one of the most popular? (for bigger projects)

Go - a bit less popular

Python - maybe for smaller companies?

2

u/smichael_44 16d ago

Everything depends…

For me, I work at a privately-owned aerospace/DOD contractor with ~4k employees.

We have a couple python backends that see ~400 DAUs and barely ever eclipse 4 RPS.

We have a .NET app that sees ~1500 DAUs and never gets above ~15 RPS.

For most companies, anything works. A better question imo is, are you learning to solve problems? Solving a company’s problems with technology is what matters most.

5

u/fixermark 16d ago

Yes, it is.

I've used Python as the language for a decent-sized service on top of postgres (sqlalchemy, alembic for migration, and then strawberry for the API). It works well, though if you scale up a lot you might start to get sensitive to the trickiness around multithreading (and you generally fix that by just spawning more instances of the service app and putting them behind a load balancer). Modern python is also type safe if you include a static analysis pass and wire it up correctly.

Java I generally dislike for this application because ORM bindings in Java are so much inscrutable compile-time magic that I don't want to learn it. Go and C# I have no opinion on in this space.

0

u/Intelligent_Part101 16d ago

Python backends are slow. You may think it won't matter, but if you start hitting the backend frequently, it will show. If you're somehow writing serverless lambda apps in python, it won't be such a problem, but it will be in a traditional monolithic server backend.

0

u/fixermark 16d ago

They are, but for most services, your bottleneck is almost always going to be network fabric and database layer. And you can scale horizontally when you bottleneck at the backend service itself. if most of your service is CRUD, it's legit hard to write it so that you notice the minimum path from query received to DB update in any language.

Are you eating more raw compute than you would if you'd built the thing in assembly? Maybe. Maybe not... Not so many great assembly coders out there anymore.

But generally, the amount you care about those raw compute numbers are in "forgot how to count that low" territory for most corporate applications. Maybe the resource squeeze AI is creating will change that calculus. But I suspect it will not.

3

u/DanKegel 16d ago

Supply chain issues make security a problem.

Consider golang instead, it's easy, fast, strongly typed, mostly mystery-free, has a great standard library, and has a fairly secure supply chain, partly because you can usually get by with the standard library more often than you can with Python or JS, partly because its package infrastructure was designed later and is more modern.

2

u/StewedAngelSkins 16d ago

Yeah it's fine. Only real drawback I can think of is it's a little less suitable for doing highly scalable microservice stuff, because the base container size needed to run a python app needs to be bigger and your options for RPC are less clean than what you get with Go. But unless that's specifically what you're doing, python is perfectly fine, and a common choice for backend code.

2

u/Evening_Vegetable218 16d ago

It's absolutely fine for most things you will need to do. Python is pretty easy to learn and there are plenty of resources to make this even easier. Once you're proficient you will be able to pick up other languages really easily

1

u/Sh3llSh0cker 15d ago

Python is great for automation and server side related ops https://github.com/elysiummachines/python

also a simple google search or a llm can tell you the same thing. just FYi.

1

u/sydridon 15d ago

Even though it's very hard to learn but I would go for rust. AI is very good at it and can help a lot if you are stuck.

1

u/engineeringsmudent 15d ago

Python’s pretty nice imo. FastAPI w/ SQLAlchemy is a great set up for building a basic backend. Being able to use pydantic models for input validation is also very nice.

Sometimes it’s alright to optimize for developer experience and ease-of-use. Not every piece of software needs to support high speed or throughput.

Have used Python quite successfully for basic backends controlling physical hardware components in specialty use cases. Using a more performant language would’ve meant longer development times and more complexity that just wasn’t needed.

All about picking the right tool to solve your particular problem.

1

u/andycwb1 12d ago

It’s a very subjective area, and also has lots of unless X, or because Y dependencies on the right answer. People obsess too much about which language. Learn to program, then learning a new language takes a few days (more these days because of the enormous amount of standard library functions available). At one point I was learning about 5 different languages simultaneously as part of my Computer Science degree - the idea was to make you think independently of the programming language you’re writing.

1

u/the_house_blend 10d ago

I guess it depends on the jobs in your area. Usually Java, C# and Node JS are the most used. I’m a Test automation engineer and I started with Java and used Selenium, then latterly Typescript with Playwright. I picked up python at some point along the way, for writing little utility scripts because it’s good for automating things, but that’s all I really use it for.

1

u/ialiimran 10d ago

I would definitely recommend learning Python. But just don't choose a language based solely on the benchmarks. Choose the one that fits the systems you want to build.

1

u/bunnypaste 16d ago

My backend is all .sh, .py, and postgresql.

0

u/Poincarina 11d ago

I am working on a legacy Python 3.8 Flask backend currently. Spring (Java) is just so much better and mature framework wise. I would never choose Python myself for a backend

1

u/Sensitive-Raccoon155 11d ago

FastAPI is good

0

u/palinurosec 16d ago

no, it's very slow. if you are looking for something easy, simple, fast and easy to maintain in the future, go with go

-1

u/az987654 16d ago

Not in a real world production application

-2

u/MacaroonOk9376 16d ago

Just here to say C# is a great choice. Depending on where you're located, there will be a shit ton of C#/.Net jobs available.

17

u/[deleted] 16d ago

[removed] — view removed comment

4

u/fiddle_n 16d ago

Of all the backend services out there, what percentage of services both have millions of daily active users and also were not able to foresee that they were going to have millions of active users? Of course such services exist but I don’t think it’s a common thing when taken in context with all the backends out there.

1

u/fixermark 14d ago

Scaling up like that requires you to get a prototype in front of people. If you can pull that off faster in Python, Python is not a bad choice. But that is partially a function of what team you pulled together.

50

u/[deleted] 16d ago • Bravo

[removed] — view removed comment

43

u/fredlllll 16d ago

"rewrite it later" is also never gonna happen

4

u/fixermark 16d ago

Or is always happening. I've never seen a company write an application once and then leave it alone forever if it was core-competency. I'd estimate our churn at the place I used to work at about... 70% rewritten over 2 years. Some core pieces were bedrock. Not as many as one might assume.

5

u/fredlllll 16d ago

maybe in big companies, small ones dont have the resources for a rewrite. ive worked on a 20 year old php codebase that shouldve been rewritten a decade ago or earlier

4

u/Dziadzios 16d ago

What do you mean by "rapid prototyping" that wouldn't be as rapid in other languages? 

The only reason to use Python for backend is integration with machine learning libraries.

5

u/ironykarl 16d ago

What do you mean by "rapid prototyping" that wouldn't be as rapid in other languages? 

Is this an honest question?  A REPL combined with a language with very little boilerplate is a pretty easy way to hack something together.

I think initial productivity on a project is one of the widely-agreed/uncontroversial supposed benefits of dynamic languages

4

u/fixermark 16d ago

This. I generally find Java (especially enterprise Java with database connectors) to be borderline-undebuggable. Too much magic, too many instances of "These methods all exist because the boomwhazit annotation interacts with the Spring annotations and causes a precompilation step to..." At some point, there's so much DSL that you're better off just using a dynamic language instead of pretending you have one in Java.

6

u/jeffreythomasprice 16d ago

Java is certainly a choice, but I wouldn't say that it's the best choice for any of those things. "Best" is highly dependent on other factors and is in some sense subjective.

That said I agree that python and js are both poor choices for anything nontrivial because of the weak, dynamic type systems. Typescript in the other hand is pretty dope, because it adds some good static typing. Any language with an even stricter type system is often an even better choice, Java among them. I would also include c# and go here, as well as rust.

All that said, your beginning or learning projects are not going to be hamstring by language choice (within reason, don't pick some esoteric toy language). Just stick with one thing and experiment.

2

u/fixermark 16d ago

I would always recommend TypeScript over JavaScript for the type system reason you've highlighted.

Python's modern type system is nearly best-of-breed, slightly behind TypeScript I think. All you have to do is add a static checker into your process and you're good to go. Bonus: you can prototype without the types and add them in later, so you get the best of both worlds: if they get in the way of your thought process while you're exploring, you can ignore them. If they don't, use them. Common LISP is the only other language I use regularly with that kind of type flexibility.

1

u/EIGRP_OH 15d ago

Both still are interpreted though

1

u/fixermark 14d ago

Correct, which is why high performance Python tends to rely so heavily on third-party libraries that do the heavy lifting in dedicated compiled code. For quite a few problem domains though, compiled versus interpreted is moot because if performance is actually the bottleneck, the workload wants to be shifted onto a CUDA environment or parallelized so much in a cloud architecture that the difference between compiled and interpreted run performance matters little unless you're pinching pennies.

The node engine for JavaScript is JIT compiled so I would actually not be willing to assume that any amortized workload (i.e repeatedly run over a long process life cycle) is outperformed by a compiled language. There are implementations of Python that do this as well, but CPython without experimental flags turned on does not.

3

u/ParadiZe 16d ago

truth nuke, i would go even further and say that "fast prototyping" or "fast DX" are a meme, you can go super fast in go

2

u/fixermark 16d ago

With modern tooling, I concur. Most of the delay one encounters in a strongly-typed language is realizing that, oh, you wanted this primitive field type to be something else, and now you have to edit every single place the field gets manipulated.

Modern IDEs have refactoring to help with that, and modern AI agents make that kind of refactor even more trivial - it can even identify places where the type change actually causes an issue and make educated guesses or ask for intervention on what to do.

2

u/pyaracetamol0mg 14d ago

Take my award mate. I'd recommend Java and Go. But if you're looking for performance try Rust (Actix for ultra low latency) or Axum. Learning curve is very challenging though.

1

u/ironykarl 16d ago

I mean... there are also loads of instances where you just want a backend for an internal tool, and dynamic languages are completely appropriate for that 

1

u/fixermark 16d ago

The wisdom here is that almost everyone needs rapid prototyping and will be rewriting it later. They'd be rewriting it later if they'd started in Go also; version 1 is almost always in need of improvement to fit the business domain.

I'm curious what you've seen security-wise in the enterprise space that would encourage you to use Java instead of Python. A speed argument I can see, but I haven't encountered a security story difference there.

1

u/povlhp 16d ago

C# and Java both target a virtual machine.
C/ C++ are OK are ok abstractions. Compiled languages are the way to go.

1

u/intbeam 15d ago

C# and Java's virtual machine compiles to native instructions. Both of them also support AOT compilation

They are both compiled languages, and performance-wise not that far off from C++ (depending on what you're doing and how)

C# can also use native pointers and cpu intrinsics

1

u/Dear-Sample-6338 16d ago

Hice mi sistemas de reservas en django(Python)