HN user

j4mie

4,533 karma

https://www.mtth.org

Posts96
Comments91
View on HN
www.theguardian.com 9d ago

Sam Neill has died

j4mie
474pts114
www.carbonbrief.org 27d ago

UK sales of electric vehicles just overtook petrol cars for the first time

j4mie
6pts0
openai.com 1mo ago

Built to benefit everyone: our plan

j4mie
13pts4
openai.com 2mo ago

The OpenAI Deployment Company

j4mie
42pts33
simonwillison.net 4mo ago

Perhaps not Boring Technology after all

j4mie
12pts2
wesmckinney.com 5mo ago

Msgvault: fast private email archive and search system

j4mie
52pts8
dri.es 6mo ago

The Third Audience

j4mie
1pts0
www.django-rapid-architecture.org 7mo ago

Django RAPID Architecture, a guide to structuring Django projects

j4mie
6pts2
blog.samaltman.com 10mo ago

Abundant Intelligence

j4mie
87pts128
services.google.com 11mo ago

Measuring the environmental impact of delivering AI at Google Scale [pdf]

j4mie
4pts1
www.lux.camera 1y ago

Physicality: The New Age of UI

j4mie
9pts0
www.djangoproject.com 1y ago

Django 5.2 Released

j4mie
57pts22
www.youtube.com 1y ago

Walk, Run, Crawl, RL Fun – Boston Dynamics [video]

j4mie
6pts2
www.dabapps.com 1y ago

Could AI bring about a hypermedia renaissance?

j4mie
3pts1
about.bnef.com 1y ago

Generative AI – The Power and the Glory

j4mie
2pts0
protonsforbreakfast.wordpress.com 3y ago

Another reason to stop using gas

j4mie
7pts15
github.com 3y ago

Microdot: The impossibly small web framework for Python and MicroPython

j4mie
5pts0
www.djangoproject.com 3y ago

Django 4.1

j4mie
289pts125
www.django-readers.org 4y ago

Show HN: Django-Readers

j4mie
3pts0
colorjs.io 4y ago

Color.js

j4mie
2pts0
adamj.eu 4y ago

How to Find and Stop Running Queries on PostgreSQL

j4mie
125pts15
gregoryszorc.com 4y ago

The PyOxy Python Runner

j4mie
2pts0
www.david-dahan.com 4y ago

MVC frameworks aren't dinosaurs but sharks

j4mie
318pts248
adamj.eu 4y ago

How to Make Django Raise an Error for Missing Template Variables

j4mie
3pts0
www.theguardian.com 4y ago

Ernest Shackleton’s ship Endurance found off coast of Antarctica

j4mie
44pts1
htmx.org 4y ago

How a hypermedia approach can address usability concerns with multi-page apps

j4mie
220pts128
github.com 4y ago

Your computer is leaking: a defence of dynamic types

j4mie
1pts0
www.radicalsimpli.city 4y ago

Radical Simplicity in Technology

j4mie
25pts4
unpoly.com 5y ago

Unpoly 2 Released

j4mie
1pts0
hyperscript.org 5y ago

What Is Async-Transparency?

j4mie
3pts0

When we bought our house (1950s semidetached) it needed a full electrical rewire. I’m so glad I asked the electricians to run Ethernet all over the house at the same time, including to the ceiling in some rooms for WiFi access points.

Hi, author here. I have been building Django and DRF applications commercially for about fifteen years at DabApps, and this guidebook is an attempt to write down the architecture patterns we have arrived at, for projects that have to survive years of ongoing maintenance.

High level summary:

* We don’t hide Django under layers of abstraction, we just slice it up a bit differently than you would by default.

* Organise code by responsibility (readers, actions, interfaces, data) rather than by app.

* Put most business logic in plain functions, not in fat models or deep class hierarchies.

* Keep views thin: treat GET as "read some data" and POST as "do an action".

* Design endpoints around real frontend use cases (backend for frontend) instead of idealised resources.

* Control queries carefully to avoid performance traps.

Happy to answer questions!

Laravel’s ORM was originally inspired by my now-long-dead PHP projects Idiorm and Paris:

https://laravelpodcast.com/episodes/c7807d42/transcript (Search for “Paris” to find the relevant section)

https://github.com/j4mie/idiorm

https://github.com/j4mie/paris

Idiorm was started in early 2010 while I was still writing PHP professionally. I’d heard about Django from a talk @simonw gave at the FlashBrighton meet-up group in 2009 and immediately fell in love. Idiorm and Paris, although not direct attempts to duplicate Django’s ORM, came from frustration that such an elegant ORM and query builder didn’t exist in the PHP world.

So in a roundabout way, Laravel’s ORM was absolutely inspired by Django.

