[Tex/LaTex] Pros and cons of the LaTeX3 syntax

expl3latex3programming

The programming language introduced by expl3 in LaTeX3 is a bit unusual compared to other TeX macro languages in that it uses both _ and : for function names. Could someone provide some technical insight on the pros and cons of the syntax?

Best Answer

Disclaimer: originally the question was phrased as like/dislike instead of pros/cons, and that is the only way in which I can provide an answer. I do not have enough practical experience in expl3 to comprehend the technical (de)merits of the language. So this answer is an (outside) opinion piece only.

To readers that know my background as one of the luatex and ConTeXt developers it should come as no surprise that I do not like the new syntax.

My main objection is that it adds additional complexity to a task (macro programming) that is already highly complex.

Taking the definition of \mode_if_horizontal:TF as an example:

\prg_set_conditional:Npnn \mode_if_horizontal: {p,TF,T,F}{
   \if_mode_horizontal: 
   \prg_return_true: \else: \prg_return_false: \fi:
}

This looks like I would have to learn a completely new programming language that looks similar to, but is clearly not the same as, TeX macros. Taking into account that it took me more than a year at a full-time job to learn how to write TeX macros properly, this scares me quite a bit.

In the example, the naming of the internal macros and the use of a comma-separated list suggest that the intent is to make macros behave more like functions in other languages would. But looking at expl3 as a beginner while already having a lot of knowledge of the underlying engine, I do not truly believe that the new syntax will succeed in shielding off the underlying engine. The problem is that if it fails to do that then it is not a replacement language, but an additional language that needs to be learned and used on top of the already existing macro language. And, at least to me, it is an additional language with very unfamiliar syntax and semantics.

All in all, I much prefer traditional TeX style macros with lua for more complex tasks.