Why is LaTeX so complicated?
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
'complicated' - surely everyone can agree LaTeX deserves that adjective.
No, I don't really agree. I think it is fairly simple to use and personally I have always found that a WYSIWYG style editing interface (on the few times I have tried to use one) is much harder to use and less intuitive.
If you want to make a list in latex, you find a document and "view source" and find that it's
\begin{enumerate}
\item zzzz
\end{enumerate}
so once you are used to the \begin
/\end
environment concept (which is surely no harder than HTML's <ol>
/ </ol>
element concept) a latex source file is pretty much self-documenting.
Now because latex is open source people modify it in all kinds of ways but the fact that it can be complicated to modify is rather different from saying that it is complicated to use. The reference in your question to standard programming concepts such as numeric types, subroutines etc. Means that you should be comparing programming functionality in Tex to (say) modifying the C++ sources of OpenOffice. It's different but not necessarily more complicated, but either are considerably more complicated than simply using the system to produce a document.
It's definitely true that the tex programming required to make a latex2e class is more intricate and less documented than would be ideal, which is something the latex3 project is trying to address, but that has little effect on most users of latex who can simply produce a document using a supplied class.
Many users use latex quite happily for decades without using any of these
Macro hell: tangled webs of junk (\relax, \csname, \let, \patchcmd, \expandafter, ...) sprinkled throughout all but the simplest macros
Similarly If you have "\makeatletter
all over the place", you should ask why you have that, that is a hook to access code that the author has intentionally made hard to access from a document, so it it is not typical use it is inline modification of the code of the system, if such modifications are complicated, so be it.
I think I can take a stab at this without being opinionated up to a point since I'm both a reasonably OKish TeX user (definitely not even close to TeXpertise) and I still think it is hard for anyone who is not actively participating in the development or answering with macro manipulations here or elsewhere.
I might rephrase your question as,
Why do we need to go down to the guts of TeX so often? Why is it so hard to design a consistent frontend in TeX?
This is due to, as far as I experienced with people I've helped with, three major and a couple of minor reasons.
TeX as a language is weird. There is no other way around saying this. However much of this weirdness comes from the fact that it is an esoteric language or just obscure. There is no OO language that resembles TeX and at the same time also popular.
People are not comfortable with moving arguments (in the sense of Dijkstra's rant about
GOTO
statement). That is to say, an expandable control sequence is a mystery for the programmer until it really expands to the surprise it includes. This makes it very difficult to learn the basics of TeX. Even to print what a control sequence holds you need\expandafter
s and\show
s at the appropriate places. So debugging is very tough. And that is a major problem for the newcomer.This is probably the most relevant reason: The internet is full of contradictory or obsolete tutorials about TeX. There is no coherent way of doing something. Some people give closer-to-the-metal pure plain TeX macro solutions, some provide LaTeX package solutions etc. It's a huge mess. And unfortunately, many of these tutorials are from the 90s and 00s with which you cannot do much anymore if you combine newer packages. Also as you know, there are better practices that emerge in time Will two-letter font style commands (\bf , \it , …) ever be resurrected in LaTeX?, Are \( and \) preferable to dollar signs for math mode? and so on. Hence it is just a never ending confusion.
LaTeX3 project is a major undertaking to address these issues and it separates the programming and document level (I'm wildly approximating). That would hopefully bring some peace to the users such that many of the details you are mentioning would be swept under the programming level carpet.
I think the most important step towards fixing these issues would be solved relatively had we had an intermediate manual for LaTeX. So far either we have Hello World examples that goes up to the capabilities of whatever is available, or completely expert level hacking cookbooks. There is no mildly technical manuals for intermediate I can handle a few @
macros user. And that leaves the users separated into very distinct,
- This is crazy, I hate it
- This is crazy, I love it
groups.