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.

  • 5
    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, 2011 at 7:03

5 Answers 5


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.

  • 1
    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, 2013 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.
    – user2478
    May 12, 2013 at 13:27
  • 3
    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. May 12, 2013 at 16:41
  • @BrunoLeFloch: LuaTeX also has some features ... ;-) By the way: I am using LuaTeX for all my publications ...
    – user2478
    May 12, 2013 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! =) May 20, 2011 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! Sep 16, 2011 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?
    – raphink
    Sep 16, 2011 at 9:11
  • 1
    @Raphink: NTS is extex's predecessor, but they are not the same, and there no much lessons to learn from extex itself ;). Sep 16, 2011 at 9:21
  • 1
    nts has completely global variables and cannot be count as an reimplementation because it doesn't use anything of what a modern language provides.
    – user2478
    Sep 16, 2011 at 15:08
  • @Herbert: because it fall into the trap of being "faithful" reimplementation and "100% backward compatible", you can't put those restriction up front and expect the project to move forward. Sep 16, 2011 at 15:53
  • 2
    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 Sep 16, 2011 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.