[Tex/LaTex] Why is LaTeX so complicated?

latex-misctex-core

I have been using LaTeX professionally almost every day for almost 10 years, so I think I can say that, by now, I more or less know what I'm doing. I also do a lot of ordinary computer programming, in traditional languages like C++ and Visual Basic. As I compare LaTeX to these other languages, the following question often comes into my mind:

Why is LaTeX so complicated?

Despite my considerable experience with LaTeX, I still regularly encounter non-obvious behaviour and strange error messages, and there are many parts of the language that seem arcane and obtuse. Here are just a few examples:

  • Macro hell: tangled webs of junk (\relax, \csname, \let, \patchcmd, \expandafter, …) sprinkled throughout all but the simplest macros
  • The ridiculous \makeatletter and \makeatother all over the place
  • Nonlocal error messages which can be difficult to fix
  • No straightforward types (int, bool, float) with the ordinary manipulation functions. Instead, a patchwork of different types of counters and registers, each of which have to be manipulated in their own special way (sometimes 2\mynum, sometimes 2*\mynum, sometimes \multiply \pgf@x by 2, sometimes \addtolength{\mynum}{3}, …)
  • Loops and conditionals are much more fiddly than they should be
  • No arrays
  • Checking for equality is ridiculously awkward (\equal{\mybool}{true}, …)
  • No straightforward subroutine syntax
  • Fixed memory limits rather than dynamically-allocated registers
  • No incremental compilation in most LaTeX engines – if I change the last line of my document, or make a tiny change to a TikZ figure, I shouldn't have to spend tens of seconds recompiling to see the effect

I could go on.

Let me be very clear about one thing: I have the greatest respect for those who developed TeX and its associated programs and packages. The system is enormously impressive and awesomely powerful. Also, every apparently-arcane feature I mention above of course exists for some good reason, and (at least) at the time it was designed, solved a real problem in (at least locally) a sensible way. And other programming languages of course have their flaws.

But surely, it is nonetheless appropriate to recognize the complexity and limitations of the system as a whole which exists now, and ask: does it have to be like this? If we could design a typesetting system completely from scratch, in 2015, couldn't we make something much simpler and more intuitive?

Best Answer

Although this question (and this answer) will stir up opinion, rather than fact, and so get teleported into Moderators' Oblivion, I'm going to have a crack, with a few ideas:

  • TeX is very old. It was written when (a) there wasn't enough CPU power around, and (b) when all it basically had to do was produce something that was going to be printed. But now it has become the hammer that makes everything look like a nail (validly or no): different output formats (eg PDF, HTML); animation; ebooks; slideshows, and more.

  • There has always been a serious concern -- "Thou shalt not break a legacy document" -- which, IMO, has inhibited possible approaches to "cleaning up" the language.

  • Like all programming languages, it has suffered what I call biological decadence: new users learning bad habits from old users. Even here, on TeX.SE, it is possible to see "correct answers" languishing while "answers which merely work" get accepted.

That said, there is light on the horizon. I believe the LaTeX3 project is heading firmly in the right direction to ensure that us end users (the "authors") see much less of macro hell and expandafter purgatory than hitherto necessary. So:

  • Support the LaTeX3 project in any way you can;

  • Think very carefully about whether LaTeX is the right vehicle for your particular document in your particular epoch;

  • Here on TeX.SE, when two answers both work, favour the simpler one

Related Question