Why Learning Prolog Can Make You a Better Programmer
coliveira.net
coliveira.net
* Constraint Handling Rules, http://dtai.cs.kuleuven.be/CHR/
* Gecode http://www.gecode.org/
* Monadic Constraint Programming Framework (Haskell)
http://people.cs.kuleuven.be/~tom.schrijvers/MCP/
* Google Operations Research http://code.google.com/p/or-tools/
* Mozart/Oz http://www.mozart-oz.org/
* Datalog 2.0 http://datalog20.org/I'm about 2/3 of the way through the book, and I highly recommend it to anyone looking to learn the language in a more or less rigorous way. It won't make you a production Prolog programmer (any more than SICP will make you a production Schemer), but it starts with a firm grounding in the theory of logic programming, and works that up to a good grounding in Prolog step by step, before spending the latter half of the book working through idiomatic Prolog solutions to a bunch of standard (once-standard?) problems (a shell, an interpreter, a compiler), as well as problems more in line with Prolog's traditional uses (ELIZA, an expert system).
The book is here:
http://www.amazon.com/Art-Prolog-Second-Programming-Techniques/dp/0262193388
``The Craft of Prolog'', which this post mentions is in the same series, and provides somewhat of a more pragmatic view of the language. I may get to that next. Meanwhile, ``The Reasoned Schemer'' provides the entry of ``the Little Schemer'' series into the field of logic programming, using the MiniKanren logic programming system for Scheme.If you're a Clojurian you can give my bells & whistles implementation a spin: https://github.com/swannodette/logos. It has good performance, tabling, pattern-matching, and disequality constraints.
I also recommend the hell out of _The Art of Prolog_. Have done so here, many times. Also: Prolog systems with constraint extensions are MUCH more powerful. SWI Prolog (http://www.swi-prolog.org/) and GNU Prolog (http://www.gprolog.org/) are both good.
I disagree with seeing prolog classified as functional - my experience with functional programming in lisp had a very very different view of side effects than my experience with declarative programming in prolog.
Sure, learn prolog and you'll learn more about programming, but that's true of any programming language. I'm not convinced the benefits of learning prolog exceed the benefits of spending the same amount of time on something else. The main thing I learned in a prolog class was the huge danger of relying heavily on facts without also considering confidence in those facts. I can learn the exact same lesson if the declarative language I choose is SQL, with the added benefit that I might get to use the SQL someday.
That said, I've always considered prolog to be the language that most threatens our sanity. Perhaps it's because the Graduate Assistant that taught my Intro to AI course was a bit cracked (he tied his shoelaces around his legs once in class because they "offended him"). Or maybe because I haven't been entirely sane since that class....
It's been a while (some decades) since I wrote my last prolog program but this seems to be rather wrong to me. First of all, there is also the paradigm of logic programming and prolog is it's best known child. I don't think you can equate logic programming to functional programming. Secondly, there are no method calls as such. IIRC a prolog interpreter basically does a depth-first search on a graph made up of assertions. The very point of prolog is though that you don't tell the interpreter "call this method with these arguments and then do that" but rather you tell it "show me valid solutions that fit this template assertion, do however you think is best". At least that's what simple interpreters did. I don't know what more sophisticated compilers like gnu prolog made out of it. Please somebody correct me if I'm wrong. It's possible that my memory fails me.
it's a declarative language though, and the model you have 'here is a query, what solutions exist' is reasonably accurate
:- dynamic bla/0.
proof_me :-
\+ bla,
assert(bla).The same's true for other langauges that offer different ways of thinking of about world: the LISP family, Haskell, Eiffel, Forth, awk, ...
Also, I'm getting fatigued by authoritative talk about computer science curricula in the same "kids these days" manner as someone convinced the world is falling apart while actual violent crime or teen pregnancy statistics drop. I'd expect claims like Oliveira's to be supported by some kind of data we can be privy to instead of vague anecdotal impressions.
"Schools are more interested in teaching marketable languages." Ok. All schools, most schools, state schools? Where's justification for "It seems like that they are looking for ways of getting people through the program as quick as possible"? Why does it seem that way?
sadly, most people when taught barely get past the 'parents and grandfathers' stage of programming.
why not something else? sure! erlang is actually pretty neat (otp is golden) and was originally implemented in prolog. why not learn a term re-writing language? what about snobol?
why prolog? well,
prolog for me has just been one of the most fun and interesting experiences I have had while programming. good prolog code is elegant in a way i've never seen in other languages and it's a big rush when you crack the puzzle of expressing your problem.
prolog was also used in ibm's watson and shipped as part of nt too :-)
It is almost as if prolog didn't make him a better programmer, given the idea that prolog 'returns values' or uses 'method calls' is 'not even wrong'.
Seriously, our attention span, time on this earth and even ability to learn is limited ;)
The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence.
-- Dijkstra
http://www.cs.utexas.edu/users/EWD/transcriptions/EWD04xx/EW...
-- Guy Steele
Notice that he lists COBOL as a language to learn. I've always found Dijkstra to be a little over the top (often the only way to get people to listen), and Steele more pragmatic.
http://www.infoq.com/interviews/Programming-Languages-Guy-St...
The starting language matters very little, the important part is to remain curious and to keep learning.
"In Computer Science programs, there is a tradition of having a course of two that represent the watershed between people that can grok CS concepts and the ones that can’t. "
Would those HNers who've been through a masters or PhD in CS help an uneducated brother hacker and list any such "watershed" courses they know of? Thanks in advance.
EDIT: links to course home pages would be highly appreciated, plus any reminiscences of how tough these courses were/felt like.
There's nothing like building a simple OS, compiler, and pipelined CPU to transform "the computer" from a magical black box into a supremely powerful, interesting tool.
Really, though, I'd say AI. Mainly because there is often no a "right" answer, just the "best" one given the inputs and problem space. It gets you thinking in a more non-deterministic way, if that makes any sense.