lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



Well, we are really drifting away OT, so I think it is better to spawn a subthread :-)


On 23/06/2011 23.38, Dimiter "malkia" Stanev wrote:
Lua is very much suited for exploratory programming, live coding,
scripting, customizing, tweaking, even creating makefile system (premake
for example) at very fast pace without recompile, relink cycles. My plan
someday is to be able to use it from Autodesk products to write certain
plugins, without the need to recompile, and ability to tweak and fix the
things on the fly. Also any technical artist would prefer Lua much more
than C++.


I don't know if Lua is suited for very large applications. Those where traditional imperative languages are said to need strong compile-time checks to be robust (if someone has an experience to share, he/she is welcome!).

I find Lua exceptional for (high-level) code generation and templating: together with lightwight OOP modeling and a DSL it can be hugely expressive. All in less than 1kLOC usually. For example, in this way I generated (using a modified version of the template engine of Rici Lake available on the WIKI) html pages and LaTeX sources, whose content is taken from a Lua data file written in a custom DSL. Sort of XSLT + XML approach, but waaaaay more readable and lightweight! :-)

One of its merit in this respect is that, although it is not Unicode aware, its strings are 8-bit clean. Moreover, as Roberto replied to one of my questions, the lua interpreter (not the core - note) relies on the C runtime for reading a script. So, although it cannot be *guaranteed* (because C standard doesn't guarantee it either) that the interpreter can load UTF-8 encoded scripts, I found that it works smoothly. This is very good for templates used to generate html or LaTeX (or whatever text file format which should support Unicode), since you can embed unicode chars directly in the template (or in Lua string literals).

Now take that, and in only 300kb executable code you have LuaJIT that
can bring the performance very close to "C" for a lot of things.

I've seen only few other languages, systems close to that. One is Common
Lisp (and specific implementations), but no Common Lisp system comes
small, and all of them are statically compiled in dynamic environment -
unlike LuaJIT with trace compilation. For that reason the get fast code
in CL you have to specify where needed the types, and these serve as
promises to the compiler, which he would obey and make your code fast
(SBCL, LispWorks, Allegro, ClozureCL and others are doing pretty good
job at it).

On 6/23/2011 2:07 PM, Francesco Abbate wrote:
Lorenzo, Henning, all,

thank you very much for the interesting discussion about Java and
Erlang, you are certainly more knowledgeable than me about these
programming languages and I think that I'm going to learn more about
Erlang.

Ultimately it seems that the idea that I had of Java is basically
correct even if I was not aware of a lot of details. I have no
experience of Java programming, my only knowledge came from my work
where we have a lot of Java applications. Sometimes they throw stupid
exceptions and became unusable and they are so terribly slow and
memory hungry so I just hate them.

For the other side my feeling is also that Lua really *lacks* the
possibility of Java to detect errors before execution using a typing
system or something similar. The fact that you have no types at all
and no warnings of any kind even for a small typing error is terrible
when you develop something even moderately complex. In addition you
don't even have a debugger so it is even more painful. And yes I know
that some home-made 'strict' packages and debugger exists but they are
often incomplete and of little aid.

When I work in C or C++ I'm glad that many trivial and not-so-trivial
errors can be detected during compilation and, what a relief, I can
throw the debugger and inspect all the variables step-by-step when I
really don't understand.

This is even more OT but it is strictly related to the Java
discussion. Where Java is very strong Lua is terribly lacking :-) and
please, no flames, I don't want to be polemic, I express just some
reflections about a programming language, Lua, that I ultimately like
and use (beside C, C++ and python).

Francesco






-- Lorenzo