Teaching Prolog in an undergrad Programming Languages course
About This Page
This page came about because a group of Prolog programmers on ##prolog IRC channel got
frustrated with the constant stream of CS students coming in who were having a miserable experience
in a 'Programming Languages' course. We decided to try to write up a help sheet for instructors teaching
As our cartoon friends observe, the real issue is the design of the course. Four languages in 8 weeks
is unrealistic. Add in a felt obligation to actually teach some language theory, and you've got an impossible job.
Here's a collection of advice we've got some rough concensus on. Most/all of it is in the cartoon:
- Don't use toy problems. Show simple, real examples, just as if you were
teaching any other language. Avoid using the class as an excuse to show off mathematical tricks.
- Accept that it's a language, and you have to teach basics of syntax and environment.
For example, hello world is a better first program than family tree. Provide support for students
to get their development environment going.There's a basic problem with the way the course is structured. It's too much ground covered
in too little time. Accept that and show students a little, rather than
trying to cram too much in.
- Don't introduce concepts and a new language at the same time.
For example, a partial evaluator is not a reasonable project. Separate
teaching theory of programming languages from teaching specific languages. It's not true that the best way
to learn the concepts is to implement them in a language you barely know that depends utterly on the
concept you're trying to teach.
- Think about what stories beginners tell themselves about Prolog. For example, novices often talk about
what gets 'returned' from 'functions'.
- Don't introduce Prolog as a domain specific language. It's rude and denigrating to the Prolog community,
and keeps students from taking the subject seriously.
- Prepare adequately for teaching. Know both Prolog and the specific prolog system
you're using well enough to assist students.
- Don't hand out assignments with a big block of code and ask students to fill in the missing
piece. Understanding code requires the same skill as writing it, but gives few opportunities to learn.
- Give your students some sample programs long enough to have the small pattern they need.
Not everyone learns well from Backus- Naur format, and your
one liner won't help the students when they have to write real code.
- Don't give students assignments that demand they do things no real programmer ever would -
like 'write a predicate that does X without using language feature or library predicate Y'
- Admit that there's an execution order in Prolog. Don't say things like 'don't understand it
imperatively, understand it declaratively'. Declarative coding is nice when you can do it. But
it's not the way real Prolog programmers program all the time. Being willfully ignorant
is rarely a good pedagogic device.
- Show students how to do the equivalent of simple structures like conditionals and loops.
They'll go looking for them anyway. We've found the explanations on this FAQ useful.
- Make clear the difference between queries at the top level and knowledgebase entries in a file.
to type in predicates at the top level and are puzzled.
A Few Resources
If you have comments or suggestions for this page, please email annie66us (at) yahoo.com