Live data from Hacker News

Introduction to logic programming with Prolog

matchilling.com

51–60 of 93 posts

Re: Introduction to logic programming with Prolog

#51
post #4

I hated it in university and hate it until this very moment. I get what this language is doing and why it is great for special usecases. But I can absolutly can not read code written in Prolog. Staring at 3 lines of code and not knowing what the hell it does, gives me nightmares till today. You can write a quicksort in a few lines. You can traverse over a tree very easily. But understanding these few lines takes me m…

I found that these kinds of languages make a LOT more sense after learning some logic [1], specially relational logic, to the extent that it's essentially the same thing.

[1] http://logic.stanford.edu/

Re: Introduction to logic programming with Prolog

#52
post #28
post #5

I find the section 5.3 from the paper "Out of the tar pit"[1] describes it very well: > It is for this reason that Prolog falls short of the ideals of logic programming. Specifically it is necessary to be concerned with the operational interpretation of the program whilst writing the axioms. I haven't heard of any approach that generalizes the goals of logic programming in a far better way. Is there any? (on specific…

What you're looking for is called answer set programming. It has pretty much replaced logic programming as a research focus, and a number of implementations exist.

Thank you - I didn't know about it (#^.^#); got some reading-up to do now....

Re: Introduction to logic programming with Prolog

#54
post #38

Earlier quoted context omitted.

That is the best way to introduce computers to a kid: "let it do the hard work for you". Logo used to be very popular for kids here in the '80s. I learnt Logo when i was 7, then i "progressed" over the years to Basic, C, Pascal, C++, Java, C#, Python and now, after about 28 years, Lisp. And now I realize Logo is close to Lisp in many ways and a far more powerful language than some of the ones I "progressed" to.

It's always been interesting to me how Logo, a Lisp dialect, was so successful as a language for teaching children to program, but so many people still go around with the idea that Lisp is really hard to wrap your head around.

>that Lisp is really hard to wrap your head around.

It deserves a blog post, but I'd say Lisp (at least Lisp in its mainstream Common Lisp incarnation) is easy to learn but extremely hard to master, since it allows many possibilities and paradigms, and because of the power of meta programming. So to master it, you would be familiarized with all the paradigms and you would know how to leverage meta programming, etc. Also, since it allows improving performance by going to low-level details (like observing the assembly output of your function), you would better know a bit of assembly/machine language if you want to be able to improve the performance of Lisp to approach (or equal) C code. So previous experience with low-level programming, at least with C, would be a good prerequisite.

But yes, using it for simple stuff is easy, and in fact, while I consider Python a great "first language to learn", sometimes I feel that Lisp isn't much difficult than Python, for the same tasks. Python is much easier to master, but then it is much more limited.

Re: Introduction to logic programming with Prolog

#55
I agree with what Sylvain Soliman said about this on Reddit: It's a nice tutorial for the 80's parts of the language:

https://www.reddit.com/r/programming/comments/7hp2xw/introdu...

In modern Prolog systems, you would use more declarative features such as constraints to model combinatorial tasks like map coloring.

Make sure to check out modern Prolog features if you are interested in learning the language seriously!

Re: Introduction to logic programming with Prolog

#56
post #19

I try to introduce my boy (12) in programming trough Scratch but still no big success. However, we solved recently two math homework exercises with Prolog (logic) and MetaPost (geometry) which caused some effect, so I'm thinking to deepen in that languages or may be switch to Logo as intermediate lisp like solution.

I know a young child who is going through Scratch, but also no big success, but then the child was introduced to Racket and is now using it as a math companion tool, such as for visualizations and calculations.

The child was encouraged to build general solutions to homework, and suddenly a lot of schoolwork with tedious arithmetic seems boring to the child.

Re: Introduction to logic programming with Prolog

#60
post #55

I agree with what Sylvain Soliman said about this on Reddit: It's a nice tutorial for the 80's parts of the language: https://www.reddit.com/r/programming/comments/7hp2xw/introdu... In modern Prolog systems, you would use more declarative features such as constraints to model combinatorial tasks like map coloring. Make sure to check out modern Prolog features if you are interested in learning the language seriously!

are modern prolog just a layer on top of the old semantics or somehow an incompatible paradigm ?
Post reply on HN