Why does everyone seem happy with SQL, and its silly syntax/semantics? Why don't we have something based on typed lambda calculus? The standard answer seems to be that SQL was designed to be accessible to laypeople (i.e. like BASIC), but isn't it about time we had a standard database query language for real programmers?
(Hopefully, it would be easier to translate between query languages than between programming languages)
(Hopefully, it would be easier to translate between query languages than between programming languages)
(no subject)
Date: 2009-06-03 07:50 pm (UTC)(no subject)
Date: 2009-06-03 09:09 pm (UTC)SQL is verbose but very powerful and quite adequate for writing relational queries. Typically you're not writing long scripts in it, by a programmer's standard, so I'm not sure what the need is for a new database language? Is there anything in particular you don't like, aside from the verbose syntax?
(no subject)
Date: 2009-06-03 07:52 pm (UTC)(no subject)
Date: 2009-06-03 08:02 pm (UTC)If you're not happy with it, tell those of us who are why, and make a case. I don't think SQL is actually that accessible to laypeople, and most people I know who can build a powerful query (even moreso using relational calculus rather than relational algebra) happen to be real programmers. SQL, like regular expressions, is a neat and powerful language. If you think you can make something that's cleaner or more powerful while still being appealing to programmers, give it a go and see how it's judged. Unlike products, these concepts have stood the test of time in the field of ideas so far.
(no subject)
Date: 2009-06-03 08:35 pm (UTC)My general opinion on this matter is that the kind of syntactic "sugar" seen in SQL is a bad way to address the fact that you don't have a programmer in front of the machine, and that teaching them logic is a good way.
(no subject)
Date: 2009-06-03 09:56 pm (UTC)Seems like a pretty nice way to me to think about these things...
Why do you insist that it's not programming and/or it's not for programmers?
(no subject)
Date: 2009-06-03 11:30 pm (UTC)I may be fishing to figure out if you actually meant anything sensible with the original post - it may be that you're more familiar with RA and have not seen RC in SQL. If so, this is probably because the most popular relational database software (MySQL) is crap and doesn't know how to optimise RC (among other misfeatures) - it tends to do perversely stupid, slow, and memory-hoggish things with RC. Other database engines don't have that problem, and a majority (although not everyone) of DB folk consider it best practice to use RC over RA whenever possible, because it's more clear, more optimisable, and more concise.
See also: Codd's Theorem
(no subject)
Date: 2009-06-03 08:10 pm (UTC)Hey, I like abstruse mathematical formalisms as much as the next guy, but on behalf of everyone for whom a computer is a tool instead of a fascination, I'm mentally giving you the finger right now.
(no subject)
Date: 2009-06-03 08:13 pm (UTC)(no subject)
Date: 2009-06-03 08:17 pm (UTC)(no subject)
Date: 2009-06-03 08:21 pm (UTC)(no subject)
Date: 2009-06-03 08:18 pm (UTC)(no subject)
Date: 2009-06-03 08:21 pm (UTC)(no subject)
Date: 2009-06-03 08:23 pm (UTC)(no subject)
Date: 2009-06-03 08:36 pm (UTC)(no subject)
Date: 2009-06-04 11:26 am (UTC)(no subject)
Date: 2009-06-03 09:06 pm (UTC)(no subject)
Date: 2009-06-03 10:52 pm (UTC)(no subject)
Date: 2009-06-03 09:20 pm (UTC)Seriously, SQL comes out of academia, and db people are much more interested in things like query planning than language design.
(no subject)
Date: 2009-06-03 10:00 pm (UTC)that's totally not true! I know at least two people who started out as PL researchers before moving into databases :P
(no subject)
Date: 2009-06-03 11:06 pm (UTC)(no subject)
Date: 2009-06-04 02:32 am (UTC)(no subject)
Date: 2009-06-03 11:06 pm (UTC)(no subject)
Date: 2009-06-04 01:45 am (UTC)(no subject)
Date: 2009-06-04 01:35 am (UTC)I'd think you'd be into that sort of union of theory and practice. SQL has mildly bad syntax because it was the 80s, but it mostly matches its problem domain. Even languages like python and haskell have special list comprehension syntax for doing similar sorts of operations. Those look more like SQL queries than the chain of zip and filter operations you'd do without them.
Possibly what you are really complaining about is the impedance mismatch between SQL and whatever glue language you're using. I don't know why people are happy with this.
(no subject)
Date: 2009-06-04 01:45 am (UTC)(defun select (test l) (if (test (car l)) (cons (car l) (select test (cdr l))) (select test (cdr l))) ))(no subject)
Date: 2009-06-04 02:00 am (UTC)That said, Microsoft has largely taken your approach with a C# feature called LINQ which basically encourages you to write queries in C# using chains of filters, which get turned into a combination of actual SQL and client side filters (I think at runtime).
(no subject)
Date: 2009-06-04 02:09 am (UTC)Thanks for the LINQ example. It still allows a DB to be a DB and PL be a PL... they just make the syntax uniform (though probably confusing for those who are used to separate syntaxes).
I don't mind that LINQ gets turned into SQL, as long as I don't see the SQL (though it would be more efficient if it interfaced with the DB directly, it sounds like a lot of work).
Do you see anything wrong with LINQ?
(no subject)
Date: 2009-06-04 02:16 am (UTC)select a and b where bar and baz
then
Foo
.filter(x => bar x)
.filter(x => baz x)
.map(x => (x.a, x.b))
(no subject)
Date: 2009-06-04 02:27 am (UTC)But I don't think FP has to be awkward in this way. Paul Graham wants to make Arc (partly) for that reason.
(no subject)
Date: 2009-06-04 02:39 am (UTC)This is already nicer in Haskell where you would write that like
map (\x -> (a x, b x)) $ filter baz $ filter bar $ Foo
but in haskell you'd actually could also do something like
[(a x, b x) | x <- Foo, baz . bar $ x]
which is way better, since it makes the components of the query (well list operation) clear (assuming you recognize the basic bits of syntax) using specially structured syntax.
The arc version, imo, would be most awkward of all, since, as a lisp it doesn't have syntax and so you end up with your usual lispy mess of nested parens.
(no subject)
Date: 2009-06-04 02:29 am (UTC)(no subject)
Date: 2009-06-04 11:28 am (UTC)It also allows you to do unbelievably insane things that I try to keep from infecting my brain.
(no subject)
Date: 2009-06-04 02:33 pm (UTC)(no subject)
Date: 2009-06-04 02:16 am (UTC)i think i generally agree with akiva here, in that i think query languages are a different animal from programming languages, so it's sort of misguided to say something like "why don't we have something based on the lambda calculus?"
(no subject)
Date: 2009-06-04 02:29 am (UTC)(no subject)
Date: 2009-06-06 04:45 pm (UTC)i don't think SQL is really imperative *or* functional -- it's a different beast altogether, a query language.
(no subject)
Date: 2009-06-06 04:54 pm (UTC)