lua-users home
lua-l archive

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


I was planning to make a separate post here, when I have little bit more progress.
But I think it's a good moment to mention it for the first time.

I'm making my own language that compiles to LuaJIT bytecode (main target, can be changed for Lua as well), based on Lua and made in Lua at the current moment. The main idea is ahead of time optimizations, C++-like zero-cost concept. The purpose is to make highly-maintainable but fast and optimized code.
This is similar to what C++ did on C.

As example: function inlining, inline bytecode block, templates, more variable attributes, static typing and macros.

I made a first draft/concept for it here: https://github.com/GitSparTV/LLLua/blob/v0.1/CONCEPT.md

-- Example
-- Can compile a separate function for external linking, but in the code just inlines into `instance.size_`.
-- Or even make everything offset-like and inline to `instance[0]` if `size_` member is the first in the definition.

function class:size() <inline>
    return self.size_
end

-- Internal Lua functions are like C++ constexpr and can evaluate the value at compile-time.
-- Bytecode will have one instruction that pushes literal string "aaaaaaaaaa" onto the stack, string.rep function won't be called.

print(string.rep("a", 10))

My first attempt was ASM-like language but with LuaJIT instructions: https://github.com/GitSparTV/LLLua/tree/v0.1/0.1
On 28 Mar 2022, 18:51 +0300, Marek Novak | ACRIOS Systems s.r.o. <novak@acrios.com>, wrote:
Hello Roberto & all mailing list members,

Maybe I could mention we use Lua (5.1.5 planning to move to 5.4.4) in
our IoT devices. Here is the API we use
https://wiki.acrios.com/en/acr-cv/lua-api .

Basically, as we have constrained resources (STM32L431CC
microcontroller, 256kB FLASH, 64kB SRAM) we adjusted luaconf.h not to
use floats etc.
The use-case of the device is to be a universal scriptable and
programmable converter between Modbus/MBus/wireless MBus and NB-IoT and
LoRaWAN radio protocols. It can be used as data concentrator, smart IoT
end node sensor or actuator etc.

We have implemented over-the-air firmware update, but in IoT networks,
the amount of data to consume during it and also the energy that is
consumed during it has to be kept low - so we profit from having Lua -
in case we need to adjust just the high-level application logic, we
don't update the whole firmware (180-230kB LZF compressed), but just the
lua script (3-8kB).

I went even further in this, and thought of making it possible to
dynamically update the Lua API by uploading a new API function, linked
against already existing firmware, so that every device has its 1-6kB
"patch" area in the firmware. Thanks to that, we can theoretically
replace a buggy API function without re-uploading the whole firmware. I
published a paper on the topic here:
https://ieeexplore.ieee.org/document/8733437 in 2019. However since
then, we did not need to use it in practice yet, but it can save the day
by making it possible to do economy firmware update for thousands of
devices without draining the IoT device batteries, once it is needed.

Thank you for giving world Lua!

(+ sorry for answering first directly to you and now correctly to the
mailing list... this is my first mailing list message)

---
Marek Novak
CTO, ACRIOS Systems s.r.o.

On 28. 03. 22 17:42, Matthew Wild wrote:
On Mon, 28 Mar 2022 at 14:13, Roberto Ierusalimschy
<roberto@inf.puc-rio.br <mailto:roberto@inf.puc-rio.br>> wrote:


Are there new relevant uses of Lua we should be aware of?
("new" ≈ released in the last year.)


Some interesting new Lua-based or related projects that crossed my radar
in the past year or so:

- SNKRX, an open-source game written in Lua. Steam:
https://store.steampowered.com/app/915310/SNKRX/
<https://store.steampowered.com/app/915310/SNKRX/> Github:
https://github.com/a327ex/SNKRX <https://github.com/a327ex/SNKRX>

- MicroStudio is an online game development environment, it added Lua
support this year:
https://microstudio.dev/community/news/microstudio-now-supports-4-programming-languages-microscript-python-_javascript_-and-lua/254/
<https://microstudio.dev/community/news/microstudio-now-supports-4-programming-languages-microscript-python-_javascript_-and-lua/254/>

- RedBean is a self-contained portable binary web server. It embeds Lua
for dynamic page generation: https://redbean.dev/ <https://redbean.dev/>

- FullMoon extends RedBean's default Lua runtime with a more extensive
framework for web applications: https://github.com/pkulchenko/fullmoon
<https://github.com/pkulchenko/fullmoon>

- Lite XL is a GUI text editor written in Lua:
https://github.com/lite-xl/lite-xl <https://github.com/lite-xl/lite-xl>

- https://supershields.io/ <https://supershields.io/> is a web service
that can dynamically generate "badges" (small informational images)
backed by Lua scripts (dev docs:
https://github.com/0ddParity/supershields/wiki/Supershields-scripting
<https://github.com/0ddParity/supershields/wiki/Supershields-scripting> )

- Self-contained Lua 5.1 distribution (Go reimplementation):
https://github.com/tongson/LadyLua <https://github.com/tongson/LadyLua>

- Yuescript is a Moonscript dialect (compiles to Lua):
https://github.com/pigpigyyy/Yuescript
<https://github.com/pigpigyyy/Yuescript>

- The mpv video player supports Lua plugins (not new), enabling
experiments such as https://github.com/dfaker/VR-reversal/
<https://github.com/dfaker/VR-reversal/>

- LuaRT is a Windows-focused Lua distribution/framework:
https://www.luart.org/ <https://www.luart.org/>

- Roblox open-sourced their Lua-derived scripting language:
https://luau-lang.org/ <https://luau-lang.org/>

- Zoltan, for hosting Lua in Zig programs:
https://zig.news/ranciere/zoltan-a-minimalist-lua-binding-4mp4
<https://zig.news/ranciere/zoltan-a-minimalist-lua-binding-4mp4>

- "Writing Compiler Front-Ends for LLVM with Lua using Mewa":
https://www.codeproject.com/Articles/5301384/Writing-Compiler-Front-Ends-for-LLVM-with-Lua-usin
<https://www.codeproject.com/Articles/5301384/Writing-Compiler-Front-Ends-for-LLVM-with-Lua-usin>

- LunarML, ML->Lua compiler: https://github.com/minoki/LunarML
<https://github.com/minoki/LunarML>

- Lua for PalmOS:
https://oldvcr.blogspot.com/2021/08/plua-revisited-lua-for-palmos-and.html
<https://oldvcr.blogspot.com/2021/08/plua-revisited-lua-for-palmos-and.html>