Live data from Hacker News

I'm not mutable, I'm partially instantiated

blog.dnmfarrell.com

41–50 of 77 posts

Re: I'm not mutable, I'm partially instantiated

#41

I've never used it in production, but I have a deep love of Prolog, just because of how different it is from any other programming language I've used. As a programming paradigm, it found it as eye-opening as functional programming. What I found interesting is that you are operating on logical statements and pattern matching, which often means that the same "function" can be used for multiple different things. For exa…

I always thought that pattern matching would be an excellent feature for other programming languages, but it seems that it hasn't become popular. Many strategies available to Prolog could become possible just by the addition of this feature. One possible implementation of the idea occurs with C++ templates specialized with numerical parameters. It also seems that Mathematica provides pattern matching, but I don't use…

Matching of patterns, with only a single occurrence allowed for each variable, is fairly popular in languages designed in the last two decades, isn’t it? A lot of those have or at least borrow from ML heritage, and that of course places a big emphasis on algebraic types and pattern matching. Full-blown unification remains niche, that’s true, but it’s just a fairly heavyweight feature, and I don’t really know how you’d integrate it without turning your language into (a superset of) Prolog.

Re: I'm not mutable, I'm partially instantiated

#42
post #38

I've never used it in production, but I have a deep love of Prolog, just because of how different it is from any other programming language I've used. As a programming paradigm, it found it as eye-opening as functional programming. What I found interesting is that you are operating on logical statements and pattern matching, which often means that the same "function" can be used for multiple different things. For exa…

Do you have a suggestion on where to / how to start learning Prolog beyond towers-of-hanoi? Prolog is basically the last language on my list of things I want to look at, but whenever I tried, I failed to find anything practical to do/try.

Try a rules-based synthesis problem. Prolog style (put simplisticly) is to write down what is true about a solution, and turn the search engine loose. Prolog is still procedural, unfortunately, so practical Prolog requires understanding the search algorithm. A suggestion: produce the XY locations of the nails for a building-code-compliant nailing pattern for a panel of plywood roof sheathing. Allow different stud spacing and wind speed zones. This is a small toy problem but will channel your thought process toward something Prologgy.

Re: I'm not mutable, I'm partially instantiated

#43
post #38

I've never used it in production, but I have a deep love of Prolog, just because of how different it is from any other programming language I've used. As a programming paradigm, it found it as eye-opening as functional programming. What I found interesting is that you are operating on logical statements and pattern matching, which often means that the same "function" can be used for multiple different things. For exa…

Do you have a suggestion on where to / how to start learning Prolog beyond towers-of-hanoi? Prolog is basically the last language on my list of things I want to look at, but whenever I tried, I failed to find anything practical to do/try.

I’ve enjoyed https://www.metalevel.at/prolog but I’m not a Prolog Programmer.

Re: I'm not mutable, I'm partially instantiated

#44
post #2

I've noticed quite a lot of Prolog content lately. I don't know if it's just a case of the Baader–Meinhof phenomenon, but it looks to me that recent article[1] about Prolog being able to improve LLM reasoning abilities renewed some interest in the language. [1] https://shchegrikovich.substack.com/p/use-prolog-to-improve-...

Here's the hacker news post: https://news.ycombinator.com/item?id=41831735

Thanks! Macroexpanded:

Use Prolog to improve LLM's reasoning - https://news.ycombinator.com/item?id=41831735 - Oct 2024 (155 comments)

Re: I'm not mutable, I'm partially instantiated

#45
It seems like whether this represents a mutable or immutable data structure depends on the operations you allow. If polling with nonvar() is allowed, couldn’t you see variables mutate as you do more unification? But if it’s not allowed, I guess you get a variable to be defined later?

Compare with a Promise. If you can check whether it resolved, you can see it mutate. If the only operation allowed is to await it then from the code’s point of view, it might be considered an immutable reference to the pending result.

Re: I'm not mutable, I'm partially instantiated

#46
post #43
post #38

Earlier quoted context omitted.

Do you have a suggestion on where to / how to start learning Prolog beyond towers-of-hanoi? Prolog is basically the last language on my list of things I want to look at, but whenever I tried, I failed to find anything practical to do/try.

I’ve enjoyed https://www.metalevel.at/prolog but I’m not a Prolog Programmer.

Ah, thanks for the link! I know his YouTube channel, but somehow I never realized there is a webpage too!

Re: I'm not mutable, I'm partially instantiated

#47
post #16

Partially instantiated data structures are also available in Haskell (via Laziness), in OCaml (via tail modulo cons, https://inria.hal.science/hal-03146495/document ) and Koka (via constructor contexts, https://dl.acm.org/doi/pdf/10.1145/3656398 )

Laziness and TMC are fundamentally different from partial instantiation in that they are implementation details, mostly/wholly invisible to the language semantics themselves. A key aspect of partial instantiation is that the "holes" may be filled in by a semantically unrelated piece of code, which is not the case for either laziness or TMC (wherein the contents data structure must be defined in one place, even if the…

Yes, that is true! Koka's constructor contexts also allow you to do this. A constructor context is a data structure with exactly one hole which you can fill in with an arbitrary value (or even several arbitrary values, copying the constructor context in the process).

Re: I'm not mutable, I'm partially instantiated

#49
post #18

I am actually working on a logical query language that's a successor to prolog here: https://memelang.net/02/ . Any feedback appreciated!

Alternative would be interesting, but successor is thought provoking. Do you mean to say most all Prolog capabilities will be possible to do in Meme?

Re: I'm not mutable, I'm partially instantiated

#50

I've never used it in production, but I have a deep love of Prolog, just because of how different it is from any other programming language I've used. As a programming paradigm, it found it as eye-opening as functional programming. What I found interesting is that you are operating on logical statements and pattern matching, which often means that the same "function" can be used for multiple different things. For exa…

I always thought that pattern matching would be an excellent feature for other programming languages, but it seems that it hasn't become popular. Many strategies available to Prolog could become possible just by the addition of this feature. One possible implementation of the idea occurs with C++ templates specialized with numerical parameters. It also seems that Mathematica provides pattern matching, but I don't use…

Erlang, Elixir, Swift, Rust, Python, probably some others.

That list is roughly in order of how capable and useful the pattern matching is in each of those languages. Erlang was originally written in Prolog.

Also, I definitely agree it's a feature I miss everywhere when not using Erlang/Elixir.

Post reply on HN