An essay inspired by this short youtube video: Why learn LUA ?
(Caution: AI generated content, watch out for hallucinations !)
On the surface, Eiffel and Lua are about as different as two programming languages can be. Eiffel is a statically typed, compiled, pure object-oriented language built around Design by Contract, with a type system strict enough to prove void safety at compile time. Lua is a dynamically typed scripting language that fits in a few hundred kilobytes and has no classes at all. Eiffel wants you to write specifications. Lua wants to get out of your way. One is associated with banking, aerospace and defence. The other powers game mods, Neovim configurations, and nginx plugins.
Look closer, though, and the two start to look like distant cousins. They share origins, aesthetics, and a set of convictions about what a language should leave out. Those shared convictions are less obvious than their differences, and more interesting.
Full article:
-- SmartDevelopersUseUnderScoresInTheirIdentifiersBecause_it_is_much_easier_to_read (Eiffel = Security by Contract + C Speed)
Short note: If I activate one of the links I get an "Access denied"...
I cut and paste the contents while eiffel.org was still in edit mode which is why the links did not work.Â
Here is the corrected version.
Hi Ulrich,
I think the answer to "why YAL?" is that Lua was never trying to compete with general-purpose languages, so comparing its syntax against theirs misses where its strength lies. IÂ watched this video by a developer called David Hockley, who used Lua as the glue between the user interface and the C++ engine of the city-builder game Cities XL, and he makes the point well: Lua was designed as an extension language, not a standalone one. It's implemented as a small C library (the full reference interpreter compiles to roughly 250 KB), so it's portable, fast, and easy to embed inside a host application. The killer feature is embeddability rather than any particular language construct. That's why you ran into it in Lightroom, and why it turns up in Roblox, World of Warcraft, the Solar2D game engine, Redis (for running logic inside the database) and Neovim (for configuring the editor).
On the "uncertain future" worry, Lua isn't really new. It dates from 1993 (from PUC-Rio in Brazil), which makes it older than Java or JavaScript, and it has a long track record in exactly this embedded niche.
As a language, its appeal is simplicity with a
surprising amount of flexibility. It has only about 21 or 22
keywords (depending on version) and a single data structure, the
table, which serves as array, hash map, set and namespace. There
are no built-in classes or inheritance, but you can build them
yourself using "metatables," which let you override how a value
behaves: what happens when a table is called like a function (__call),
how fields are read and written (__index, __newindex),
how tables are added or compared (__add, __eq),
and so on. David describes this as almost being able to program
the behaviour of the language itself, which makes it easy to
learn but harder to master.
On concurrency, Lua has coroutines, which are cooperative, not parallel threads. So it's good for things like game scripting and state machines, but it doesn't offer true multi-core concurrency out of the box.
The video is also honest about the weaknesses. You can't build a complete application in Lua alone, since the heavy lifting (rendering, for example) is done in the host language, and outside game development there are few jobs that require it. So you're right that there's little reason to switch to Lua as a primary language. It makes sense when an application you use already offers Lua bindings and you want to extend it, or when you want a lightweight way to make your own C/C++ program scriptable.
Above all else, proponents of Lua say it's a very enjoyable/fun language to work with. To me it is the ideal beginners language, and would be a good stepping stone to learning Eiffel.
Kind regards,
Finnian
Hi Roger,
Thanks for digging that out. It holds up remarkably well fifteen years on.
Your point about providing value to 1_000_000 users rather than converting 1_000 programmers resonates. I'd push the number further, to 1_000_000_000 users. That's less fanciful than it sounds, since the eXpat XML parser is present on at least that many devices.
As you may have read, Anders Persson and I are building a drop-in replacement for libexpat (Xpact) written in Eiffel, using the Python community's wrapper as the gateway. The pitch is that it's both more secure and faster than the C original. It follows the current trend of rewriting critical C infrastructure in Rust, but with Design by Contract finding errors that Rust might miss.
It also ticks another box on your slide: "Make Eiffel-quality applications possible without having to write them in Eiffel." A Python developer using it never needs to know there's Eiffel underneath.
I'll be announcing the fifth milestone on this project shortly.
Regards,
Finnian
Hi Roger,