1

Are there any alternate compiler implementations for the Tex language? I know that there are variants (Luatex for instance), but do they all share the same codebase with Tex/Pdftex? What about Xetex, is that a completely separated implementation in terms of code base? Does it target the exact same language, or are there differences in what they support?

Edits to clarify:

  • with "alternate implementation", I mean a program that shares little or no code with the standard pdftex. Something rewritten from scratch (possibly in another language).

  • I mean something that I can use to compile a real-world document in. If I understand correctly, Latex is a macro system based on Tex, so an alternate compatible implementation of Tex should be able to run these macros with little or no changes. I don't know what you mean with "any Tex format". Do you mean output formats?

  • The example I have in mind is multiple compilers for the same language (e.g., Cpython or Pypy). For instance, there are many C compilers around; the two main ones are GCC and Clang. You can literally take the same C program and compile it with either of them (with very few exceptions regarding nonstandard features). Clang is a relatively new implementation, that provided in some cases greater speed and better error messages.

  • The differences between TeX engines is certainly relevant, but I don't find any mention to the similarities/differences between these engines. Are they all minor improvements to the same codebase, or five completely separate implementations? Can I take the same file (a simple Latex document, for instance) and compile it with either of them without changes?

  • 1
    What is your understanding of an alternate implementation? There have been attempts to port TeX (the program) to other programming languages. Do you think only of engines that support any TeX format, a specific format or even something own only based on TeX? – TeXnician Jan 8 '18 at 11:53
  • 1
    Just to clarify terms: an engine is a compiler, a format a set of macros. And switching engines requires non-trivial changes to documents. That's why you sometimes need adaptions to switch e.g. from pdflatex to xelatex. Although you are still running the same format and technically use the format's macros (engine-specific macros are a minority). So in some kind different engines are "alternative implementations". – TeXnician Jan 8 '18 at 14:21
  • 3
    I might also point out that the original engine (written in Pascal) has be rewritten in a variety of different languages. There is a test provided. Any program that passes the test can all itself TeX. – John Kormylo Jan 8 '18 at 14:55
  • 2
    All of the current TeX engines in use started out from Knuth's TeX90: pdfTeX and XeTeX were originally change files against tex.web (but now are not). LuaTeX was written by starting from pdfTeX and changing stuff: I guess the question then is when do a series of changes become a re-write ... (LuaTeX is written in C, TeX90, pdfTeX and XeTeX are written in WEB, so certainly it is 'more different'.) – Joseph Wright Jan 8 '18 at 14:59
  • 2
    Broadly, each different engine has been written to add some features to TeX90, so one cannot view them as separate implementations which are entirely freely interchangeable. On the other hand, almost everything other than those deliberate additions is the same between engines (though see some changes made by LuaTeX). I'm not sure that's an answer: its an observation and already covered in various places ... – Joseph Wright Jan 8 '18 at 15:02