Is "Write your nontrivial LaTeX macros in expl3!" a good advice?

The broad base of programming tasks is covered by expl3 and so it is possible to use it for a large number of tasks. For example, my package siunitx is written entirely in expl3, and there are very few places I have to grab some LaTeX2e or plain TeX concept. (Those tend to be at the interface, for example using LaTeX2e document commands, or one or two very limited places there are no expl3 interfaces for TeX primitives.)

You will need to understand some basic TeX ideas to use expl3, most notably

  • TeX works with tokens not characters/strings, which means we need to worry about category codes
  • TeX arguments are normally 'balanced text' (things in braces or single tokens), unless they are explicitly set up to be delimited
  • TeX works by expansion, but not everything is 'expandable'
  • Scope is created explicitly using groups, not implicitly by 'functions'

(Over time, the LaTeX team do hope to document all of this within the expl3 documentation.)

With that background, you should be able to tackle a wide range of programming tasks in expl3. You may need some 'glue' where for example you need to use a LaTeX2e concept, e.g. package loading, but this will typically be a very small part of your code. In particular, you are very unlikely to need complex expansion control, unless you are after high performance or very specific needs.

It's important to state that expl3 is broadly stable. There are still deprecations, and you may need to make adjustments over time, but these are increasingly rare. There is a formalised mechanism for deprecation and informing programmers of changes.


[I decided to remove my excessive comments and to provide an answer instead.]

If I got you right, you wish to know if it is good for someone who wishes to accomplish more or less sophisticated programming-tasks by means of TeX to directly lay the focus on expl3 rather than beginning by gaining in-depth knowledge of plain-TeX and primitives and the LaTeX 2ε-kernel.

This also depends on the purposes behind these programming tasks.

If you wish to just write some more or less sophisticated macros for private usage, you may be happy when getting it done somehow, e.g., by means of expl3 if that is what you are already familiar with.

If you wish to publish code which is intended to extend a given framework, you need to be familiar with that framework and with all other frameworks you may use for writing your code:
Writing a package for LaTeX 2ε by means of using expl3 in package-mode implies the need of being familiar both with LaTeX 2ε and with expl3.

In case first attempts at writing own macros using expl3 do not work out as intended, you may wish to retrace things for finding the reason. Hereby you may easily and quickly reach the point where you wish to retrace what an expl3-macro defined in the expl3-kernel does exactly.
As something was used for implementing the expl3-kernel, you then have reached a point where you need to be familiar with that "something". That "something" basically is some TeX-engine with primitives "renamed".
So you still need to be familiar with the basic concepts ("digestion processes": reading and tokenizing .tex-input-files, expansion, assignments, glue and boxes, output-routines etc) that apply to all TeX-engines.

[Explanatory insert:]

I just wrote:

In case first attempts at writing own macros using expl3 do not work out as intended...

I don't intend to indicate that expl3 (or whatever other framework) is not reliable/is unstable or the like.
When I started learning TeX/LaTeX 2ε/expl3 my attempts at writing own macros very often did not work out.

The reason was not the "framework". The reason was that in my beginnings I didn't know enough about that "framework" (only superficial knowledge conveyed via some nice tutorials, but no in-depth knowledge) and therefore tried to use things in ways which were not intended by the implementers who wrote the "framework". In order to gain knowledge about the "framework" I needed to play around and trace things ("looking" at them via \show) and grasp how they work myself.

Back then I received great help by the regulars of the usenet-newsgroups comp.text.tex and de.comp.text.tex.

[End of explanatory insert.]

On the one hand expl3 is designed with the goal that you don't have to worry about every obscure expansion-sneak when programming.
On the other hand expl3 is designed to remind you of concepts like tokenization and expansion all the time, again and again, ad nauseam, because with expl3 the name of a non-user-level-macro already tells you what arguments that macro processes and by means of which tokenization/expansion/whatsoever-methods each argument of the macro will be pre-processed before it gets applied to the macro-definition's replacement-text.
I take this for a good thing because it can be very helpful when in case of error-messages retracing things be just looking at the code: You can more easily see that a macro doesn't get the type of argument which it should get. E.g., a macro getting a normal argument while "expecting" an argument that got tokenized under verbatim-category code régime. E.g., a macro getting the name of a control-sequence while expecting the control-sequence-token. ...

It is also a bit like cars: In order to handle it well, you have to know to a certain extent how it works.
My experience is that with expl3 reading the user documentation usually is sufficient— provided you read it very very carefully and understand the references to basic TeX concepts.
Nevertheless you may reach a point where you are interested in expl3's implementation...

If you like carefully reading user-documentations in the way in which a lawyer investigates every word/phrase of a contract for pitfalls, probably needing to do a bit of research within other sources of information like the TeXbook regarding the meaning of TeX-related terminology and concepts, then in my opinion expl3 is a good choice.
If you like to learn by reading code, then it also depends on what macro-collections etc you are already familiar with.
I think if you start into the "TeX-world" by learning expl3, then the learning curve will be very steep and you will be faced to references to basic TeX-concepts in an extent which sooner or later leads to you being able to cope with code written in LaTeX 2ε or plain-TeX as well. ;-)

To be honest: To me retracing expl3-code is a nightmare and it takes me long time. This is mainly because I am not familiar with/used to it. Thus I think: If you wish to quickly reach a stage where this is not a nightmare to you, then start learning expl3 as soon as possible. ;-)
I think it is also a matter of training: In my beginnings when I wasn't familiar at all with TeX-programming and the look of LaTeX 2ε-code, retracing LaTeX 2ε-code (e.g., by reading source2e.pdf) was a nightmare to me, too. ;-)

Currently/nowadays you will nevertheless still be faced to a lot of code not written in expl3. If you wish to be able to trace such things, you need to be familiar with programming in plain TeX and LaTeX 2ε as well.

Tags:

Macros

Expl3