A thing that got me into logic programming was trying to explain the rules of games like chess to a computer, and that I think is the killer app for Prolog.
A starting point for me was a MooC I did a couple of years ago given by Stanford University which sadly no longer seems to be given, though it still has a website at http://ggp.stanford.edu/
Stanford’s General Game Playing movement seems to have fizzled out – I tried to subscribe to its mailing list a while back, and it seems to be dead – which I blame on it using a weird Lisp dialect instead of plain-vanilla Prolog.
Whereas the accompanying online textbook taught Infix Game Description Language (GDL) which is pretty much Prolog, all the hundreds of strategy games developed for a competition to promote interest in AI at http://games.ggp.org/ were written in the Lisp dialect whose supporting software consisted of one, now unmaintained. Java program.
I’m not a teacher, so have no idea if Stanford thought creating this confusion between infix and prefix GDL would be educational. My view is it just killed what could have been a great AI teaching tool.
I initially thought translating the Lisp dialect into Prolog would be easy, and ended up with a chess player riddled with bugs (which I’m busy fixing, since we have a very draconian Covid-19 lockdown where I live in South Africa, so I have plenty of time on my hands at the moment).
But the basic point is that pattern matching languages such as Prolog are ideal for Game Description Languages, making them a lot easier to read and write than in traditional C-family languages.
I personally am convinced that learning different programming languages teaches “transferrable” skills, just as you describe it.
I can’t disagree about this, but there are some considerations that could taint the analogy. Here is a short and definitely not exhaustive list (and I can make counter-arguments to everything I am about to write, but won’t, just to keep it short):
Natural languages evolve naturally (hehe) and co-evolved with the human brain. Programming languages have been engineered.
Small children don’t learn in the same way as grown-ups, or to put it differently, as we get older, learning just gets difficult.
Natural language is usually used for informal communication between humans. We (humans) tolerate a lot of variation, which is one of the reasons why natural languages evolve and change as fast as they do.
Mastering a language (natural or programming) is a very long process; this is why I would say that priorities and time are still important.
hi, I use prolog as a programming language since I first experienced it at the university in 1990.
at that time there was only Turbo pascal, Basic, an C for Ms dos.
I use still use prolog compiler and interpreters for various things.
Prolog and also swi-prolog has connections with python with C and with java, so there it cant be a danger to use it
the reason for not using prolog yet in companies could be that still 90 procent of the companies is still only building so called user-applications or web applications where they only implement user interactions with data connections.
I mean to say that almost nobody is building knowledge intensive systems yet,
and that time still has to come
In my case i would prefer to write a prolog program which generates python code instead of writing the python code myself. Also java code is very well suited to be generated from prolog, i would prefer that as well instead of writing the java code myself.
In my own life I use prolog for example if I need to convert and read for example Csv data files.
with prolog you can experience some sort of Magic, which is less the case in procedural languages, where you are endlessly coding forwards.
If for example you need to analyse images and generate movies on Ubuntu?
, I would then use swi-prolog in combination image magick.
Swi prolog is very good for web-applications, it can do the same as PHP with mysql and apache server and more, and the code is a lot easier to write and read than php.
Yes, we are building such systems. There are relational databases that cover to some degree. Developing is a real pain though.
There are real problems in this space, Oracle is not going away in a hurry, the most useful features of relational databases are proprietory, and again, writing SQL is such a pain that people have been coming up with all kinds of programming acrobatics to avoid it. But “momentum” is a real thing and I really can’t see a language like Prolog taking the place it deserves soon enough
I wasn’t planning on chiming in but some awesome features of Prolog that I see worthy of note are using Prolog for it’s prototyping ability (term rewriting) and meta interpreters. These are not things beginners get into so many of the people who don’t have nice things to say about Prolog never get to this level and see how beautiful Prolog is at doing this.
While you may never use these concepts in a job, the things you will learn about programming while on the path to learning how to use these concepts will open your eyes to many vistas few programmers ever see.
I tell myself that eventually everybody and all companies will use Prolog for many things.
Maybe indeed the question is wether that is soon enough as you say.
Currently we, me and my companion are building a webservice completely written in swi-prolog.
In this example we need to do a lot of data inferences on the server to display intelligent data to the web-end-user,
we use a lot of data-files which, at the moment, we completely load into memory, the data queries we perform in this case would almost be impossible in Mysql as a mysql Query, ( it would get to slow,
Or the query would become absolutely unreadable, and also impossible to extend further )
I’ve spent the last 15 years as a consultant in the embedded field and I use them on pretty much every contract, OK, not every contract but if I’m doing a biggish job that can justify some time spent building an executable specification then I will. An executable specification in these cases is just a Prolog program comprising some operator/3 calls to give me nice syntax, some rules using that syntax (usually > 30 rules so too many for ‘manual’ reasoning with my poor brain), and a demo predicate to give me answers I’m looking for.
In situations where you would see someone reaching for some formal modelling languages like Alloy, Promela, and the like, I’m knocking up a quick Prolog like interpreter. The logic programming research community wrote heaps of papers in the 80s and 90s showing us how to do this. Pretty much all of it is free to access on the web. All we have to do is want to use it!
In this article, the authors give an overview of tool-based verification of hardware and software systems and discuss the relation between verification and logical reasoning. Here, “verification”’ refers to reasoning-based methods to establish dependability. This isn’t restricted to proofs of functional correctness; it also includes other scenarios such as test generation and bug finding. The authors describe the main verification scenarios and methods that are in use today and the extent to which they depend on logical reasoning. From this discussion, they distill current trends and new opportunities for the interaction between verification and reasoning.
Prolog isn’t mentioned, instead systems like ACL2 or HOL are. These are meant to help in theorem modeling and proving rather than allow one to code “searchful programming” like Prolog does. But one has to get in on the ground floor…
writing SQL is such a pain that people have been coming up with all kinds of programming acrobatics to avoid it
SQL is ugly as a language, but the principles are very sound and rather straightforward. It’s just that coders try to avoid it for all the wrong reasons (reluctance to learn something new & declarative and a misguided idea that everything must be the same language, I went through the same mindstate). Therein likes waste & failure.
You have a problem: You need to write SQL queries but you don’t want to get into SQL
You use a framework to isolate yourself from having to learn SQL.
Now you have two problems:
A complex, illogical framework, that injects bugs, especially in concurrent applications
And its attendant pseudo-SQL language meant to recover the flexibility lost by 1
Seriously, EJB3/JPA over Hibernate? Utter madness!
But things like Jooq are a real improvement. Embrace SQL!
Btw, I noticed that SWI-Prolog offers this library:
I will be starting for your description … I am from Brazil also and had my first contact with Prolog in 1987 (surely you are not born yet). In addition of many comments done, I would try to resume in:
Prolog brings a rich heritage from the logical world, with concepts embedded and other no. Anyway, these math concepts are taught in a course of logic. As I know a little of our reality in the universities, probably if you have some contact with the first order logic (FOL), probably, which the concepts and definitions are applied in the Prolog. However, in a regular course of logic, here in Brazil, normally the theoretical approach is taught dissociated from a practical use. This dissociation happens for the several reasons. Surely, as your background is in math, you will enjoy a lot of the Prolog.
Finally, if you must learn, the answer is YES:
The learning curve of Prolog is fast for the beginners
To verify all the math foundations in logic
To expand you thought of programming
To solve some problems where the logic paradigm “wears such a glove”
Many years ago, I did some videos on Prolog for my students. These videos are in PORTUGESE (you are native), so, you can start by there, check my channel in Youtube,
Start from this video for instance: Prolog e seus elementos
Well, I hope to help you in this discussion, very well posted by Paulo, Jan, Eric et all
I would say Prolog is -the way- to create the new programming languages and tools and frameworks of the future…that’s -EXACTLY- why I am re-coding my computer language in it, from scratch. It’s been a long and hard road but definitely worth it as I have increased my knowledge and understanding of not only “logic programming” but the embodiment of a lot of it in the language we call Prolog.
Like Lisp, it will change the way you think about problems and can only help to make you a better prospect to be hired?!
So, if you want to learn something that will, ultimately, make you very very productive once you “get it”, and the learning curve is long and steep in places (like anything worthwhile I guess) then go for it!
Yes. The idea was every new problem would spawn a language. Well, designer logics they called it in logic programming circles but it was the same thing. This style of thinking was the knee-jerk reaction of old school lisp and prolog programmers working in AI. Here’s some words to live by:
A programming methodology often used in AI, as well as in other fields, is stratified or layered design. When faced with a problem, rather than implementing a solution directly in some base language, a new, more appropriate, higher level language is designed in which to express a solution, and this is implemented in the base language. This methodology can have several iterations yielding as a final solution a hierarchy of different languages each more appropriate to expressing the solution than the language below. — Bowles and Wilks in Tracing Requirements for Multi-layered Meta-programming, in Meta-Programming in Logic Programming by Abramson and Rogers.
@bwat I take your point althought that’s not what I meant in my comment. Having been a software engineer for 35 years and used everything from assembler, Smalltalk, Lisp, Erlang, countless years of C/C++, Java etc etc yadda yadda…and having used yacc, bison, antlr, PEG toolkits until I feel sick, I realise that what I really needed all along was DCG-s and Prolog and nothing more!
There is “something” about Prolog I can’t pur my finger on but just lately, in the last few weeks of intense effort on my language project, things are clicking especially regarding the full enormity of unification and back tracking that make me wonder (a) why’d it take so long to “understand” and (b) why couldn’t I have learned Prolog 35 years ago!
People with roughly 3x my experience in software development in the large have been completely unaware of Prolog’s actual strengths, despite having “learned” it in university. This seems to be common. Actually, it is so common that I am certain that I am still missing a lot of important things about Prolog in particular and programming and software development in general.
As is, experience shows that the only road to that kind of understanding is just working on it with your own hands and head (whatever “it” really is…)
I’m going to take your statement out of context on purpose just so I can make a point Right, there is a problem with language exclusivity:
If we need a new data structure we create a new library.
If we need a new control structure we create a new language.
Prologians (and Lispers) are experts with meta-interpreters so the new language thing is easy. What I had drummed into my head was we shouldn’t use Prolog if we can create a language that is better. We were supposed to create languages like mathematicians create notations.
In the book Eco-Logic they develop a order sorted ‘Prolog’ with functions for ecological modelling. Once you see how easy it is to do taxonomical reasoning with order sorted logic and mathematical modelling with functions, there’s no going back to Prolog for that sort of thing. I implemented their language in 267 lines of well documented Prolog. I can add Prolog prdicates as built in predicates of this new language with one line - one line. Why would I use Prolog?
Oh, I know the feeling. I was taught Prolog in the early 1990s but only really ‘got it’ when I implemented a WAM, compiler, debugger, and all that in around 2014. I always knew there was something to be gained from that type of programming but professional programming (pretty much all the languages you mention) got in the way.