Post AYJedW04t3fQUp6FQu by lanodan@queer.hacktivis.me
 (DIR) More posts by lanodan@queer.hacktivis.me
 (DIR) Post #AYFEOuMwcxLSI4KWhs by emacsen@emacsen.net
       2023-07-31T06:13:36Z
       
       1 likes, 0 repeats
       
       A bit of a programmer rant...People wonder why I like ORMs even when they're unnecessary. Firstly, I've never liked SQL. I think that writing queries to a RDBMS is something that a computer should do, akin to compilation. In the few times when extreme optimization is warranted, low level code can be generated to suit that specific case. In other times, ORMs usually provide a more natural interface to data that increases readability and code flow.#programming #rant #sql #databases #orm 1/2
       
 (DIR) Post #AYFEU6wXIx8qjhSUt6 by lanodan@queer.hacktivis.me
       2023-07-31T06:16:46.182775Z
       
       0 likes, 0 repeats
       
       @emacsen I hate SQL enough that I think there should be a better way to interface with a database, like one that's not so prone to injection and it might as well just be a binary-oriented format.
       
 (DIR) Post #AYHkCSOOP5eKtf2A0u by emacsen@emacsen.net
       2023-07-31T06:18:50Z
       
       0 likes, 0 repeats
       
       @lanodan I entirely agree. SQL feels like a poor abstraction, one that should be relegated to the past, with a standard binary interface being offered, first optionally, then SQL being deprecated.
       
 (DIR) Post #AYHkCT7Phhf79I67Bg by xocolatl@mastodon.social
       2023-08-01T11:15:31Z
       
       0 likes, 0 repeats
       
       @emacsen @lanodan I don’t mean for this to come across as condescending, so please don’t take it that way. You are both talking about a language that you do not understand and don’t know how to use. In particular, you seem to want to tell the database how to do its job instead of just declaring the results you want. There are hundreds if not thousands of person-hours put in to optimizing queries, and your “I’ll do it in my own code” is no match for that.
       
 (DIR) Post #AYHkCTugkV4rc79SzY by lanodan@queer.hacktivis.me
       2023-08-01T11:21:28.195507Z
       
       0 likes, 0 repeats
       
       @xocolatl @emacsen > I don’t mean for this to come across as condescending, so please don’t take it that way. Then please rephrase or rethink entirely how you want to lay your post out because that's 100% how you're putting it.Specially as: The whole reason I want SQL to be replaced with another language is because I know it enough to know too much of it's quirks.And it's not that I want existing databases like PostgreSQL or MariaDB to go away, you can change the interface language of a software without having to rewrite something entirely (heck, I'm writing this post on Pleroma, which changed both of client API and server API).
       
 (DIR) Post #AYHl8lgoobMHXeSQ7c by glitch@pl.glitch.pm
       2023-08-01T11:30:10.459022Z
       
       0 likes, 0 repeats
       
       @lanodan @emacsen @xocolatl ORMs are great as long as you're just doing basic CRUD operations. Thankfully, that's 99% of the operations you'll ever need to do.For the 1% of really complicated queries, that's when SQL will always be better because of how purpose build it is to return tables/do complex updates and deletes. You can do them in ORMs but it starts turning into a contortionist exercise at that point because even the best ORMs aren't made with those in mind. (Also for stuff that needs really optimized queries - ORMs may not choose the most optimal retrieval methods for a complex query.)And *even then* it's all being bolted on top of some pretty awful design choices that should be changed cuz we've learned more about how to properly design a language since the 90s.
       
 (DIR) Post #AYHl8mnwfaeZ02ncrw by lanodan@queer.hacktivis.me
       2023-08-01T11:32:00.607971Z
       
       0 likes, 0 repeats
       
       @glitch @emacsen @xocolatl Please do not explain shit that I know.
       
 (DIR) Post #AYHy48sQTdbJPb0kim by xocolatl@mastodon.social
       2023-08-01T13:34:56Z
       
       0 likes, 0 repeats
       
       @lanodan @emacsen I don’t know how to put “you don’t know what you are talking about and should read a book or something” more delicately.
       
 (DIR) Post #AYHy49SwHso9Eq5udM by lanodan@queer.hacktivis.me
       2023-08-01T13:56:50.222140Z
       
       0 likes, 0 repeats
       
       @xocolatl @emacsen Consider:- SQL queries via string formatting + basic helper functions: Good luck not accidentally doing something broken- ORMs: Generates unreadable code, tends to encourage making bad codeA better query language would allow queries to be properly checked and not warrant such bad abstraction layers.That's why people like me want a replacement to SQL, even after having used it for years. Meanwhile your position sounds like "Please don't replace C or Bourne Shell".
       
 (DIR) Post #AYJ5XM0hcTsLNbicXQ by lanodan@queer.hacktivis.me
       2023-08-02T02:54:24.520786Z
       
       0 likes, 0 repeats
       
       @xocolatl @emacsen Well after having slept on it: SQL usage could also just separate data from code cleanly and get a nice subset that's just data, then get a clean way to separate between the two.Like how JavaScript (code) got JSON (data) with a dedicated parser instead of eval or code concatenation, which allows to pass external data including wild ones like text in a way that's nearly always going to be safe, even if your JSON encoder screwed up and forgot to escape some characters (where then it's either extra variables or a syntax error, not code injection).
       
 (DIR) Post #AYJdpha5YW2hvzBtCa by xocolatl@mastodon.social
       2023-08-02T09:17:39Z
       
       0 likes, 0 repeats
       
       @lanodan @emacsen I am not sure exactly what you mean by separating code and data. Data is the result of the code. Unless you mean when you provide data, like input from a user or something. That has existed for over 30 years now.
       
 (DIR) Post #AYJdpiHKxida67QQc4 by lanodan@queer.hacktivis.me
       2023-08-02T09:19:29.264439Z
       
       0 likes, 0 repeats
       
       @xocolatl @emacsen Yeah, input from a user, where there's been a constant stream of code injections for decades basically whenever an ORM isn't used and the data in question isn't simple to validate (like free-form text for example).
       
 (DIR) Post #AYJedVQH2B1khmLecq by xocolatl@mastodon.social
       2023-08-02T09:26:30Z
       
       0 likes, 0 repeats
       
       @lanodan @emacsen This is an example of not knowing SQL.The constant stream of injections for decades is because people are not using parameterized queries and once again trying to do the DB’s job in their own code. This is not SQL’s fault, it’s the developers’ fault for not learning SQL.
       
 (DIR) Post #AYJedW04t3fQUp6FQu by lanodan@queer.hacktivis.me
       2023-08-02T09:28:29.366489Z
       
       0 likes, 0 repeats
       
       @xocolatl @emacsen And blaming the users is a blatant example of design failure, even for languages.
       
 (DIR) Post #AYJfSu82wB6g69KbBI by xocolatl@mastodon.social
       2023-08-02T09:34:23Z
       
       0 likes, 0 repeats
       
       @lanodan @emacsen Sorry. Blaming your tools just because you don’t know how to use them is not a design failure with the tools.
       
 (DIR) Post #AYJfSupeK3z8HNjQ92 by lanodan@queer.hacktivis.me
       2023-08-02T09:37:50.436602Z
       
       0 likes, 0 repeats
       
       @xocolatl @emacsen That would be understandable if you where providing hammers, which you're not.There needs to be tools to say "nope, this code is busted" not sheer elitism like "nope, a large part of people using SQL are entirely at fault"
       
 (DIR) Post #AYJg7IIwTJegf3geo4 by xocolatl@mastodon.social
       2023-08-02T09:42:58Z
       
       0 likes, 0 repeats
       
       @lanodan @emacsen I criticize #SQL all the time—and there is much to be critical about—but the “problems” you are describing are purely user-error.
       
 (DIR) Post #AYJg7Iy40QY4iavUu0 by lanodan@queer.hacktivis.me
       2023-08-02T09:45:09.248892Z
       
       0 likes, 0 repeats
       
       @xocolatl @emacsen And user errors should be errors, either at runtime or with some other way like static analysis.
       
 (DIR) Post #AYJqODQQrgJrzdtjQe by mkutz1492@mastodon.world
       2023-08-02T11:39:43Z
       
       1 likes, 0 repeats
       
       @xocolatl @lanodan @emacsen - declarative languages (sql)- objective code (ORM)- hierarchical file format (JSON, XML)All 3 are different ways to describe the same thing. It should be easy to translate between.Each solves a different set of problems better than the others.Don't hate one because you don't run into the problem it solved best.IMO