Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Just out of curiosity, is ConTeXt using the TeX algorithm in it's entirety, or are some components rewritten?

If it's the latter:

  1. Could all of TeX be rewritten in Lua, or are there good reasons against it?
  2. How was the pascal translated to Lua - automatically, or did someone understand it in it's entirety and rewrite it?

Feel free to close this as off-topic

share|improve this question
1  
I suspect you mean at least in part LuaTeX rather than ConTeXt here. Also note that the binary part of the ConTeXt Mk IV set up (LuaTeX) is not written in Lua at all, it's written in C. –  Joseph Wright Mar 6 '13 at 17:27
    
TeX could be rewritten in Lua or any other language, but then you couldn't call it TeX unless it passes the torture test. –  Yiannis Lazarides Mar 6 '13 at 17:44
    
@JosephWright Yes, I meant anything but pascal I suppose. I guess this is more of a luatex question then :-) –  drozzy Mar 6 '13 at 17:45
    
ConTeXt MkIV uses extensively Lua functions, as far as I know, but LuaTeX, over which it is based, uses essentially the same algorithms as (pdf)TeX, with the big difference that almost all internal operations are "open" to Lua functions, so in principle almost all TeX working can be modified. LuaTeX has been completely rewritten in C from the start. –  egreg Mar 6 '13 at 17:49
3  
Have a look at History of LuaTeX for details on how ConTeXt and Lua interact. –  Aditya Mar 6 '13 at 19:18

2 Answers 2

ConTeXt is mainly a macro package written in the TeX language. The current version MkIV is written for the TeX backend LuaTeX, which is written in C and opens up part of the TeX internals to a Lua interpreter, which the ConTeXt macros heavily use.

Could all of TeX be rewritten in Lua, or are there good reasons against it?

Sure, nothing prevents you from rewriting TeX in Lua, but it would not make much sense. It already has a brilliant C implementation with Lua interface. What would be the benefit?

How was the pascal translated to Lua - automatically, or did someone understand it in it's entirety and rewrite it?

The pascal code was never translated to Lua. The pascal code has been manually converted to C.

Here are some slides which depict how LuaTeX is comprised: Taco-LuaTeX-talk-2007

share|improve this answer
3  
LuaTeX was written in pascal (just like pdfTeX an Aleph), for a good portion of it is history, and the current C code was translated manually not using web2c. –  Khaled Hosny Mar 6 '13 at 23:16
    
I wonder what's going on with the LuaTeX/ConTeXt -generated PDF documents when many of them, including the one linked in the answer, do not show all of the content text with Google Chrome's PDF viewer. –  morbusg Apr 1 '13 at 18:12

The Luatex project, as outlined by Taco in the link Marco gave, isn't about reimplementing Tex, it's about:

  1. Exposing Pdftex's internal data structures to Lua;
  2. Adding hooks into the Pdftex engine, e.g., callbacks; and
  3. Using Lua as a bridge to other code, most importantly Metapost, through mplib.

This allows Lua to be involved in layout, but the that is through configuration, scheduling and controlling the Pdftex engine which does the real work.

Context uses Lua to make scripting easier, and because it can potentially make heavy use of Metapost in layout. But the heart is basically Knuth's algorithms. Note also that Context Mk II did not use Lua, so much of Mk IV's functionality does not depend on what is new with Luatex.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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