TeX/MetaFONT/MetaPOST
‘m finally seeing the beauty of TeX, through the agency of MetaPOST. The syntax is still very ugly, IMO, but necessarily so. What’s important is that it is *very* permissive. And I’m also seeing, I think, why TeX has been favorably compared to LISP.
How to go about explaining? Well, the whole thing began with my downloading some example MP code that Alan Kennington so kindly has put up for public viewing. I noticed that in some of the diagrams, he drew heavily on the macro aspects of MP. For example, in MP, to specify a smooth curve joining n points, you would use this line of code: z1..z2…z3..{other points here}..zn. In plotting a section of the curve of some analytic function, he wrote code equivalent to this:
z1..
draw for t=1 to n:
.. zt
end for
Of course, that syntax is incredibly not MP correct, but you should get the gist. In what other languages can you do anything even close to that? I can only think of two: Postscript and LISP. I think this really points out that simple is better; because those languages expect everything to resolve itself into simple components (in the case of Postscript, elements on a stack, in that of LISP, atoms, and in that of MetaPOST/FONT, sparks and tags), and allow anything that will resolve itself in such a manner to be syntactically correct, they are extremely powerful. Although I guess the old truism that such languages would be inefficient for use in large programming projects is valid.
Anyhow, the point is that I realized that such powerful constructs are also available in TeX, because like MetaFONT/POST, it is essentially a macro (text-replacement) based language. I wonder why more recent small languages aren’t so well designed?
Possibly relevant posts:
- Code Highlighting Added (2/2/2005)
- My metapost night (9/20/2005)
- Implicit Plotting code for Mathematica (8/30/2007)