(no title)
larrik | 5 months ago
In NodeJS the most popular ORM is Sequelize. Sequelize struggles with TypeScript, the code to use is extremely verbose (vs Django), and the migrations are simplistic at best. There are other ORMs, but you usually gain TypeScript support at the expense of good migrations (which range from rough SQL-script-only support to literally nothing). Schema migrations are one thing, but if you want to do a data migration that uses business logic, in Django you can potentially just bring in your business code directly into a migration, and you can also explicitly set pre-requisites rather than having to order the filenames (which is what everything else seems to use).
Also in NodeJS if you miss an `await` in your controller, the entire server can crash if that call fails.
That's Node vs Django, though, which isn't completely JS vs Python, but it also really is.
Coming from Python, JS has constant surprises, where code works in one place and not another (in the same project!) due to reasons I don't always understand around ES version and configuration. Everything in JS feels like a hack job, built on a pile of someone else's hackjobs.
Likewise, if I want to know how something in Python works, I just look at the source. I rarely even look at official documentation because the code is right there. That's not a reasonable thing in JS, frankly.
But really the worst part is that I do a ton of "try and test" development, where debugging is hit or miss and console.log is everywhere. In Python, I can just write the code live in the shell/iPython, and then past the working code back into my IDE. This ends up being a huge timesaver.
nawgz|4 months ago
I totally agree JS can be surprising, and actually I think the greatest skill a JS developer needs is to understand what things are powerful reliable and composable as opposed to hacky, where you can understand hacky things lead to surprising behavior.
For instance, I too have used Sequelize, and it is a painfully bad library. I can only see that network effects have lead the community here, there is no merit. Instead, I think the scrutinizing JS developer - the one who can write reliable JS - needs to just throw Sequelize out. It sucks.
I happily did this, and so I looked elsewhere at what the community was trying in terms of data paradigms. An obviously interesting invention of the JS community at the time was GraphQL. After some time, I decided writing my own resolvers in JS was an exercise in futility, but I found it incredibly attractive to use the tool Hasura to give a free GraphQL API over a DB.
PostgreSQL, Hasura GraphQL Engine, GraphQL, graphql-codegen, and typescript combine to make this amazing chain where you can normalize your DB and rely on the foreign keys to make up the GraphQL relationships, get automatic knowledge in the GQL you author of whether the relationship is nullable or represents an object or array relationship, and then load deeply nested (i.e. semantically rich) queries to author a type-safe UI in. All of this requires 0 packages to be published, I just use a monorepo with `pnpm` and my client can talk to Hasura safely with the generated code from Hasura GraphQL Engine, or to my TS backend via tRPC and tsconfig.json "references".
Now when it comes to migrations, Hasura has first class support, it's really incredible how you can use `hasura console`, click in a GUI to make all your database changes, and have a migration written to source code ready for you to use after this.
So, take it this way: Sequelize sucks, TS can't polish a turd, and the job in JS is to discover something powerful and useful.
In Python, you would never have touched a garbage library like Sequelize because Django is amazing and the community recognized that.
And now, let me show you my personal bias
> Everything in JS feels like a hack job, built on a pile of someone else's hackjobs.
Nah, you have it exactly backwards. How are type hints not meaningful in Python in the year 2025? Sure, named args and some other things are useful, but Python is the king of the untyped dynamic happy-cast do whatever BS. The code is insanely terse but that's directly a bad thing in this day and age when that terseness is directly achieved at the cost of meaningful typing.
I for sure recognize this partially stems from the activities one performs in the language, but having to run your Python to know if it works is objectively hilarious. Well crafted TypeScript and ESLint recommended catches virtually all my programming errors, such that I would never run into this problem
>if you miss an `await` in your controller, the entire server can crash if that call fails
My IDE calls that out! As it should! As Python refuses to!
rick1290|4 months ago