2

My take from What is the difference between TeX and LaTeX? is that TeX is the programming language that renders the document. LaTeX is a well-known macro package for TeX with the aim to make the writer's life easier.

I have some experience with web development. In the realm of JavaScript, React is a library that allows you to write unsupported JavaScript syntax (namely JSX), to make the developer's life easier (improving developer experience).

I guess that LaTeX to TeX is like React to JavaScript. The difference is that unlike React, the LaTeX syntax is not unsupported; it's just un-predefined in the TeX engine. While the React syntax (JSX) is actually alien, exotic to the JavaScript engine, and the compiler has to convert JSX to supported JavaScript syntax before the running it.

Is my understanding correct?

Ooker
  • 1,450
  • 1
  • 12
  • 26
  • 2
    Yes, kind of—LaTeX is a “framework” the way React is, in the sense that it defines its own ways of doing various stuff, which if you buy into them provide many conveniences. Perhaps another analogy is that LaTeX is like Wordpress: a large software system, widely used, with many plugins (packages). But I don't think this question as currently written can be answered very definitively with a "yes" or "no". – ShreevatsaR Mar 02 '24 at 07:09
  • 1
    I guess I'd say it's more like assembler/C or C/Python – Joseph Wright Mar 02 '24 at 07:18
  • 3
    that difference is fundamental. to a user it's possibly similar but when comparing programming languages your comparision to react is "it's like react except completely different" latex is written in tex so it's like a large javascript library so a better analogy would be jquery, to the end user there is a different syntax and functionality but it's written in the language not an extension of it. – David Carlisle Mar 02 '24 at 09:46
  • 1
    A nice question. There is a big difference between programmer-level, power-user level, and end-user level. I cry and moan when the documentation for level X is explained using the mentality of level Y. – rallg Mar 03 '24 at 19:12

1 Answers1

3

The question is not about differences in programming-paradigms but is about getting an overview over terminology.

Nevertheless the author of the initial release of this answer recommends not to focus on analogies to other things too much while familiarizing with TeX and LaTeX.

Instead, first familiarize with the terminology introduced and used in the TeXbook and in The LaTeX Companion for denoting concepts related to TeX and LaTeX and the underlying programming-paradigm.

When you are sufficiently familiar with TeX and LaTeX and the underlying programming-paradigm, then, while thinking about analogies to things with slightly different programming-paradigms, you can minimize the risk of developing misconceptions due to inadequacies in an analogy that are difficult to free yourself from.


TeX is the programming language that renders the document.

Let's look at the term "TeX":

The term TeX is used in (at least) two ways:

The term TeX denotes the typesetting and document formatting language TeX invented by Donald E. Knuth.

The term TeX also denotes a compiler/a computer program whose name is TeX and which is written by Donald E. Knuth and which also is referred to as Donald E. Knuth's original TeX compiler.
The term TeX besides Donald E. Knuth's original TeX compiler nowadays also denotes a range of computer programs based on Donald E. Knuth's original TeX compiler that are subsumed under the terms "TeX compiler" and "TeX engine".
With these compilers the focus is not on creating code for a so-called executable file, which in turn a computer can operate on for carrying out whatsoever algorithm while probably requesting whatsoever (user-)input at the runtime of the program.
With these compilers the focus is on creating the result of processing the description of a document, whereby the description is given in the typesetting and document formatting language TeX and whereby the result usually is

  • an output file, i.e., a .dvi-file or a .pdf-file which in turn can be used by programs for rendering .dvi-files/.pdf-files into something visible/printable,
  • and a .log-file in text format
  • and some messages on the terminal
  • and some (auxiliary) files in text format
  • and, in case shellescape/\write18-feature is activated, probably the result of carrying out programs other than TeX or other instances of the program TeX.

Nowadays there is not just one TeX compiler, but there are several variants of TeX compilers. In the context of variants of TeX compilers you speak of TeX engines.

The primogenitor to all nowadays' TeX engines is Donald E. Knuth's original TeX compiler, also referred to as TeX821. Version 0 of TeX82 was released in September 1982. Since version 3.0 (3.1?) of TeX82 updates to TeX82 are indicated by adding an extra digit at the end of the decimal, so that the version number asymptotically approaches π. Version 3.141592653 of TeX82 was released in January 2021. Since version 3.0, which was released on March 15, 1990, Knuth's TeX82 internally uses 8bit numbers for representing characters while the 7bit-number character encoding scheme ASCII is a strict subset of Knuth's TeX engine's internal 8bit-number character encoding scheme so that 256 different characters can internally be represented in TeX so that implementations of TeX are feasible which can read/process text files where characters are encoded in some 8bit-number character encoding scheme. Knuth's TeX82 produces output files in device independent format (dvi). (In contexts not related to the document formatting and typesetting language TeX "dvi" also is an acronym for "digital video interface" or "digital visual interface"—make sure not to confuse these things.)

