Hacker News new | ask | show | jobs
by legionth 3125 days ago
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 more time than writing it in C, Java, PHP etc.. But I guess it is all training...

9 comments

I've had the opposite experience. In university and later, everytime I play with prolog, I love it. Some things make so much more sense when you write them this way, and it's not just the few very specific cases. When I learned about prolog and had the first couple of classes using it, I was delighted! Finally a language that works in a way my mind likes to think in.

I am not saying that one way or language is better than the other. But I'm saying that, like you are faster to rewrite in c or java, there are people that can rewrite or understand faster the other way. :)

Programming is fun!

I love Prolog, to the point of having taken part in the Portuguese university national logic championship back in the 90's.

On our degree, we had three logic programming classes, starting from logic programming as pure math all the way to deep Prolog exercises.

I didn't know there were Logic championships using Prolog!

P.S: Vocé é Portuguese, lisper e tambén fá de Prolog? You impress me more each day, pjmlp!

Obrigado, but actually it is due to quality of many of the teachers I had the opportunity to interact with during the 90's version of FCT/UNL. :)
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/

> You can write a quicksort in a few lines. You can traverse over a tree very easily. But understanding these few lines takes me more time than writing it in C, Java, PHP etc

I'm still only a beginner at Prolog, but that's what I enjoy about it: it's an entirely different way of tackling problems that really stretches my brain, not just new syntax on the same old paradigm that I already know.

Something tells me that it would probably be easier if this was your first programming language. Actually I expect that some would find this declarative style a lot more intuitive and natural.

But when you've spent many years writing imperative code it feels so alien. It reminds me of the first time I attempted to write Verilog, it's hard to break the mold and change the way you think about the flow of a program and how you construct algorithms. Eventually it clicked for me and Verilog though, so I expect with enough dedication one could do the same with Prolog.

I don't think working with numbers is a strong side of Prolog. Quicksort in Haskell is also 3 lines, but it's totally readable. I can make use of functional programming in my daily life, but logic? Never. But think of the Zebra puzzle. In Prolog the solution is 100% declarative.

BTW, I hate Prolog too.

I agree that is hard to think in prolog, formulating the problem as logic rules is not natural for us after we done imperative programming. I imagine this is true on small problems that are popular in education but in a real world scenario a hard problem(that is suitable for prolog) would be much harder to do it in C or other imperative language, and probably adding new rules would be easier in prolog.
Some problems are harder to express in Prolog (than in conventional imperative logic), but then there are some problems that are far, far easier to solve in Prolog.
KIT?
You can learn prolog at more than one university in the world.
Sure, but some courses are taught in more or less enjoyable ways.