# More Modern Reimplementations of TeX

There is no doubt that the original Pascal/WEB implementation of TeX is a masterpiece and I have learnt a lot reading through the source code (both weaved and tangled) but it definitely shows its age. Most of the code deals with things like lower-level datastructures and memory management that would be vastly simpler or unnecessary in a more modern language with good libraries.

Have there been efforts to reimplement TeX in a modern language such as Python while keeping full backwards compatibility?

At various times I've endeavoured this myself and have made some progress but I'm interested if other work exists.

-
You do know that LuaTeX have moved over to C, I guess? Also, are things like Python available truly cross-platform? (I'm thinking mainframes.) – Joseph Wright May 20 '11 at 7:03

There are hundreds of partial reimplementations and nobody could finish it! It is really easy to start such a project but it seems really impossible to finish it ... And yes, LuaTeX maybe more than a start, but at this time it has a lot of bugs.

-
Lot's of bugs sounds like it is unusable. I think it's unfair to say LuaTeX is just "more than a start". I happily use LuaTeX in a production environment (!) every day, so does the creator of ConTeXt. It certainly depends on the application, but the answer is too negative to be generally true. – topskip May 12 '13 at 13:23
sorry, but I compare it with the original TeX and that has no bugs. This is the reason why I call more than 10 bugs a lot: tracker.luatex.org/my_view_page.php And, of course, LuaTeX is an extension of TeX and has many more features than TeX itself. – Herbert May 12 '13 at 13:27
Well, some bugs of TeX are deemed features because fixing them would lead to breaking changes in older documents, so I am not completely sure whether saying it has "no bug" is really warranted. – Bruno Le Floch May 12 '13 at 16:41
@BrunoLeFloch: LuaTeX also has some features ... ;-) By the way: I am using LuaTeX for all my publications ... – Herbert May 12 '13 at 20:27

I've written partial implementations in PHP and in Perl. They are by no means full, and were written for specific purposes. As these purposes were for conversion from LaTeX to some other markup then I concentrated on the expansion (TeX's "mouth") than the other pieces.

Also in Perl is LaTeXML.

-
Pretty impressive code, @Andrew! =) – Paulo Cereda May 20 '11 at 10:19
Indeed impressive and useful. I am just playing with CSS3 and HTML5, reproducing standard LaTeX output while adding some interactions through canvas and it makes the work easier. Thanks! – Harold Cavendish Sep 16 '11 at 15:22

I am working on a reimplementation in Haskell: hex. It currently doesn't do much besides really simple files, but it has been progressing.

-

There is NTS, and there are some good lessons to be learnt from it for anyone "reimplementing TeX in a modern language".

-
Isn't that was Patrick mentioned? – ℝaphink Sep 16 '11 at 9:11
@Raphink: NTS is extex's predecessor, but they are not the same, and there no much lessons to learn from extex itself ;). – Khaled Hosny Sep 16 '11 at 9:21
OK, thanks for the clarification @Khaled. – ℝaphink Sep 16 '11 at 9:21
nts has completely global variables and cannot be count as an reimplementation because it doesn't use anything of what a modern language provides. – Herbert Sep 16 '11 at 15:08
one good lesson to be learned from nts is "don't put a committee in charge of the programming effort" -- the guy who was paid to the work didn't want his name associated with the results -- so unlike the situation with luatex and taco h – wasteofspace Sep 16 '11 at 15:54

See extex - its a java based implementation. Not used in productive environments, as far as I know, but probably very interesting project.

-