An extension to Knuth's TeX compiler is ε-TeX from the NTS project. That compiler brings along extensions to Knuth's original TeX compiler like expressions for doing integer calculation or calculation of lengths already in the processing stage of expansion and the possibility of re-tokenizing .tex-input already tokenized to name only a few.

Another one of these TeX engines is the pdfTeX compiler by Hàn Thế Thành. That compiler comes along with the ε-TeX-extensions. By default it produces output files in portable document format (pdf) and brings along features for micro-typography and a lot of innovation and additional primitives tailored to the possibilities which the portable document format provides.

By implementing fancy algorithms for treating sequences of explicit character tokens coming from tokenizing 8-bit characters as representations of utf-8-encoded multibyte-characters you can "trick" these "8-bit compilers" into handling .tex-input-files encoded in utf-8 also.

Yet another TeX engine is XeTeX by Jonathan Kew, which, when TeX is in the mode for breaking text into lines of a paragraph and breaking the lines of a paragraph across pages automatically, allows not just having TeX typeset texts where lines are to be read from left to right but also allows having TeX typeset text where lines are to be read from right to left or where symbols are to be aligned vertically. XeTeX natively processes .tex-input-files encoded in utf-8 and supports modern font formats such as OpenType (OTF) and SIL's Graphite font technology.

Also a nowadays very important TeX engine is LuaTeX by the LuaTeX development team. That engine combines the document formatting and typesetting language TeX with the programming language/scripting language Lua. It also natively processes .tex-input-files encoded in utf-8 and supports modern font formats such as OpenType (OTF) and SIL's Graphite font technology.

Let's look at the phrase "… is the programming language that renders the document":

As far as the author of the initial version of this answer knows, rendering is a process, while a language alone is something abstract and doesn't initiate processes. So the typesetting and document formatting language TeX alone does not render the document. The computer does. By means of a computer program which is a compiler called a TeX engine and which enables the computer to "understand" the typesetting and document formatting language TeX and to carry out the instructions given in that language for creating a result as described above.

Let's look at "LaTeX is a well-known macro package for TeX with the aim to make the writer's life easier" and at "Is LaTeX a programming framework of TeX?":

LaTeX, more specifically LaTeX 2ε, is a macro collection that is written in the typesetting and document formatting language TeX and in this way—as indicated in the subject line of the question—probably can be considered a kind of "programming framework of TeX".

LaTeX, however, is not a "programming framework of TeX" in the sense of providing, e.g., some sort of integrated development environment with input editor and graphical user interface where execution of a compiler and viewing .log-files and the like is available via a mouse click or via a gesture on the touch screen.

LaTeX 2ε does not extend the fundamentals of the grammar that underlies the syntax of the typesetting and document formatting language TeX.

The macro collection called "LaTeX 2ε" is subsumed under the term "format" whereby the term "format" also is a term of TeX-jargon explained in the TeXbook of Donald E. Knuth.

In this context the term "collection" was used instead of the term "package".
In TeX-jargon formats form a special kind of "package":

A "format" is a collection of routines designed on top of TeX's primitives, written in the typesetting and document formatting language TeX. Usually .tex-input is stored in ordinary text files. But a "format" is intended to be pre-processed whereby the result of pre-processing yields a format file whose name's extension is .fmt and wherein data is arranged in some binary format in a way where, in contrast to ordinary text files, the data can be loaded into memory at high speed when starting the TeX compiler. The process of having a TeX engine create such a fast loading .fmt-file is called "dumping a format file".

Dumping (and afterwards using) a .fmt-file from the sources of nowadays releases' of LaTeX 2ε works out successfully only with TeX engines where ε-TeX-extensions are available. This implies that nowadays you cannot use Knuth's traditional TeX compiler any more for successfully dumping (and using) a format file for LaTeX 2ε. But with the TeX engines εTeX, pdfTeX, XeTeX and LuaTeX you can.

