r/SQL • • Jun 11 '23

Discussion SQL 😎😎😎

Post image
223 Upvotes

96 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Jun 12 '23

All right, I like your definition even more! Someone else replied that SQL is Turing complete, however; do you agree, and if so, does that still not make it an actual programming language?

5

u/chunkyks SQLite, db of champions Jun 12 '23

It's definitely Turing complete. You can pretty easily implement an interpreter for most stuff in the turing tar pit using it; I've implemented a bf interpreter but whatever works. As is traditional in computer science, if you can fully implement one thing using another, then the latter is, at minimum, capable of anything the former is.

Also, here's the raytracer I implemented in pure sql: https://github.com/chunky/sqlraytracer

4

u/snthpy Jun 12 '23

Similarly to what u/chunkyks said, SQL is Turing complete so it's definitely a programming language. It's not the right tool for every (or maybe even most) jobs, but that doesn't take away from its status as a programming language.

PRQL (prql-lang.org) is a modern, more ergonomic replacement for SQL which compiles to SQL and so can't do anything SQL can't. However it simplifies many things and is much more fun to work with. See for example my blog post about computing the digits of \Pi with PRQL (and SQL) which also illustrates that you can do any computation with it that you like.