Just some followup comments on the previous post.
When posting about the “Einstein puzzle” a few days ago, I found that there’s no “prolog” option for the sourcecode tag in WordPress. Now I wasn’t astonished by any means, because Prolog is (sadly) still rather obscure. And to the extent that it is a household name in the programming world, it’s more or less an object of ridicule:
Q. How many Prolog programmers does it take to change a light bulb?
Hehe! It’s still kind of funny.
Anyway, the numerous snippets of code had to be highlighted somehow. Without thinking too hard I picked C. The results were adequate, except that a) not much highlighting got done, and b) what did occur was spurious: some of my names were treated as keywords. It’s my own fault for conflating one language with another dissimilar on on the basis that I’m quite fond of both of them.
I have since tamed my sentimentality and done some actual science: I embedded a sample of Prolog in each of the 28 options on http://en.support.wordpress.com/code/posting-source-code/. As you might have expected, the results were so breathtaking that I will considerately omit 27 of the renderings, and present only the winner, Erlang:
% This is an example predicate. a_predicate(UpperCase, _) :- var(UpperCase), write('_'). a_predicate(UpperCase, [H|Tail]) :- \+var(UpperCase), write(lowercase).
What is the Erlang highlighter doing right here?
- It’s treating the text from
%to the end of the line as a comment.
- It’s highlighting uppercase names differently from lowercase ones.
- It’s not (as far as I can see) picking out some names as keywords.
For some reason it doesn’t recognise single-character names like
H, nor the anonymous variable
_. And it doesn’t highlight symbols, which is a bit of an omission.
Nevertheless, it does a good job on Prolog (which is not surprising considering their closeness as languages, I guess). Consequently, I may be encouraged to write more about Prolog in the future, and perhaps contribute to its standing as something all programmers should learn a bit of.