With nowadays' TeX implementations TeX executables "look" at the command-line to see what name they were called under and from that name deduce the base-name-part of the name of the .fmt-file/of the format file to load. The meaning of "name they were called under" depends on the circumstances with the operating system and/or on the file system in use. With operating systems/file systems allowing symlinks it might be the base-name-part of the filename of the file representing the symlink pointing to the TeX executable in question.

This way the routines provided by a format are available "from scratch" right away, without the users/programmers needing to place commands into their .tex-input for loading them.

With packages that are not formats, users/programmers who wish to use the routines provided by these packages need to place commands into their .tex-input for processing the corresponding text files. (The loading of such text files does not take place at high-speed but does take place at the speed at which external text files are processed.)

E.g., with packages which for their own successful loading and for the working out of the routines provided require the format LaTeX 2ε to be loaded, you usually place commands like \usepackage or \RequirePackage which are directives that themselves are defined in the format LaTeX 2ε.

The concept "language" also is interesting when coping with TeX. The fundamentals of the grammar of the typesetting and document formatting language TeX cannot be changed while programming in TeX, but the fundamentals of that grammar need to be obeyed as long as you don't like to obtain low level error messages at the compiler's runtime. But the program TeX offers means for in the course of carrying out the program TeX coming from an earlier state to a later state so that, e.g., the functionalities denoted by control sequences in the earlier state in the later state are not available any more or are available via a totally different set of control sequences/via different names. Also, syntactical aspects can be introduced in a later state that are not yet introduced in an earlier state, e.g., by defining macros that process (delimited) arguments so that the order, in which tokens that are to form arguments and argument delimiters occur, does matter, or by (re)defining macros in terms of \outer so that the corresponding control sequence tokens themselves cannot be components of arguments of other macros.
So the question arises whether both in the earlier state and in the later state you really still have the same language and not just the same fundamentals of grammar. ;-)


1Edit in 2024/03/03, 16:20 UTC: The esteemed TeX - LaTeX Stack Exchange member ShreevatsaR in a comment pointed out that "TeX90" is not official terminology. In the source code of the current version (version 3.141592653, January 2021) of Knuth's original TeX compiler, tex.web, the program is still named TeX82.

Ulrich Diez
  • 28,770
  • Nitpick/question: Where does the name "TeX90" come from? I've only it seen used by Joseph Wright on this site (and now you). At some point the terms "TeX78" and "TeX82" were used, to distinguish between Knuth's SAIL program (and ports of it) and the Pascal/WEB rewrite. Since then, the program being used is really just the latter one (TeX82) — yes, version 3.0 of it was released in March 1990 which yes had some important changes like 7-bit to 8-bit, but it was as part of the same stream of development (not like "Win95" "Win98" etc). – ShreevatsaR Mar 03 '24 at 14:39
  • @ShreevatsaR Thanks for reading and nitpicking and pointing this out. ;-) I don't know where this originates from. I found it in TUGboat, Volume 24 (2003), No. 1, The (La)TeX project: A case study of open source software, page 143, https://tug.org/TUGboat/tb24-1/gaudeul.pdf. I naively assumed it stems from Knuth, but seems it doesn't. In recent "TeX the program" and in tex.web you still find TeX82, so you are right, it's still TeX82. I edited my answer accordingly. – Ulrich Diez Mar 03 '24 at 15:41
  • I guess people started using it like C89, C99 etc — a year to refer to a newer version of a language/standard. – ShreevatsaR Mar 03 '24 at 16:53
  • @ShreevatsaR Not 100% sure where I got it from (either TUGBoat or comp.text.tex), but it's always seems pretty clear to me that it contrasts with TeX82 and is friendlier than saying 8-bit TeX vs 7-bit TeX. – Joseph Wright Mar 03 '24 at 17:01
  • @JosephWright Interesting, thanks… I notice also that tex.web says “Version 2.992 introduced major changes for 8-bit extensions (September 1989)” — maybe back then lots of people had not yet upgraded, so it was important to distinguish “TeX82 version 2.991 or earlier” and “TeX82 version 2.992 or later”, thus a new name for the latter (with Sep 1989 approximated to 1990)? Makes sense how such a convention may have arisen, and the reason people did not extend the practice to numbering every new version of TeX—like TeX86, TeX93, TeX95, TeX2002, etc—is because other changes were minor, I guess. – ShreevatsaR Mar 04 '24 at 05:27