# What's the difference between format and macro language?

From a comment by morbusg

depends on what you mean by "plain tex": if you mean "plain tex – the macro language", then yes, LaTeX does provide an interface. If you mean "plain tex – the format", then… well, LaTeX does use plain as a base for many things.

I thought format and macro language are the same concept. But the quote seems to distinguish the two. So I wonder what differences and relations are between them?

-

I would use "macro language" to mean the macro system built in to tex-the-program ie the system that allows macros with parameters #1 .. #9. This is as distinct from other macro languages such as the #DEFINE macros implemented by the cpp pre-processor for C or the entity definition mechanism in XML (both of which are noticeably less expressive than the TeX macro language).

A "format" in a TeX context is a language built using TeX (typically by dumping a collection of ready-defined macros and other definitions into a packaged binary). So the LaTeX format consists principally of macros, but also non macro definitions such as register allocations and font definitions.

-
"A format in a TeX context is a language built using TeX (typically by dumping a collection of ready-defined macros and other definitions into a packaged binary)." I wonder if by "built" and "dumping", you meant "compiled" and "compiling"? By "a packaged binary", do you mean the executable of an engine? –  Tim Jul 20 '12 at 14:54
No. A format file (.fmt) is not an executable, it is what I said: a binary file (basically a memory dump of the internal state of the engine at the point it sees \dump). This format file can be loaded by the executable to get back to that point without having to read all the source files again. (additionally it is possible to make a executable that has the format pre-loaded to save a bit more time, as the format doesn't need to be read of disk). Loosely people talk of compiling but TeX is a macro expansion language interpreter coupled to a typesetting engine, not a compiler. –  David Carlisle Jul 20 '12 at 15:00
Thanks! So Tex is an language interpreter, coupled to an engine. Is an engine an interpreter, compiler or something else? What is the counterpart to an engine for Tex in a programming language? –  Tim Jul 20 '12 at 16:17
The distinctions between compiled and interpreted languages are blurry so it's hard to be precise. I think you are making it seem a lot more complicated than it is. engine corresponds to "compiler" or "interpreter" or "run time system" depending on your point ofview. It just means all the executable code that does stuff. Macro definitions document files, format files are all just data and are processed by an executable compiled program (written in some combination of pascal and C usually), but it doesn't really matter what it was written in, it is just the "engine" that makes things happen. –  David Carlisle Jul 20 '12 at 16:26
You want the definitions to be a bit loose, so they make sense over time and over machine types (where the technical details may change a bit but not in ways relevant to the use of tex) –  David Carlisle Jul 20 '12 at 16:27

All I meant was to distinguish between

1. TeX - the language, which has primitive commands available on the user-level, and
2. A format (a collection of macros), which builds higher abstractions on those primitives.

Often you can see people saying "plain TeX" when they mean either one of the above, which can be confusing.

-

The macro language of TeX refers to the way macros are read, defined, expanded, etc.; the set of primitive commands & their effect; and things like that. In this context, “plain TeX” means the stuff DEK’s engine understands, as opposed to the extensions supplied by engines like e-TeX, XeTeX, PDFTex, LuaTeX, etc., etc.

The format is the way TeX is configured: which characters have which catcodes, what names do the primitives have, and which macros are pre-defined and to what. In this context, “plain TeX” is the format described in The TeXBook, as opposed to extensions like eplain, LaTeX, & ConTeXt.

The difference between a format and a macro package is not quite clear-cut: there are commands to turn the currently-loaded set of macros into a new format. This is how LaTeX and ConTeXt work without requiring something like \input latex at the top of your source.

By convention, the tex command loads the TeX engine with the “plain” format.

-