Ah, a seven-year-old question with plenty of perfectly acceptable answers.
I'd note from a "why" perspective, Barbara Beeton's comment:
when knuth created tex, he was intending it for use by himself and his secretary, and he designed the language that he thought was most appropriate for its intended use -- typesetting. he didn't foresee its adoption by so many other users
and Victor Eijkhout's answer
TeX is not a regular programming language: it's a "macro expansion language".
do the most to get at the heart of the question.
Much of the primitive syntax is based around making keyboarding as ergonomic as possible for DEK's use case¹ and a lot of what's happened with macro development in the nearly 40 years since TeX82 was released has been around trying to make things more regular (the random placement of @ in “private” command names is one instance of bad irregularity). I think that Frank Mittelbach’s Teutonic temperament goes a long way to making this sort of thing happen² with expl3 and various LaTeX extensions from the team. But of course, LaTeX, having grown in a disorganized fashion over 37 years has plenty of inconsistencies to go around, including multiple key-value implementations and conditional syntaxes (e.g., as Steven Segletes gave an example, there are macros which have a general format of⁴
\somename{CONDITION}{TRUE ACTION}{FALSE ACTION}
xparse (among others) provides multiple variations of its conditional commands, e.g.,
\IfBooleanTF{ARG}{TRUE ACTION}{FALSE ACTION}
\IfBooleanT{ARG}{TRUE ACTION}
\IfBooleanF{ARG}{FALSE ACTION}
which is also present in expl 3 syntax which has, for example:
\bool_if:nT {CONDITION} {TRUE ACTION}
\bool_if:nF {CONDITION} {FALSE ACTION}
\bool_if:nTF {CONDITION} {TRUE ACTION}
(In general, expl3 is an attempt to turn TeX's macro language into something approaching a more familiar programming language, although there are some occasional oddities like using the term map for what's really a foreach).
- Someone can doubtless more easily dig up his comments on why he preferred
{1\over 2} to \frac{1}{2} etc.
- I'm simultaneously awed and bemused³ by the tendency of German individuals and institutions to engage in systematic arrangement of things
- Yes, I meant bemused and not amused.
- Note that TeX's processor can get confused by having a macro name start with
\if… so that naming is generally frowned upon unless it's a conditional created with the primitive \newif.
etoolbox's conditionals for example. – cgnieder May 23 '14 at 18:33\newif\iftestA \iftestA \let\x\iftrue \else \let\x\iffalse \fi \bye. Mastering the TeX syntax with conditionals takes a lot of time! The LaTeX andetoolboxconditionals are much safer\iftest{arguments}{YES}{NO}and such style is even almost necessary in certain circumstances. Naturally, underneath, it all boils down to careful wrappers of the TeX primitives. – May 23 '14 at 18:53for eachprimitive instead of recursive loops)… TeX was never meant that way – it is meant to be written in a meaningful, readable order (no libraries or functions) and self-documented. Most humans that know programming languages do not think like Knuth, and do not see code as some form of prose. – ienissei May 23 '14 at 20:50:)Besides, I have the impression Maslow's hammer applies here as well.:)I remember of the arithmeticIFin Fortran and different decimal marks in ALGOL, so your mileage may vary. Personally, I believe this question turns more opinion-based. – Paulo Cereda May 24 '14 at 11:13