Live data from Hacker News

Prolog language for PostgreSQL proof of concept

github.com

51–60 of 83 posts

Re: Prolog language for PostgreSQL proof of concept

#52
post #51

Recently, I learned that PostgreSQL can integrate with many languages through plugins, such as PL/Python, pgrx (Rust), pgzx (Zig), and so on. I wonder if anyone is planning to write one for Java or C#, lol.

Not that I'm aware of but any plugin system that expects dynamically linked binaries integrating through C API can be targeted by .NET NativeAOT (e.g. OBS plugins can be written in C# without manually dealing with hosting the runtime).

Re: Prolog language for PostgreSQL proof of concept

#53

As a proof of concept, this looks very cool. Suggestion: add a short example to the README. I had one experience with Prolog in the 1980s that blew my mind. I had an IR&D project to build a complete prototype of an air/land battle simulator (yes, I was a defense contractor back then) in Common Lisp given 6 weeks of coverage to write it and demo it. After a month I was satisfied with the functionality and after demoin…

This reminds me of an old idea I’ve toyed with. In a logic class in university we talked about how some logic is time dependent, like A is true 2 hours after B becomes true. I was inspired to try to think through a language like prolog that could model and solve these relations through time. Didn’t get far with it since it’s a hard problem and I had too many classes that term. I was thinking it would be useful for clockless chips.

Re: Prolog language for PostgreSQL proof of concept

#55
post #51

Recently, I learned that PostgreSQL can integrate with many languages through plugins, such as PL/Python, pgrx (Rust), pgzx (Zig), and so on. I wonder if anyone is planning to write one for Java or C#, lol.

There has been PL/Java for a long time: https://tada.github.io/pljava/ and PL/Perl and others. The projects you mention are largely building on well-established interfaces in Postgres.

Re: Prolog language for PostgreSQL proof of concept

#56
post #7

If you're interested in this I would also recommend you check out Logica[0], which is a datalog-like language that is explicitly made to compile to SQL queries. 0: https://logica.dev/

I was wondering how this was possible and then found this monstrosity: https://colab.research.google.com/github/EvgSkv/logica/blob/... Click on the SQL tab.

Seen longer, more obtuse queries written by hand in some applications I've worked on. Big, useful systems often give rise to them eventually.

Re: Prolog language for PostgreSQL proof of concept

#57
post #7

If you're interested in this I would also recommend you check out Logica[0], which is a datalog-like language that is explicitly made to compile to SQL queries. 0: https://logica.dev/

I was wondering how this was possible and then found this monstrosity: https://colab.research.google.com/github/EvgSkv/logica/blob/... Click on the SQL tab.

I wrote SQL queries twice that long for credit originations reports in banks which would hit several terabytes of disk read per run

Re: Prolog language for PostgreSQL proof of concept

#58
post #15

Love this, I've long considered that this should've been made as Prolog and SQL are ternary logic and basically SQL derives from Datalog and it itself from Prolog. A table record can be taught as of as a Prolog fact, so this makes the WHERE clauses the predicates in the conjunction on the right-hand side of a rule. And then exhausting the goal is actually returning the result-set. Hope to see this develop even furthe…

Prolog's evaluation semantics are order-dependent, though. I've always thought this was the reason why the two language paradigms didn't see more merging than they did. There are some datalog+RDBMS hybrids but, as much as I'm not a fan of .NET, I think LINQ has seen the most success in this space.

What are you concerned about when using .NET?

Re: Prolog language for PostgreSQL proof of concept

#59
post #53

As a proof of concept, this looks very cool. Suggestion: add a short example to the README. I had one experience with Prolog in the 1980s that blew my mind. I had an IR&D project to build a complete prototype of an air/land battle simulator (yes, I was a defense contractor back then) in Common Lisp given 6 weeks of coverage to write it and demo it. After a month I was satisfied with the functionality and after demoin…

This reminds me of an old idea I’ve toyed with. In a logic class in university we talked about how some logic is time dependent, like A is true 2 hours after B becomes true. I was inspired to try to think through a language like prolog that could model and solve these relations through time. Didn’t get far with it since it’s a hard problem and I had too many classes that term. I was thinking it would be useful for cl…

Not sure if it's exactly what you're looking for but see this paper: https://ceur-ws.org/Vol-2785/paper9.pdf ( A Language for Timeline-based Planning )

Re: Prolog language for PostgreSQL proof of concept

#60

So, I expected this to actually query the DB using prolog (using the correspondence between relational algebra and logic programming). I mean, can those prolog stored procedures use the db as a source of facts for prolog, or otherwise write queries?

you can do that using ODBC
Post reply on HN