Why should I be interested in Lua?
You asked, inter alia:
What for can [Lua] be used in typesetting? Can it somehow substitute any packages?
Some typesetting tasks can be achieved only in LuaTeX, but not pdfTeX or XeTeX. We're starting to see more and more packages that require LuaLaTeX to accomplish their objectives; these packages simply couldn't have been written at all in pdfLaTeX or XeLaTeX. Examples are the
showhyphens
andselnolig
packages. (Full disclosure: I'm the main author of theselnolig
package.)Some typesetting tasks can be accomplished more easily (or, at least, with no more work) in LuaLaTeX than in either pdfLaTeX or XeLaTeX. Compare, for instance, the following two code chunks (from the posting Arithmetic temporaries in tex). In both cases, the macro
\StrMid
serves to extract a substring from a string:\usepackage{luacode} % for "\luastring" macro \newcommand\StrMid[3]{\directlua{tex.sprint(string.sub(\luastring{#1},#2,#3))}}
versus
\usepackage{xparse} \ExplSyntaxOn \NewExpandableDocumentCommand{\StrMid}{mmm} { \tl_map_function:fN { \tl_range:onn { #1 } { #2 } { #3 } } \use:n } \cs_generate_variant:Nn \tl_map_function:nN { f } \cs_generate_variant:Nn \tl_range:nnn { o } \ExplSyntaxOff
By contrasting these two chunks of code, I certainly do not mean to slight the author of the LaTeX3 code. Not at all! All I mean to do is to show that some tasks can be rather easy to accomplish if one knows even just a little bit of Lua. This is especially true when it comes to manipulating strings, as Lua provides quite a few powerful string-handling functions.
If you're used to working with a modern programming language but haven't ever fully mastered all the fine points of a macro expansion language -- I myself must plead guilty to just this charge... -- you'll probably find it much easier to program some non-trivial typesetting tasks by using Lua code and the clear interface between Lua and TeX that's built into LuaTeX.
Lua is a programming language designed to run in a small easily embedded virtual machine (much smaller than the Java JVM for example) and so ideal for embedding in other systems (it is used as the configuration language for several games for example).
So it is not developed by the luatex people (in fact Lua itself is currently at at least at version 5.3, ahead of the Lua 5.2 version shipped with luatex) but chosen as a suitable extension language.
It can be used to re-implement several of the built in TeX algorithms
It's more or less OS independent
Yes as you see in Luatex it can handle Unicode fonts and Unicode strings (Unicode strings are exposed as UTF-8 encoding so a single unit is a byte rather than a character)
As an example of what can be done with LuaLaTeX, I created a script that automatically converts CSV data into the LaTeX tabular or matrix format. It is quite useful for lab reports since the user no longer has to worry about manually updating data or simulation results in the TeX file.
https://gist.github.com/calebreister/8dd7ab503c91dea4dd2c499b9d004231