Live data from Hacker News

Do you think writing backend with Python feels wrong?

news.ycombinator.com

11–17 of 17 posts

Re: Do you think writing backend with Python feels wrong?

#12

I think as your backend grows larger you will likely begin to run into the issues that I experienced with Python through my years of writing it. The dynamic typing eventually makes certain kinds of bugs creep into your code and it can be difficult to realise. Code written in dynamic languages are also more difficult and time consuming to refactor than code written in a statically typed language.

True, absolutely, but if you add type hints before you refactor, it isn't too bad.

Re: Do you think writing backend with Python feels wrong?

#13

I think as your backend grows larger you will likely begin to run into the issues that I experienced with Python through my years of writing it. The dynamic typing eventually makes certain kinds of bugs creep into your code and it can be difficult to realise. Code written in dynamic languages are also more difficult and time consuming to refactor than code written in a statically typed language.

True, absolutely, but if you add type hints before you refactor, it isn't too bad.

Not before the refactor. Type hints need to be there from beginning. I can't imagine anybody decides writing python without type hints in 2023.

Re: Do you think writing backend with Python feels wrong?

#14

Earlier quoted context omitted.

True, absolutely, but if you add type hints before you refactor, it isn't too bad.

Not before the refactor. Type hints need to be there from beginning. I can't imagine anybody decides writing python without type hints in 2023.

Correct, but if they are there this isn't a problem, so if it's a problem I'm figuring they aren't there ...

Re: Do you think writing backend with Python feels wrong?

#15

Java has the advantages that it fully supports threads, I've seen JVM back ends hold up under heavy load. It is often possible and sometimes easy to get a 7.5x speedup on an 8-core machine with Java. I write a lot of backend code using aiohttp in Python for my own side projects, it is really a blast, particularly if the code is "more than a web server", say it is listening to message queues, connected to something li…

Aiohttp is too risky to code,and it is only good if you are only one working on that project, or you are working with good friends of yours. Give it in a hands of bad programmer, you are fucked harder than any pornstar I have ever and yet to seen in my 21 year lifespan. You are right about pip too, I don't know how did they achieve to come with a package manager that is worse than NPM. Such a feat.

pip got frog boiled into it.

Maven is a correct package manager. Maven is able to get a global view of the metadata for all of the packages that conform to the specification so it can find a correct solution for dependencies before it downloads any JARs.

Historically, Python used egg files that required you to run the setup.py (and download dev dependencies) before you knew what the dependencies of a package are. This has the real advantage of being able to change your dependency list based on your environment (say loading a GPU-enabled or platform-specific version of a dependency) but "doing the right thing" would involve doing all this work in isolated environments and doing an awful lot of work.

Thus you get the "optimistic" approach used by pip which is to start installing packages one at a time and hope for the best. There is no correct strategy to recover when it paints itself into a corner.

Almost all pypi packages are wheels now and they just introduced the ability to download just the metadata file (a few years back when I was struggling with Python packaging at a startup I did find you could accomplish the same with two or three http range requests since you can find the superblock and directory information at the end of the wheel and then fetching the metadata is easy.) If a package is only available as an egg you can do what anaconda does which is make a wheel of it for your specific configuration and stash it in your private repository.

We might see a correct system emerge out of this, but...

Python has suffered from people who think an 80% or 90% correct solution is acceptable but that's just wrong. Until ChatGPT came along nobody thought an 80 or 90% sorting algorithm is acceptable. Certainly people could decide they need or don't need certain features (for instance pyenv) but there are certain things that are either wrong or right and you can either invest a finite amount of effort into getting things right or struggle forever pushing bubbles around under the rug.

Python also needs a good answer for environmental variation. For instance there is scikit-learn and there is a version of scikit-learn compiled against Intel's MKL library. The latter package should be tagged as a substitute for the first so that somebody who wants to use it can swap it out without making any changes to the package configuration file (can't do that because you don't want to check those changes into version control.) There are some affordances for packages having optional features but these just aren't adequate to the task.

Re: Do you think writing backend with Python feels wrong?

#16
It sounds like you're just saying it's boring when an adequate library/framework is available. But I've never heard of such a library/framework that makes it THAT easy.

Either the software you're working on is simple or the projects are too small and not complex enough for you. Has nothing to do with Python.

Re: Do you think writing backend with Python feels wrong?

#17
I felt the opposite once I stopped writing backends in Python and moved to Scala, then Go.

The compiler is like an extra set of eyes attached to a brain that doesn't make mistakes. The type system in Scala especially freed up so much time and concentration allowing me to focus on implementing business logic at such a rapid pace. I couldn't go back to Python now for anything moderately complex.

Post reply on HN