As a side note, I’m still doing Django 16 years later and love it more than ever.

It's worth noting that uv also supports a workflow that directly replaces pyenv, virtualenv and pip without mandating a change to a lockfile/pyproject.toml approach.

uv python pin <version> will create a .python-version file in the current directory.

uv virtualenv will download the version of Python specified in your .python-version file (like pyenv install) and create a virtualenv in the current directory called .venv using that version of Python (like pyenv exec python -m venv .venv)

uv pip install -r requirements.txt will behave the same as .venv/bin/pip install -r requirements.txt.

uv run <command> will run the command in the virtualenv and will also expose any env vars specified in a .env file (although be careful of precedence issues: https://github.com/astral-sh/uv/issues/9465)

Diagram as Code 2 years ago

Previous discussion: https://news.ycombinator.com/item?id=31849787

Repeating my comment from that thread:

  from diagrams import Diagram
  from diagrams.aws.compute import EC2

  with Diagram("Simple Diagram"):
      EC2("web")
This has a very odd API. It's using (abusing?) context managers and contextvars to do weird spooky things that you could just as easily do with ordinary objects or functions.

I wrote a library a little while ago which is intended to be the simplest possible expression of this idea:

https://github.com/j4mie/hotmetal/

The core implementation is only 85 lines of Python, and has no imports at all, so works nicely on minimal/alternative Pythons like Micropython.

I'm using it on a medium-sized side project and it's shockingly productive compared to string templates. I don't think anyone is using it except me, though.

Django Styleguide 4 years ago

I've been heavily inspired by this styleguide over the years, but I still think it's a bit too complex. A few random thoughts:

  - I think "services" is too much of a loaded term. I prefer "actions", and I always use the function-based style.
  - I hate the naming of "APIs" in this document. They use the term "API" when they mean "endpoint" or "view".
  - "Reuse serializers as little as possible" is the single best piece of advice when using DRF. The inline InputSerializer thing is brilliant.
  - Having each each endpoint only handle a single HTTP verb is brilliant.
  - URLs and views should be separate from all other business logic (models, actions etc).
  - For read endpoints and associated business logic, I'd encourage https://www.django-readers.org/ (disclaimer: I'm the author).

This makes me think you've never dealt with untyped Python code in a large production repo.

I run an agency and we maintain dozens of large, mature production projects (up to ~100k lines of code each).

I do understand the arguments and examples in the rest of your post, and intuitively they make sense, but practically I have almost never had an experience like the one you describe in 20+ years of working on Python codebases.

you have to dig into the function to find out what it's actually going to give you

This is exactly what I do, and it's just fine. I find it more difficult to build a mental model of what's happening in type-annotated code.

Like I said, it's subjective. That's why I find "types improve readability" arguments in posts such as this to be problematic. They are stated as basic axioms with no supporting data. It's easier to read for you.

The more I think about it, the more I think that the controversy around static type annotations in Python boils down to this:

  Improved readability
This is very subjective, and is particularly sensitive in a language like Python which (rightly) has such a strong historical emphasis on readability above almost anything else.

My personal opinion is that static type annotations are extremely detrimental to readability. They add jarring line noise that makes reading Python much less like reading English. Hitting a type annotation when reading Python forces my brain into little backtracking loops which hugely diminishes my ability to form a mental model of the code from a quick read.

I wonder if people who come to Python from other languages (that are already statically typed) are accustomed to the poor comprehension introduced by types, and so don't experience this drawback.

Diagram as Code 4 years ago
  from diagrams import Diagram
  from diagrams.aws.compute import EC2

  with Diagram("Simple Diagram"):
      EC2("web")
This has a very odd API. It's using (abusing?) context managers and contextvars to do weird spooky things that you could just as easily do with ordinary objects or functions.

What's your definition of "large codebases" here? My experience is that on Python codebases large (~100k lines) and small, type annotations are generally a net negative, particularly with a "rotating roster of many developers", because of their complexity and detrimental effect they have on readability. As the OP says, incorrect types are worse than no types at all.

Just to note: django-zen-queries doesn’t encourage you to execute querysets as soon as you define them, but rather just before you pass them to a template or serializer. This is a pattern we’ve found really useful.

(I’m the author of django-zen-queries)

I’m not a fan of the hyperbole in the article either. Some of the points are genuine problems but none of them should put off beginners.

Every web-based video chat I’ve used (including Google Meet and Slack) makes the fans on my decently-specced 2018 MacBook Pro spin up like it’s about to take off. I’ve tried Firefox, Chrome and Safari. Zoom (via the native Mac app) doesn’t do this. Does anyone know why browser-based video is so resource intensive?