Anytime this topic comes up, this opinion is invariably at the top of the comments. However I've never seen a non-trivial application made this way. Mind sharing one? More than the query generation, I think people reach for ORMs for static typing, mapping, migrations, transactions, etc.
I'm not doubting that it can be done, I'm just curious to see how it's done.
I formerly worked for a travel company. It was the best codebase I've ever inherited, but even so there were select N+1's everywhere and page loads of 2+ seconds were common. I gradually migrated most of the customer-facing pages to use hand-written SQL and Dapper; getting most page loads below 0.5 seconds.
The resulting codebase was about 50kloc of C# and 10kloc of SQL, plus some cshtml and javascript of course. Sounds small, but it did a lot -- it contained a small CMS, a small CRM, a booking management system that paid commissions to travel agents and payments to tour operators in their local currencies, plus all sorts of other business logic that accumulates in 15+ years of operation. But because it was a monolith, it was simple and a pleasure to maintain.
That said, SQL is an objectively terrible language. It just so happens that it's typically the least of all the available evils.
Anytime this topic comes up, I ask: Why not both? I don't want to modify my SQL strings every time I change a column. Django ORM lets me combine custom SQL snippets with ORM code. I never hesitate to use custom SQL, but its just not a reasonable default for basic CRUD operations that my IDE can autocomplete. Not only that, but also provide nice feautures pike named arguments, walking relationships, sanitizations, etc. At the same time, I can do a UNIONS, CTES, anything I want. I just don't understand why it's worth arguing against ORMs, when no one is forcing you to stop using raw SQL.
I completely agree, it is absolutely essential to understand what SQL is emitted, and how SQL works. Perhaps the strawman argument against ORMs is that they preclude you from knowing SQL. They don't.
YouTube is one from my experience. The team there had a pretty strong anti-orm stance. DB performance was an existential necessity during the early scaling. The object fetching and writing tended to be focused through a small number of function calls with well scrutinized queries and write through memcaching.
The company I work for is one such example. We write inline SQL in a Python Flask+Celery app which processes >$3bn of salaries a month. The stated goal from the CTO, who was an early engineer, is simplicity.
In addition to the great replies folks are sharing, I've found LLMs are quite good at authoring non-trivial SQL. Have effectively been using these to implemnt + learn so much about Postgres
It's not the sql that is non trivial, it's the patterns where I need to mix and match filtering clauses etc which make running a layer on top of the sql necessary. Unless you're sort of patching together your own query building.
Many great SQL examples have long existed on stackoverflow and similar sources, but until the recent past were buried by lower quality questions and answers or SEO spam.
You will find that if you check sources they are lifted almost verbatim. LLMs are a way to cut through the noise, but they are rarely "authoring" anything here.
It's wild how far a little marketing can go to sell the same or an arguably worse product that used to be free and less unethical.
I’ve started a few projects with SQL over the years, and it makes for a much slower development cycle. Instead of solving business problems, you’re spending too much time focusing on query optimization, and any iteration that touches the db requires all the mapping logic to be painstakingly reconstructed. For me writing queries in SQL is for later optimization. But then again, I’m pretty strict about abstracting even the ORM stuff away into a data access layer, so maybe people run into problems trying to thread ORM models all the way through to their frontend code or whatever crazy things people get up to.
I worked for a publicly traded corporate elearning company that was written this way. Mainly sprocs with a light mapping framework. I agree this is better as long as you keep the sprocs for accessing data and not for implementing application logic.
ORMs are way more trouble than they’re worth because it’s almost easier to write the actual SQL and just map the resulting table result.
My current company is built like this, and it’s great. I can’t think of a single production bug that’s come from it, which was my main concern with the approach. It’s really, really nice to be able to see the SQL directly rather than having to reason about some layer of indirection in addition to reasoning about the query you’re actually trying to build.
I work in logistics, warehouse management systems (in particular the one I've specialized in) have incredibly complex databases with a lot of business logic baked in. This is due to being very data-crentric applications.
Also, in many non-tech companies the database admins were historically a consistent IT resource even when no other developers were available, so SQL gets leveraged extensively. When your only tool is a hammer, most of your problems end up being weirdly nail shaped.
I've worked on a few, nothing I can share. I don't mind using an data mappers like Dapper in C# that will give you concrete types to work against with queries. Easy enough with data types for parameterized inputs as well.
Cerner millennium is built entirely this way. There is a custom sql language called CCL that is used for everything interacting with the DB. All the applications just call CCL scripts.
I have written the entire backend of a fintech using nothing but postgresql, integration over http and webhook receival included (the last bit was with postgrest, but you get the point)
Every single time. Where are these developers? Orms are a god send 98% of the time. Sure, write some SQL from time to time, but the majority of the time just use the ORM.
We have a POS system where entire blogic is postgres functions.
There are many others as well. Sure Rails/Laravel/Django people use the ORM supplied by their framework, but many of us feel it's un-necessary and limiting.
Limiting because for example many of them don't support cte queries(rails only added it a couple of years ago). Plus it get weird when sometimes you have to use sql.raw because your ORM can't express what you want.
Also transactions are way faster when done in a SQL function than in code. I have also seen people do silly things like call startTransaction in code and the do a network request resulting in table lock for the duration of that call.
Some people complain that writing postgres functions make testing harder, but with pglite it's a non issue.
As an aside I have seen people in finance/healthcare rely on authorization provided by their db, and just give access to only particular tables/functions to a sql role owned by a specific team.
I worked at a company where we used Dapper with plain SQL. Like the sibling commenter said, simplicity. There were never [ORM] issues to debug and queries could easily be inspected.
Writing queries is trivial and in any marginally complex case I'll write something which beats the ORM for efficiency. I suppose they are a god send if you don't know SQL but you can learn SQL quite quickly.
Am I the victim of the algorithm? Because all I see on HN these days is people pessimistic about tech and society. The tenor here is overwhelmingly negative.
Where are you seeing anyone defend big tech, tech bros, or any tech in general?
Clinton era consultants were the only ones saying the obvious: “it’s the economy stupid”. On the other hand it was the Obama era consultants who were fixated on the massive loser that is identity politics
Democrats are screwed on economic messaging until they join Republicans in dropping neoliberalism. Was never popular, but both parties could stick to it as long as neither "defected". Now one has.
Even when the economy's good, they're going to be hindered on messaging until they drop that.
Meanwhile a bunch of them are running around like "the problem's that we were too nice to trans people!" lol no, the problem is the latent one that's been hanging there waiting to be triggered by one party or the other since the '80s, the one any expert should have been watching for a shift in—or looking to move first on—this entire time.
> Democrats are screwed on economic messaging until they join Republicans in dropping neoliberalism.
I disagree. What we're witnessing today is that while people are happy with many of the fruits of globalization (cheap Chinese junk, cheap flights, ability to travel anywhere, remote work, etc, etc) our politicians have just about done everything in their power to increase the price of the things that actually matter: housing, healthcare, childcare, and education.
A Democrat party that could actually deliver on these things (rather than exacerbate the problems as they have done) would fare far better electorally. No need to put in place unpopular, destructive tariffs.
> increase the price of the things that actually matter: housing, healthcare, childcare, and education.
i.e. things that have large skilled labor inputs within the US and can't be exported, plus housing which half the population doesn't want to be cheaper. This is just "Baumol cost disease". The major component of healthcare, childcare, and education is the wages of other Americans.
Let's not kid ourselves that the election was a fair comparison of economic policies.
The economy was doing fine apart from a transitory inflation spike especially in eggs. Meanwhile the US is now involved in a pointless trade war with Canada before even getting to the budget; people are going to have an economic disaster that dwarfs the price of eggs, because they got invested in identity politics of the right-wing.
I predict the Trump term will be an economic disaster on the numbers, but this will have no effect on people's stuck belief that Republicans are better than Democrats at economic management.
Silenced as in, not given access to White House officials? Sorry but there is a difference between that and arresting people for things they say online.
Not given access to the White House, threatened by legal action and ousted from their journals [1]. Is that enough or should we only start to act when they get disappeared?
Also, I won't cry for the two 4chan basement dwellers from your article getting to face the consequences of their despicable actions. Sorry, our definition of free speech does not include harassment and flurries of racial slurs. Literally 1984, I know.
It is undeniable that European countries police speech more heavily than the US does. They have laws on the books that plainly give them this power. They exercise this power quite regularly. Feel free to argue that it is right for them to do so, but don't muddy the discussion attempting to redefine words.
Which words did I redefine? Our free speech doesn't include hate speech but it is still called free speech in our constitution. And it's boundaries are still clearly defined, just like yours.
Also, I don't feel like there's anything to argue, look where allowing rampant misinformation and lies proliferation got your country. Your president is spitting Russian propaganda to Zalensky's face: "you started the war", "Russia will respect peace", "Europe only loaned money", etc. Your country is falling apart, not mine.
Five years ago, Guinness left the following note on their video of Ben Lee's performance:
"
It's worth noting that this is no longer a category that our records team monitor - the record has been rested. Our records managers are no longer able to monitor fastest musician records as it has become impossible to judge the quality of the renditions, even when slowed down. In terms of monitoring the number of musical notes, it is not clear if all notes have been played fully.
"
Yeah, I think this is in large part due to TwoSetViolin, a classical music YouTuber duo who did a hilarious roast of this performance, as well as the whole concept of "fastest performance". See https://www.youtube.com/watch?v=BvsvaCU6i1M for the original video.
So you're suggesting there's some other viable model of egg production that would deliver eggs at 2021 prices? People want cheap eggs. Saying, "well if we just adopted a decentralized, more resource intensive model we wouldn't have problems with bird flu" doesn't address that concern.
People want lots of things to be cheap but that doesn’t mean it’s sustainable. Here in the mid-Atlantic we’ve seen the same thing others mention: the local, non-factory farms prices haven’t changed in years but the supermarket stuff went from being cheaper to more expensive.
The theory that optimizing for the lowest price might other negative effects isn’t exactly novel: we’ve seen that in many other areas, and if you’ve ever been anywhere near a factory farm it’s enough to put you off of eating eggs.
I think it was Food, Inc, a documentary from a number of years ago. Joel Salatin of Polyface Farms talks about factory farming and Salatin often argues that industrial farming is not necessarily more cost-effective and that his method is both profitable and environmentally sustainable.
In obsidian I have a template to insert a timestamp. I have a "Work Log" file I refresh each month where I just jot down whatever with the timestamp. No further organization required.
I’ll never understand this narrative. What product category has Apple missed or failed to execute well in since Jobs died? Do you think there’s an iPhone level hardware product out there that Apple would be shipping today if only Steve were still around?
Off the top of my head, since Jobs death Apple has launched AirPods, Apple Watch, Vision Pro, Car Play, Home Play, M-series MacBooks, and they’ve greatly expanded their services business.
I'm not doubting that it can be done, I'm just curious to see how it's done.
reply