13

What I've read is that NTS (New Typesetting System) was a project to reimplement TeX in Java. According to the current version of the Wikipedia article, it was started with high hopes (and sufficient funding), such as the hope of being easier to extend, though in the end it was abandoned because:

  1. It was too slow,
  2. By then extensions e-TeX and pdfTeX were around and this program only implemented the core “Knuth” TeX, without these extensions.

At least in implementing the core TeX, though, it seems to have reached a fair degree of completion: it is said that it even passed the TRIP test (the “torture test” that a TeX program needs to pass, to be called TeX).

But that was in 2000. Today, 17 years later, computers are faster, and possibly what was too slow for 2000 is acceptably slow (even if many times slower than “regular” TeX). Hence the question: is it possible to use nts today, to compile plain-TeX (only, as LaTeX requires the e-TeX extensions) documents? There might be some interest, or at least curiosity, in seeing a Java program do what the WEB-b-Pascal-converted-to-C program does.

  • 1
    On CTAN you can still access the source code: ctan.org/tex-archive/systems/nts – Henri Menke Aug 10 '17 at 0:39
  • 1
    You can extract the archive and then use java -jar texmf/nts/base/nts.rt.jar test.tex to compile your sample INI-TeX document (there are not formats provided). Also the output will be pretty boring as there are no fonts provided either. – Henri Menke Aug 10 '17 at 0:44
14

(Answering my own question to preserve this information, but would still welcome better answers…)

Yes, NTS is usable, if you have some basic binaries of the TeX ecosystem like kpsewhich, and certain “data” like plain.tex, fonts, and other files. These you can get from installing TeX Live (or a similar system).

Here are the steps which seem to work (tested on Mac and Linux).

  1. Prerequisites: make sure the kpsewhich and java commands exist and work. You can do the former by installing TeX Live (skip this step if you already have a working TeX system). For example on Ubuntu:

    $ sudo apt install texlive-binaries
    $ sudo apt install default-jre
    
  2. Get the NTS sources and unzip them:

    $ mkdir nts && cd nts
    $ wget http://mirrors.ctan.org/systems/nts/ntsbase-1.0-beta.zip
    $ unzip ntsbase-1.0-beta.zip
    
  3. Make one of the nts scripts executable (I think it doesn't really matter which), and optionally try to run it:

    $ chmod +x ./bin/i386-linux/nts
    $ ./bin/i386-linux/nts
    nts: NTS Java Executable nts.rt.jar or Nts.class not found.
    
  4. Move to the directory that contains the .jar file:

    $ cd texmf/nts/base
    
  5. Optionally: try to run it:

    $ ../../../bin/i386-linux/nts 
    nts: Can't find requested NTS .nfmt file >nts<.
    
  6. Dump format file:

    $ ../../../bin/i386-linux/nts -ini plain '\dump'
    This is NTS, Version 1.00-beta
    NTS comes with ABSOLUTELY NO WARRANTY.
    This is free software, and you are welcome to redistribute
    it under certain conditions; for details see the file
    COPYING in the distribution
    (/usr/share/texlive/texmf-dist/tex/plain/base/plain.tex
    Preloading the plain format: codes, registers, parameters, fonts, more fonts,
    macros, math definitions, output routines, hyphenation
    (/usr/share/texlive/texmf-dist/tex/generic/hyphen/hyphen.tex))format file stored in 689 milliseconds
    
    No pages of output.
    Transcript written on plain.log.
    
  7. Now it is usable!

    $ ../../../bin/i386-linux/nts -fmt=plain '\input story \bye'
    This is NTS, Version 1.00-beta
    NTS comes with ABSOLUTELY NO WARRANTY.
    This is free software, and you are welcome to redistribute
    it under certain conditions; for details see the file
    COPYING in the distribution
    ./plain.nfmt loaded in 1120 milliseconds
    (/usr/share/texlive/texmf-dist/tex/plain/knuth-lib/story.tex [1])
    Output written on story.dvi (1 page, 668 bytes).
    Transcript written on story.log.
    

This story.dvi has our familiar beloved story:

story.dvi

I tried this with some other bigger plain TeX files, such as gentle.tex, the source to the book A Gentle Introduction to TeX. It works.

It is noticeably slower (even in 2017): while tex gentle.tex takes 0.05 seconds, ../../../bin/i386-linux/nts -fmt=plain gentle.tex takes 3.71 seconds. This may be acceptable though. Note that although the font files and other files are loaded from the TeX Live installation (probably after being looked up with kpsewhich), the actual code that does the typesetting is all Java code.

The curious thing is that the dvi files produced by nts and by tex (the one from TeX Live) are slightly different: you can run dvitype on the respective DVI files to see that the calculated positions have tiny differences and even different order of commands. So I'm curious about the "passed trip test" remark (but perhaps the trip test doesn't require identical DVI files either). Nevertheless, visually there is no difference in line breaks or page breaks, or the positions of characters, as best as I can see.

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.