NORM
potygen
Our great sponsors
NORM | potygen | |
---|---|---|
3 | 3 | |
108 | 86 | |
- | - | |
7.6 | 2.8 | |
5 months ago | 6 months ago | |
PLpgSQL | TypeScript | |
BSD 3-clause "New" or "Revised" License | GNU General Public License v3.0 or later |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
NORM
- Is ORM still an anti-pattern?
-
Looking at the Postgres NORM project
Repo: https://github.com/hettie-d/NORM
-
Contributing to the No Object Relational Mapping Project (NORM) for PostgreSQL
No, because we support the specific return type with strong Postgres types. If you look at the package here: https://github.com/hettie-d/NORM/blob/master/sql/account_pkg.sql
potygen
-
Monodraw
OMG this is one of my favorite tools paid for it all the way back when it went out. Have used it so many times just to write documentation for things like:
https://github.com/ivank/potygen/blob/main/packages/potygen/...
ASCII is just so versatile and allows you to put nice graphics in places where one does not expect, making things more easily understandable.
-
Pql, a pipelined query language that compiles to SQL (written in Go)
I also wrote a parser (in typescript) for postgres (https://github.com/ivank/potygen), and it turned out quite the educational experience - Learned _a lot_ about the intricacies of SQL, and how to build parsers in general.
Turned out in webdev there are a lot of instances where you actually want a parser - legacy places where they used to save things in plane text for example, and I started seeing the pattern everywhere.
Where I would have reached for some monstrosity of a regex to solve this, now I just whip out a recursive decent parser and call it a day, takes surprisingly small amount of code! (https://github.com/dmaevsky/rd-parse)
-
Is ORM still an anti-pattern?
I used to agree 100% with this sentiment, as dissatisfaction with available ORMs at the time (early days of doctrine in PHP) drove me to actually write my own. Turned out an amazing exercise in why orms are hard.
Anyway a few years later I was in a position to start things fresh with a new project so thought to myself, great lets try to do things right this time - so went all the way in the other direction - raw sql everywhere, with some great sql analyzer lib (https://github.com/ivank/potygen) that would strictly type and format with prettier all the queries - kinda plugged all the possible disadvantages of raw query usage and was a breeze to work with … for me.
What I learned was that ORMs have other purposes - they kinda force you to think about the data model (even if giving you fewer tools to do so) With the amount of docs and tutorials out there it allows even junior members of the team to feel confident about building the system. I’m pretty used to sql, and thinking in it and its abstractions is easy for me, but its a skill a lot of modern devs have not acquired with all of our document dbs and orms so it was really hard on them to switch from thinking in objects and the few ways orms allows you to link them, to thinking in tables and the vast amounts of operations and dependencies you can build with them. Indexable json fields, views, CTEs, window functions all that on top of the usual relation theory … it was quite a lot to learn.
And the thing is while you can solve a lot of problems with raw sql, orms usually have plugins and extensions that solve common problems, things like soft delete, i18n, logs and audit, etc. Its easy even if its far from simple. With raw sql you have to deal with all that yourself, and while it can be done and done cleanly, still require intuition about performance characteristics that a lot of new devs just don’t possess yet. You need to be an sql expert to solve those in a reasonable manner m, just an average dev could easily string along a few plugins and call it a day. Would it have great performance? Probably not. Would it hold some future pitfalls because they did not understand the underlying sql? Absolutely! But hay it will work, at least for a while. And to be fair they would easily do those mistakes with raw sql as well, but with far few resources to understand why it would fail, because orms fail in predictable ways and there is usually tons of relevant blog posts and such about how to fix it.
It just allows for an better learning curve - learn a bit, build, fail, learn more, fix, repeat. Whereas raw sql requires a big upfront “learn” cost, while still going through the “fail” step more often than not.
Now I’m trying out a fp query builder / ORM - elixir’s ecto with the hopes that it gives me the best of both worlds … time will tell.
What are some alternatives?
Norm.net - Norm.net is an innovative and high-performance Database Access for .NET Standard 2.1 and higher
cornucopia - Generate type-checked Rust from your PostgreSQL.
SQLpage - SQL-only webapp builder, empowering data analysts to build websites and applications quickly
jOOQ - jOOQ is the best way to write SQL in Java
postgres_air
Knex - A query builder for PostgreSQL, MySQL, CockroachDB, SQL Server, SQLite3 and Oracle, designed to be flexible, portable, and fun to use.
sqlite-fast - A high performance, low allocation SQLite wrapper targeting .NET Standard 2.0.
sqlc - Generate type-safe code from SQL
postgres - Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare