Python & TypeScript - in Review (2024)
Python & TypeScript - in Review (2024)
December 2024
One thing that I like to stress is the importance of tooling and relying on defaults. By being able to speak consistently within ones own projects or using commonly seen patterns reduces the mental overhead. These could be folder structures or idioms, especially things which permeate across different programming languages or frameworks.
Here are some of my thoughts on Python and TypeScript; coming from someone who is predominantly a Python developer and does minimal front-end work.
Python
As a general trend, I’ve gone all-in in [astral](https://astral.sh/:
- Moving away from poetry and onto uv. I believe uv has reached a level of maturity which makes it production ready, especially its relative speed.
- Similarly moving to uv, I’m defaulting more and more to ruff as a replacement for flake8 and isort.
General setup
1brew install uv
2uv init <project>
with options in pyproject.toml
1[tool.ruff]
2line-length = 120 # changed from 88
3
4[tool.ruff.lint]
5select = ["E4", "E7", "E9", "F", "I001"] # added isort option
In general using ruff format and ruff check --write make for good developer
experiences
On “default” libraries, I do find myself trying to rely more and more on stdlib instead of particular frameworks. This is probably more a reflection of trying out https://cosmo.zip/ for trying out portable scripting as a default.
Enterprise library recommendations:
- I do still use pydantic very heavily. One thing that I would like to try is logfire which I haven’t had an opportunity to test.
- For web frameworks fastapi is still more than sufficient and provides a good developer experience. I’ve run into issues with it being too opinionated, and needed to write a fair bit of custom middleware, though nothing insurmountable. sqlmodel looks like a good option for what it does though I’ve personally had mixed experiences working with ORMs and generally have hand-rolled things rather than rely on frameworks.
- orjson has been an amazing drop-in replacement for stdlib json library, and I’ve witness substatial improvements to latency metrics in production services
- pytest remains my preferred testing library of choice
Patterns
In terms of enterprise building patterns, I still recommend Cosmic Python, in particular working with Domain Driven Design.
TypeScript
I’m very new to TypeScript, and have not used it in anger in enterprise settings. Infact modern web development is still very daunting and the tooling still doesn’t “make sense” to me. The general webdev space feels like there was a lot of tacit knowledge that was in-built in the ecosystem and non-obvious for how a beginner should proceed.
- Defaulting to bun. Maybe I’m just late to the game, and I feel like maybe I can just skip node. This allows me to use bun test as a test framework as well (rather than jest or mocha)
- biome has been amazing for formatting and linting with APIs very similar to Python’s ruff
- rolldown, it just “works” for me out of the box and meant I didn’t need to concern myself with builds and complex configuration
- alpine.js as a front-end javascript library. This may be a somewhat unusual choice, though coming first from Python and moving to TypeScript just means my biases is towards this model of development rather than using React.
Since I use TypeScript more as a hobbyist, I do find myself gravitating towards patterns which allow me to “deploy” applications straight to static hosting solutions like github pages. In the past, I have tried solutions like Gatsby Vite though they haven’t quite clicked for me.
General Setup
In general bun defaults work well. I would generally push source code to the
src folder and use rolldown to push builds to dist with separate html
files for testing the webserver. Hopefully in the future I get the whole
software development cycle seamlessly working (n.b. I know
bun supports watch mode supports
watching)
Hopefully in the new year I get more acquainted with the appropriate patterns
for TypeScript development. I may try doing more work with bun repl and
scripting as a replacement to Python to practise my coding chops.