Hacker News new | ask | show | jobs
by Townley 1988 days ago
Disclaimer that basically everything below is a personal opinion:

- MyPy is a great (fine, decent) library for typing, but even without it, the type hints in newer python versions and typing standard library are super powerful. Not “rust” levels of powerful but at least on par with typescript

- Django is still excellent and now supports async views via asgi. Outside of async, django+DRF+djoser are an excellent choice for a backend. If you really like typing and cool, smaller frameworks, Starlette and the derivative FastAPI frameworks are a lot of fun. Any of those options are great for a web app backend these days

- Gunicorn is still easier to configure. UWSGI is also still around. Both are well supported - Django run server has gotten better about reloads, but it’s still not as good as node’s offerings

- asyncio has taken a bite out of celery (heh) but celery is still common and useful for deferred tasks

- I think dockerizing the app is the way to go these days. There’s just too many odd system dependencies and python compilation differences to deploy directly to an EC2 instance. Digital Ocean’s app platform or AWS Amplify (or EBS) make deploying a container image decently easy. And if youre willing to take the plunge into Kubernetes, I find it has many python-specific advantages (eg horizontal scaling to avoid pYtHOn DOesNt sCaLE” nonsense) at the cost of a tremendous learning curve. If you do end up going for a non-containerized deployment, infrastructure as code is big now, so both terraform and ansible might be your friends

- graphQL support is bad. I think Graphene (Django) is the best you’ll find. DRF being decent is one of the reasons I generally stick to REST if I can help it

- Asyncio has come a long way but still has issues with non-async codes (eg it’s hard to make a sync request or access a DB in an async block)

- Tornado was the initial async bad boy and is still around, but again FastAPI is doing some really cool stuff in async

- For data science, pandas is pretty universal but it plays very nicely with numpy. If you haven’t kept up with Tensorflow or PyTorch, you’ll be astounded by how far ML has come

2 comments

> but at least on par with typescript

I wish this were true, but mypy is far behind typescript. For example, mypy has `Literal["foo"]`, but typescript has the ability to template literals like `"foo-${bar}"` etc, and actually understand the results statically.

That's not to say mypy isn't great, it has some really good stuff, but I mostly think you're underselling Typescript here.

Huh, good to know. Does this issue apply to f-strings or are you talking about format methods? I did a brief look through issues and MyPy seems to support f-strings fine, but I’d 100% believe that there are still kinks to work out
Ah, so mypy supports fstrings, but not in types. So you can do

    Direction = Literal["left", "right"]
But this won't work:

    eft = "eft"
    ight = "ight"
    Direction = Literal[f"l{eft}", f"r{ight}"]
(Yes, this is super contrived, I bad at coming up with examples, but https://mariusschulz.com/blog/string-literal-types-in-typesc... shows some realistic examples where it's useful in typescript)
Thanks for the heads up about graphQL—I think I'll avoid for now. It will be for a new project so not a big deal.

I just had a quick look at PyTorch... you're totally right this is miles ahead of what I remember.

I forgot to ask about package management. Do you use pip, conda, poetry?

Personally I love poetry, if for no reason other than making publishing a breeze. If I can’t use it for some reason, I like managing virtual envs with pyenv (not to be confused with pipenv. You’re better off for having missed the controversies around that)

Oh btw virtualenv is gone now; you make envs using python -m venv myEnvName

Nice, I’ll check out poetry.

That’s great that some of the virtualenv functionality made its way into the standard library!