LuaTeX Comes of Age
lwn.net
lwn.net
I process text (not in Lua). I do a bit of Troff, html, stuff like that.
Where to start learning ?
http://ctan.mirrors.hoobly.com/info/lshort/english/lshort.pd...
Then, look at the links in my article, and you should be able to start doing something interesting.
- tex takes 0.15 seconds
- pdftex takes 0.37 seconds
- luatex (1.0.4) takes 0.46 seconds
All of these are reasonably fast, and I think getting a full book in less than half a second is acceptable. (My browser takes longer than that to render most things.)
What's the catch? This book is written in plain TeX. The slowness comes when you use LaTeX: it's not unusual to have even single-page documents that take longer for LaTeX to generate. The whole LaTeX approach is to have a package for everything, load everything you may want, providing all the features, etc — and all of this implemented in TeX macro expansion in painful and hard-to-refactor ways.
This is something LuaTeX will help with actually: LuaTeX makes TeX less monolithic by providing hooks (callbacks), and many things can now be implemented in easier-to-read Lua code as hooks into the right parts of TeX's execution, rather than setting everything up at the start so that after macros are expanded the right thing happens. If there's less use of LaTeX and elaborate macros, things should get faster.
There is an easy fix: specify a lower compression setting. It defaults to the highest or close to the highest setting, which is inordinately more expensive.
The example they present from that page:
\documentclass{article}
\usepackage{luacode}
\begin{document}
\pagestyle{empty}
\begin{luacode*}
function esn (n)
return (1 + 1/n)^n
end
function etn (n)
tex.print(string.format('%5d & %1.8f \\\\', n, esn(n)))
end
\end{luacode*}
Convergence to $e$:
\begin{tabular}{ll}
\rule[-2mm]{0pt}{4mm}$n$ & $(1 + \frac{1}{n})^n$ \\
\hline
\luadirect{
for n = 10, 110, 10 do
tex.print(etn(n))
end
}
\hline
\end{tabular}
\end{document}
which allows a pretty table to be printed in the document.This also results in cleaner code (even beyond Lua being more readable than TeX macros), and smaller/faster code as you don't have to account for as many different kinds of things in your "input".
The "fade lines" callback example in the linked article is a good one. Here's another example of mine (not a great one) where you can influence TeX's linebreaking algorithm to avoid short words at line boundaries: https://tex.stackexchange.com/questions/378704/how-to-avoid-... -- the solution with macros is not so great.