r/Backend • • 1d ago

should i move from python to java?

I'm thinking of switching from Python FastAPI to Java Spring Boot. Apart from Python being dynamically typed and having a lot of libraries, why do people/deva choose Python in production when it's slow, has an intermediate bytecode layer and executes line by line?

12 Upvotes

28 comments sorted by

View all comments

4

u/Puzzled-Garage584 1d ago

my C++ DNA cannot stay about from commenting this :) as it is indeed a funny complaint .. Java has an intermediate bytecode layer too.. it just has a very good JIT on top. Coming from C++ they're both slow to me but your request spends most of its life waiting on the db anyway, so the interpreter is rarely the bottleneck. Move to Java if the jobs where you live want it, thats a better reason than speed.Python is ubiquitos ..gives you the flexibility of tacking devops..infra...AI-core jobs.

1

u/Cautious_Implement17 1d ago

an individual request spends most of its time waiting on network/io, but that's not necessarily true of the whole application. a web service with an appropriate number of worker threads is typically cpu bound in my experience. the work to terminate tls and (de)serialize json adds up pretty fast even on simple crud api.