3 ms·
SQL is on the same group as Prolog. In fact, it is a simpler and purer implementation of a constraint-solving language, so it is probably a better option for le
by marcosdumay 4y ago
SQL is on the same group as Prolog. In fact, it is a simpler and purer implementation of a constraint-solving language, so it is probably a better option for learning the group than Prolog.
For the signal transformation ones, there are also the hardware definition languages on the same category as LabView and animation languages.
- ucarion 4y agoTo your point, Berkeley's intro-level CS class, CS61A, used to use teach Prolog as an example of logic programming. They use SQL now instead. I can't really attest to whether that's a better choice for learning logic programming, though. It's easier to "run programs" in Prolog. SQL wants to be a cog in a machine where Prolog is more freestanding.
- tonyarkles 4y agoI definitely did a bunch of Prolog in my CMPT216 class back in undergrad and I hadn't really thought of SQL as an alternative until today. I agree with you it's easier to "run programs" in Prolog, and a lot of the concepts from the class would have been more difficult to map to SQL than Prolog (e.g. writing a Sudoku solver in Prolog was mind-melting in a good way, writing a Sudoku solver in SQL would probably be mind-melting in a bad way). The one thing that SQL does have going for it though is that there's a ton of tooling for getting practical real-world data into it. I would absolutely love to take a set of logic/set-oriented problems and solve them both in Prolog and SQL, just to see which ones are ergonomic in each language. Maybe this summer at the cabin...
- ucarion 4y agoThe tooling thing goes both ways. I remember classmates struggling with homework because they were trying to use a different flavor of SQL than the SQLite we ran for class. This stuff is obvious to engineers, but very confusing to someone whose first hello-world was 8 weeks ago.
- ngruhn 4y agoSQL has no recursion. I would argue that's a pretty fundamental aspect of Prolog, so I don't think SQL is a representative replacement.
- curiousllama 4y agoYes it does. It’s a fun problem to make a sudoku solver https://technology.amis.nl/it/solving-a-sudoku-with-one-sql-statement/ https://technology.amis.nl/it/solving-a-sudoku-with-one-sql-...
- ngruhn 4y agoOk fair enough. I suspect that's a pretty non-standard/rarely-used feature though. If you learn SQL you likely won't encounter this and I still contest the idea that SQL is a good entry into the logic paradigm. SQL and Prolog are both relational. That's very unique to both. But SQL is all about querying databases. Prolog can also be used and understood as a database querying language but it's also very strong for - parsers - interpreters - expert systems - solving combinatorial problems If you really want to you can probably use SQL for that too. Or any language for that matter. But going out and learning SQL won't naturally expose you to these applications and how well the logic paradigm lends itself to them.
- castorp 4y ago> I suspect that's a pretty non-standard/rarely-used feature though. If you learn SQL you likely won't encounter this Recursive common table expressions are part of the SQL standard (since 1999) and are quite frequently used to traverse hierarchical data (aka "adjacency list"). It is part of basically all (good) SQL tutorials - at least in the "advanced" part.
- blowski 4y agoI don't remember using recursion in a real project, but I built a HN clone on top of Postgres, with the following query: WITH RECURSIVE thread(id, parent_id, user_id, post_id, timestamp, text, depth) AS ( SELECT id, parent_id, user_id, post_id, timestamp, text, 0 FROM comments WHERE user_id = 1 AND parent_id IS NULL UNION ALL SELECT c.id, c.parent_id, c.user_id, c.post_id, c.timestamp, c.text, t.depth + 1 FROM comments c JOIN thread t ON c.parent_id = t.id WHERE c.user_id != t.user_id ) SELECT * FROM thread ORDER BY timestamp ASC;