Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The only thing I like in SQL is that is almost the same language in decades. Learn it once and you're done. If you really need, you could write macros yourself. I don't see the value of learning a new language to do the same thing


Given how many new programming languages have become widely used in the time since SQL's creation, it seems many others do se some value. For a mostly direct parallel to PQL, see CoffeeScript and TypeScript.


I love LINQ just because it made HOF look like SQL


SQL's nonsensical handling of null is reason enough to learn other query languages.


Do you mean that NULL <> NULL and NULL infects boolean logic?

NULL is always an awkward thing to deal with - how you want to handle it depends on the specific thing you're trying to accomplish. I'd probably prefer it if NULL equaled NULL when dealing with where conditions but it actually makes join evaluations a lot cleaner - if NULL equaled NULL then joining on columns with nulls would get really weird.

At the end of the day IS NULL and IS DISTINCT FROM/IS NOT DISTINCT FROM exist so you can handle cases where it'd be weird.


the best way to handle nulls is with Option / Maybe types. that is, without null at all

unfortunately they were not invented at the time sql was created


I think that's just a question on syntactic sugaring here - so, concretely, what would that mean for comparison operators? If I wanted to `id = id` and both were nullable would I need to express that as two layers of statements where I tried to unwrap both sides first or would we have a maybe vs maybe comparison operator - if we had such an operator what would it do in this case?


You’d have to unwrap, usually with convenient mechanism for it —pattern matching

The problem is that id = id is fundamentally incorrect for a nullable column. You should have done id is not null and id = id. And you shouldn’t have been allowed to do the first anyways, because nothing good can come of it (there is no sane semantics to stuffing a trinary logic into a boolean algebra, and SQL chooses one of the many insane options, leading to both false positive and false negative matches depending.) the only correct answer is not to do that.


I can understand how that would make things more explicit - but given how common nullability is in the realm of databases I think it'd be a bad idea to force that much syntax in a situation where id=id is essentially what we want to discuss - especially since columns becoming potentially null is so trivial to achieve (even when impossible due to model constraints) as soon as you start throwing left joins in the mix.


Sometimes you really want explicit, rather than dealing with the errors caused by implicitness. And with a language that has proper support for things like Maybe, there isn't that much syntax.

It's true that you have to adopt a completely different language, but when that language saves you from potentially expensive bugs, it becomes appealing.


You might be interested in my attempt: https://docs.racket-lang.org/plisqin/Nullability.html

I think it handles all the 3VL problems I've encountered in SQL, but that doesn't mean it handles all possible 3VL problems. It also might not make any sense to anyone except me.


It's been a while since relational algebra so I don't feel confident saying "Yes" or "No" (I guess you could say my reply is Null) - but that seems like a really good base approach - especially having a state for being uncertain whether something is nullable or not... having an operator embeded fallback approach also seems to be a lot more usable for the developer.

Also, this is an aside, but is your thing named after Snake Plissken?


Yeah, kind of. I have seen Escape From New York but I don't really remember it. I was more aware of the character via the reference/homage in Metal Gear Solid 2. In any case, I don't love the name but the obvious choice (Racquel) was already taken and "Plisqin" had zero Google results so I said "meh, good enough."


Using this language on top won’t solve that though, it still compiles into sql, warts and all.


Pql uses the same NUll handling, since it just passes it through to the generated SQL.


> The only thing I like in SQL is that is almost the same language in decades

So you do agree that the rest of SQL is broken. That’s why there is a value in creating (and learning) such new languages.


I strongly disagree that SQL is broken. Try using JPA or your favorite ORM on a large project with a complex entity graph. It is a nightmare having to ctrl-click deep into the entity graph to see what annotations are on some great-grandchildren to get an idea as to what query is being executed. When working with relational data SQL has always been the ideal tool for the job on the projects I've worked on.


ORMs are fundamentally broken. Hiding the relational structure of a relational database is the act of madmen.

Using the psychosis of ORMs to defend the psychosis of SQL is itself a form of psychosis


I think a lot of times people say “ORM” when they mean “Hibernate” or some other ORM implementation.

In your codebase, do you stick raw SQL all over the place and iterate over rows exclusively? Or instead, as a convenience, do you write helpers that map objects into SQL statements and map result rows into objects? If so, congratulations, you’re using an ORM. The concept of ORMs is not bad. It’s a logical thing to do. Some ORM _implementations_ have some very serious issues, but that does not make ORMs as a whole bad.


I'm not sure I'd consider query-builders to be ORMs. You do inevitably have a mapping from query resultset to list<obj>, so it does meet the name itself, but there's clearly a very large difference between "Hibernate" and query-builder, and if you don't want to use ORM to be the differentiating term calling out Hibernate and friends specifically, then let me know what you do wish to use. But as far as I know, colloquially and commonly, ORM refers to the former -- not the general act of having any mapping at all.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: