3 ms·
> if a standard embeddable programming language had been available he'd of course have used it in TeX — I think Lua would count I agree with your general idea,
by nsajko 5y ago
> if a standard embeddable programming language had been available he'd of course have used it in TeX — I think Lua would count
I agree with your general idea, but it is really a shame that Lua was chosen as the language to embed in TeX, instead of something sane like a Scheme, Common Lisp or at least Python (today, maybe Julia). Furthermore, the effort to rewrite as much of the TeX implementation as possible in Lua is perplexing.
- leephillips 5y agoJulia is a wildly inappropriate choice for embedding, and Python is not much better. Some implementation of Scheme might make more sense (isn’t that what Guile is about?). Except that most people are put off by s-expressions; Lua is comparatively “normal”.
- BeFlatXIII 5y agoIf you're not chasing market share for commercial purposes, do you really want to cater to those who are put off by s-expressions if you personally enjoy them?
- leephillips 5y agoProbably not. But I’m guessing that the people who created LuaTeX prefer Lua. And maybe, if you wanted to create a scriptable TeX that would be usable by the typical TeX user, a language like Lua makes more sense than a Lisp. Those users tend to be scientists and mathematicians, and just anyone who needs to make good-looking documents; most are not familiar with Lisp and would find it more difficult to learn than Lua.
- bccdee 5y agoIf you're making a tool for people to use, it's probably best to use a syntax that most people are comfortable with. UX doesn't only matter to corporations.
- chriswarbo 5y ago> Except that most people are put off by s-expressions This triggered my obligatory rant that Lisp doesn't require s-expressions, there are a bunch of equivalent alternatives, and indeed the entire point of s-expressions is that they're trivial to generate, parse and manipulate automatically (if you don't want to write them manually). http://chriswarbo.net/blog/2017-08-29-s_expressions.html http://chriswarbo.net/blog/2017-08-29-s_expressions.html
- leephillips 5y agoThe suggestion was to use Scheme or CL.
- svat 5y ago> Furthermore, the effort to rewrite as much of the TeX implementation as possible in Lua is perplexing. Very little of the TeX implementation has been rewritten in Lua. (Assuming you're talking of LuaTeX itself and not the "TeX without TeX" wiki page, which is just for demonstration.) LuaTeX starts with the WEB (Pascal) code of TeX, manually translated into C (see e.g. https://tug.org/TUGboat/tb30-3/tb96hoekwater-pascal.pdf https://tug.org/TUGboat/tb30-3/tb96hoekwater-pascal.pdf), and, additionally, hooks are added: callbacks that can be written in Lua, and which have access to the internal data structures. (By the way, SILE is a separate typesetting system (unrelated to TeX) that is actually written in Lua, and re-implements some of the TeX algorithms in Lua, I think. You can see this talk by its author about it: https://www.youtube.com/watch?v=5BIP_N9qQm4 https://www.youtube.com/watch?v=5BIP_N9qQm4 )
- qart 5y agoAs much as I like all the alternative languages you mentioned, and as much as I hate it, I think JavaScript (or wasm) would/should be the language of choice were TeX to be extended today.
- phlakaton 5y agoSee Lilypond, the music typesetting project, if you want to see how Scheme embedded in a TeX-like language looks. From my experience, you're generally evaluating to actual AST-like objects instead of sprintf-ing something TeX-like – I suppose this has pros & cons.
- strenholme 5y agoit is really a shame that Lua was chosen as the language to embed in TeX, instead of something sane like a Scheme, Common Lisp or at least Python (today, maybe Julia) I personally find Lua to be a completely sane and easy to program language. But, to each their own. Let’s look at these options and some others: Scheme/Lisp: It’s true that Scheme and Lisp-like languages are pretty compact and easy to embed, but the syntax of Lisp is, for most modern programmers, pretty esoteric. Asking today’s programmers to program in a Lisp is, for better or worse, like asking secretaries to use Vi to edit documents. Python: Python is a big, bulky language and one which is not really suitable for embedding inside another program. See this recent discussion for more on this: https://news.ycombinator.com/item?id=29700947 https://news.ycombinator.com/item?id=29700947 Julia: A somewhat non-mainstream language, and, like Python, it doesn’t look to be a language designed for embedding the way Lua is. Forth: Like Lisp dialects, Forth’s completely stack-based syntax is not intuitive for today’s generation of programmers. Lua needs batteries, which I know is off putting to some programmers. It turned me off from Lua for a while until Roblox made me give Lua a second chance. Here is my own set of public domain Lua batteries: https://github.com/samboy/LUAstuff https://github.com/samboy/LUAstuff (stuff like a Lua copy.deepcopy(), sorted table/dictionary iteration, split strings based on a regex, etc.)
- charlieyu1 5y agoPython is more like something that should be run alongside LaTeX, not embedded in. PythonTeX already does this