Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!jarthur!nntp-server.caltech.edu!marcel From: marcel@cs.caltech.edu (Marcel van der Goot) Newsgroups: comp.text.tex Subject: Re: Why use TeX if ... Summary: TeX is easy to use, but not necessarily easy to program Keywords: TeX, PostScript, typesetting, page description, programming Message-ID: <1991May11.013248.16286@nntp-server.caltech.edu> Date: 11 May 91 01:32:48 GMT References: <1991May9.204113.17636@beaver.cs.washington.edu> <1991May10.065219.23433@agate.berkeley.edu> <1991May10.211802.4344@csrd.uiuc.edu> Sender: news@nntp-server.caltech.edu Organization: California Institute of Technology (CS dept) Lines: 165 [ NOTE: This is quite a long posting --- sorry for that. There is a summary at the end. ] We've recently had a number of postings about ``the TeX language,'' its perceived shortcomings, and comparisons with other typesetting systems. From pauld@stowe.cs.washington.edu (Paul Barton-Davis): > The hacking problem is primarily caused by the fact that the TeX > extension language was designed (apparently) as a macro replacement > language. If TeX has a "normal" or "proper" programming language, then > it would a lot easier to extend, without getting used to its > arcane grammar. As Victor already pointed out, TeX doesn't have much syntax; what syntax there is, such as what a number looks like, is fairly straightforward. The only hard part is the lexical scanning (i.e., the conversion of characters into tokens). Also, the history of programming shows you wrong: ``hacking'' (used in the negative sense) occurs in all programming languages. The hacking problem is caused by programmers who lack knowledge about programming techniques. From edward@priam.Berkeley.EDU (Edward Wang): > I agree. I can think of three things wrong with the Tex language: > textual substitution macros (rather than functions or even > Lisp-like macros), TeX is indeed based on macro substitution, rather than on the constructs found in conventional programming languages. But then, TeX is not a general-purpose programming language, it is specifically designed for typesetting text. It is much more of an application program than a programming language. An important difference with a ``normal'' programming language is that the typical user wants to present TeX with the text to be typeset. In other words, the typical user does not want to be concerned with programming at all (most readers of this newsgroup are, in that respect, probably not typical users). As far as I can tell, the only way in which you can have the freedom of presenting your input as almost plain text, with very little knowledge about the details of the underlying programming language, is with a language based on macro substitution. A conventional programming language with strict syntax means that your input has to obey very strict rules. It is true, TeX's macros take some getting used to, because of the complexity of the system. What you get back for that is an unparallelled freedom in the form your (normal text) input can take. You can make TeX look like LaTeX (which is only somewhat different), but you could for instance also make TeX look like troff. With a normal programming language that is impossible: A C program always looks like a C program, a pascal program always looks like a pascal program, and a lisp program always looks like a lisp program. You cannot decide, ``let's give an end-of-line the meaning of a semi-colon'' so that you don't have to write semi-colons in C; You cannot decide to use square brackets instead of parentheses in lisp. And these are only very minor variations, many TeX macros do much more. Is it important to have so much control over the form of your input? Yes, it is. Not so much for you programmer types. Programmers are used to obeying strict syntax rules. But it is important for people who do the actual writing of the books, papers, letters, etc. For those people the ease of *usage* of the macros is important; TeX can make that very easy. Of course, that means that the *construction* of macros becomes more complicated. In short: TeX's macro language makes input of text much easier than any conventional type programming language could; the price is the increased burden for the macro designer. (Edward Wang) > dynamic scoping (lexical is better, both is best), > lack of a programmer-visible representation of text (boxes are not enough). > On the last point, it would be sufficient to have a side-effectless > way to map text (strings as in the input document) into typeset text. > As it is, the result is inconsistencies like Latex's fragile commands. Dynamic scoping is pretty much inherent in macro languages. Lexical scoping requires strict syntax rules. I have no idea what you mean by your last remark: what side-effects are you talking about? You can represent strings as strings (in macros or token registers). Once you *typeset* something, a lot more things than just the text is involved. For instance, the font in which something is typeset. I think that that is much more a problem that LaTeX's fragile commands have. Paul Barton-Davis adds to that: > Add to that - too many primitives. Even Common Lisp, perhaps the most > burdened common language when it comes to primitives, doesn't come > close to TeX (this is a top-of-the-head assertion that I should really > check). Things like vbox and hbox should, in my opinion, be some way > above the primitive level. [...] As I said, TeX is more an application program than a programming language. The main purpose is to typeset text, not to program macros. Therefore, the comparison with Lisp doesn't make too much sense, I think. Why should vbox and hbox be at a different level? (I assume you mean, expressed in terms of other primitives.) and: > only traditional typesetting > systems. TeX's language is a pretty good model of that process, but > doesn't reflect the much more powerful models that PostScript and > other PDL's have given us. Well, TeX is a typesetting system, whereas (as you say) PostScript is a page-description language. If you take a standard book on PostScript (say the reference manual or so) then it will almost certainly tell you the difference. Very few people want to write their text directly in PostScript. Instead, PostScript is usually produced as output from some other typesetting system (for instance, TeX). TeX's PDL is the dvi format, which is indeed less general (but more efficient for the printer) than PostScript format. Also, aren't you shooting yourself a bit in the foot here: I think that PostScript has more primitives than TeX. (Paul Barton-Davis) > TeX's model is based on > ignoring the contents of each box, which works for general text, where > each set character can be accurately described by a box along with a > few extra details to handle areas where it is not contained by the > box. However, this doesn't work for images, and is very difficult to > work with when curves are heavily in use. Well, who claims that TeX is good for all kinds of typography? TeX is intended for typesetting things like books, papers, and letters. In such environments even pictures are typically indeed just boxes. How often do you see a picture in the newspaper that has the text flowing around George Bush's head (say)? Never: everything is cut at right angles. Such things, as well as typesetting along fancy curves, individual spacing between characters, etc., *do* occur in, for instance, advertisements and on posters. Sure, TeX is not very suitable for such things. ******************** Whew! That was long. A summary: When TeX is compared with other programs/systems, one should keep in mind what TeX is intended for. Since TeX is intended for typesetting books and the like, it should not be compared as if the primary use of TeX is as a programming language. The emphasis in the design of TeX is on the possibility to write easy-to-use macro packages, at the cost of hard-to-program macros. (That, of course, does not imply that all macros written are easy to use.) Since TeX is not a page description language, and since PostScript is, their comparison has very little basis. PostScript is best used with other programs that generate page descriptions. When it comes to typesetting books etc., TeX is one of the best such programs available. When it comes to different forms of typesetting, other programs may be more helpful. Finally: No perfect program has ever been written. TeX isn't perfect, and PostScript isn't perfect either. Marcel van der Goot .---------------------------------------------------------------- | Blauw de viooltjes, marcel@vlsi.cs.caltech.edu | Rood zijn de rozen; | Een rijm kan gezet | Met plaksel en dozen. |