Hacker News new | ask | show | jobs
by anagri 1056 days ago
i have worked on multiple languages - php, java (spring etc.), ruby (rails), golang (gin), javascript, typescript (nextjs), and many i am forgetting to recall.

FastAPI is the sweetest and the most intuitive web framework.

I just checked a few doc pages for your framework, seems heavily inspired by FastAPI.

So what have you not found in FastAPI that is making you write a new web framework from scratch?

3 comments

IMO Litestar is even better than FastAPI and its governance structure will better enable a solid foundation to build from. FastAPI a bit all over place and quite minimalist (which is great in some respects). I just prefer that Litestar offers more goodies similar to eg Django in many respects but still much more lightweight. Litestar feels generally more well integrated than FastAPI.
Haven't used panther myself, but I've chosen to use other solutions instead of FastAPI because tends to be the usual python soup mess on multi-modular projects. Also, I dislike pydantic quite a lot (I know, it works well for many use cases, its not a bad library), and usually use a three tier (presentation-service-data), DI-driven approach to development, which is largely incompatible with most python framework approaches. So, I've been building pretty much all the required layers on top of some of the Flask functionality for http (mostly the router and the dispatcher).

Also, building a framework is also a nice way of understanding how the sausages are made :)

> and usually use a three tier (presentation-service-data), DI-driven approach to development...

For web I love this approach and have moved more towards this myself.

Pydantic has it's place in my opinion, there are other packages that do a similar thing and for most use cases you can roll your own pretty effectively. For me that place is marshalling on the wire data to a typed custom data type with validation. Whether you are using JSON, or {binary format}.

You likely need to write the validation code yourself since you should be validating from the database as well.

So there we go, I am anti ORM as well.

Anything relates to the request should be handled at the "request layer" which in my case is flask(werkzeus) and maybe per request DB connection should be created at that layer.

Everything else should be in a business layer, that way which framework you use doesn't matter and can be trivially replaced with something else.

I forgot to add that most of my "custom" implementations are also open-source, to avoid repeating the same boilerplate over and over at different places. Its not "pythonic", and it is at varying degrees of maturity, and honestly, they are mostly for internal use in my projects (documentation is incomplete, interfaces may change, etc), but if you want have a look:

https://github.com/oddbit-project/rick_db - postgresql query builder & object mapper - it is built around the concept of pure data objects (no indirect references do open resources) that can represent application data between layers; It also features a forward-only migration manager;

https://github.com/oddbit-project/rick - plumbing, validation & assorted logic - provides service locators, registries, containers (including dependency injection); validators, forms & request validation (with support for laravel-style validation chains), and a bunch of other stuff;

https://github.com/oddbit-project/pokie - flask-based web meta-framework, focused on REST api design, that brings components from the other two projects into an modular applicational framework;

FastAPI is simply an attempt to make a Django on top of Starlette.