r/lua • • Aug 07 '26

Lua.org is down. Plz fix thx

Thumbnail lua.org
1 Upvotes

r/lua • • Jul 14 '26

Show HN: L2C - Transpiling Typed Lua into 35KB, 0-GC Native C for HFT and MCUs

Thumbnail
gallery
0 Upvotes

Hi HN,

I love the elegant syntax of Lua, but in microsecond-critical environments like High-Frequency Trading (HFT) or hard-real-time embedded systems, GC pauses (jitters) are deal-breakers. C++ solves this but introduces massive cognitive overhead.

So I built L2C — an opinionated, ahead-of-time (AOT) transpiler pipeline that converts Typed Lua (Teal) into bare-metal C (via Nelua), and finally links it with Clang -O3 -flto.

What makes it deadly pragmatic?

  • Absolute 0-GC: Garbage collection is physically stripped. We use Stack Arrays and 10MB Arena Allocators that reset in O(1) time.

  • Tiny Statically Linked Binaries: The resulting executable is around ~35KB.

  • Zero-Copy Casting: Network byte streams (e.g., from UDP/ZMQ) are mapped directly to C-struct pointers via Type._cast(ptr) without deserialization overhead.

  • C-FFI Unity Build: I wrote an "Invisible Debt Registry" that automatically resolves static library dependencies like -lc++ or -lsodium. It currently ships with 0-GC bindings for ZeroMQ (tested at 530k+ msg/s), simdjson (AVX-512), and libuv.

  • Edge IoT Support: The exact same Lua script can be cross-compiled into .uf2 or .bin firmwares running on top of FreeRTOS for RP2040 and ESP32.

Here is what the HFT gateway code looks like:
(It feels like scripting, but runs like raw ANSI C)

The meta-compiler itself is packed into a standalone binary.
Source code and Docker forges are available here:
🔗 GitHub: https://github.com/panshaogui/L2C

Would love to hear your thoughts, especially from the quant and embedded folks!


r/lua • • Jul 25 '25

Help What symbol is unexpected? (first 50 lines of challenges.lua below)

Post image
0 Upvotes
.CHALLENGES = {
    --[[{
        name = 'TEST',
        id = 'c_test_1',
        rules = {
            custom = {
                --{id = 'no_reward'},
                {id = 'no_reward_specific', value = 'Big'},
                {id = 'no_extra_hand_money'},
                {id = 'no_interest'},
                {id = 'daily'},
                {id = 'set_seed', value = 'SEEDEEDS'},
            },
            modifiers = {
                {id = 'dollars', value = 100},
                {id = 'discards', value = 1},
                {id = 'hands', value = 6},
                {id = 'reroll_cost', value = 10},
                {id = 'joker_slots', value = 8},
                {id = 'consumable_slots', value = 3},
                {id = 'hand_size', value = 5},
            }
        },
        jokers = {
            {id = 'j_egg'},
            {id = 'j_egg'},
            {id = 'j_egg'},
            {id = 'j_egg'},
            {id = 'j_egg', edition = 'foil', eternal = true}
        },
        consumeables = {
            {id = 'c_sigil'}
        },
        vouchers = {
            {id = 'v_hieroglyph'},
        },
        deck = {
            --enhancement = 'm_glass',
            --edition = 'foil',
            --gold_seal = true,
            --yes_ranks = {['3'] = true,T = true},
            --no_ranks = {['4'] = true},
            --yes_suits = {S=true},
            --no_suits = {D=true},
            cards = {{s='D',r='2',e='m_glass',},{s='D',r='3',e='m_glass',},{s='D',r='4',e='m_glass',},{s='D',r='5',e='m_glass',},{s='D',r='6',e='m_glass',},{s='D',r='7',e='m_glass',},{s='D',r='8',e='m_glass',},{s='D',r='9',e='m_glass',},{s='D',r='T',e='m_glass',},{s='D',r='J',e='m_glass',},{s='D',r='Q',e='m_glass',},{s='D',r='K',e='m_glass',},{s='D',r='A',e='m_glass',},{s='C',r='2',e='m_glass',},{s='C',r='3',e='m_glass',},{s='C',r='4',e='m_glass',},{s='C',r='5',e='m_glass',},{s='C',r='6',e='m_glass',},{s='C',r='7',e='m_glass',},{s='C',r='8',e='m_glass',},{s='C',r='9',e='m_glass',},{s='C',r='T',e='m_glass',},{s='C',r='J',e='m_glass',},{s='C',r='Q',e='m_glass',},{s='C',r='K',e='m_glass',},{s='C',r='A',e='m_glass',},{s='H',r='2',e='m_glass',},{s='H',r='3',e='m_glass',},{s='H',r='4',e='m_glass',},{s='H',r='5',e='m_glass',},{s='H',r='6',e='m_glass',},{s='H',r='7',e='m_glass',},{s='H',r='8',e='m_glass',},{s='H',r='9',e='m_glass',},{s='H',r='T',e='m_glass',},{s='H',r='J',e='m_glass',},{s='H',r='Q',e='m_glass',},{s='H',r='K',e='m_glass',},{s='H',r='A',e='m_glass',},{s='S',r='2',e='m_glass',},{s='S',r='3',e='m_glass',},{s='S',r='4',e='m_glass',},{s='S',r='5',e='m_glass',},{s='S',r='6',e='m_glass',},{s='S',r='7',e='m_glass',},{s='S',r='8',e='m_glass',},{s='S',r='9',e='m_glass',},{s='S',r='T',e='m_glass',},{s='S',r='J',e='m_glass',},{s='S',r='Q',e='m_glass',},{s='S',r='K',e='m_glass',},{s='S',r='A',e='m_glass',},},
            type = 'Challenge Deck'
        },
        restrictions = {
            banned_cards = {
                {id = 'j_joker'},

r/lua • • Mar 05 '25

Discussion Is it possible?

0 Upvotes

Original "So, if there is an IDE, that like, lets you make a game with LUA, that isn't LOVE2D, or ZeroBrane Studio, I wanna know, because I wanna take the challenge.

Edit: I know LOVE2D is a Framework meant for helping you make a game! I just called it an IDE as I don't wanna add ", or a Framework that isn't LOVE2D", I just wanted to keep my sentence very simple!"

2nd Edit: Here, since you guys want to correct me instead of giving me an answer, "Okay, so I want an IDE (Integrated Development Environment), that lets you use LUA, I do not want to use LOVE2D (A Framework), or an IDE such as ZeroBrane Studio, I want an IDE that lets you make 2D games, like how for Example; VS Code, Eclipse Workspace-Java, Eclipse Workspace-C++, IntelliJ IDEA, NetBeans, and JDeveloper, but for LUA of course, as I want a small challenge.

Oh I should also add this, "I do not want a Game Engine, I will make my own Game Engine in the IDE" "

Also stop arguing please over correct wording, I fixed it for those who need it more detailed, I already have a guy give me one "TIC-80", and it has been solved, but you may add more IDEs if you want to.


r/lua • • May 13 '23

Help What is the worst a lua back door could do

0 Upvotes

I want to get into this game that uses a lot of player made lua scripts and I’ve heard of back doors in lua what exactly is the worst a lua back door could do?


r/lua • • Nov 26 '24

Project My 100% free obfuscator

0 Upvotes

Hello,

I created a free Discord obfuscator bot with no hidden costs. It was a great learning experience for me, so it’s a win-win for everyone.

Enjoy!

https://discord.gg/N25mkPRsk9


r/lua • • Feb 09 '18

Why do people like lua?

4 Upvotes

I've started actually learning more about it and well.

Pretty much everything is a table, okay, not that hard to get with this, loops and if statements are pretty simple to remember, it's weird to get length of a table but not that hard to remember, can live with that, different language, different syntax.

You can have objects, but they are still tables. Well, okay, whatever, I'm used to writing same shit over and over again because I've used java before, whatever, that's fine, I guess.

Global scope is just a giant table and so it's better to just write even more code to localize everything you'll use, otherwise it will be slow (multiple hashtable lookups whenever you use some global function in a table of table of the table in a table that is in another table). Uh, just why? That's first time I hear that in any language, localizing everything would make your code run faster, it's not really obvious, although once you realize that global scope is a table, only logical, but, why?

What's the appeal to this? And why did people stick with it? I thought that I'd see why people use lua over say python if they add scripting support to their game, but all I saw now is that I actually would lean even more towards using python there. If you have to be a professional programmer to write efficient code in lua, then python being slower does nothing for average person who would mod a game, because average person is not professional programmer who knows languages in and out, and little details such as localizing globals makes it run faster, which ranges from 10% slower without localizing to 400%+ (ridiculous) slower without localizing. Hell, most people who do that just instead look for tutorials on how to mod x game using lua, instead of learning lua.

I'm not saying that language is unusable, I'll still finish my project while learning it, but things like this just add to the "things you do to waste more time than needed" which are caused by bad design.


r/lua • • Aug 28 '26

I wrote an RDBMS engine 100% from scratch in pure Lua (B+Trees, WAL, Postgres wire protocol, S3 storage)

9 Upvotes

Hey r/lua!

Wanted to share a project I've been building called LuaDB: a lightweight, zero-dependency embeddable database system written in pure Lua.

Why pure Lua? Cross-platform embedding without needing C bindings or compiling native SQLite shared libraries (great for LÖVE, Roblox, OpenResty, or embedded devices).

What it includes:

  • Full B+Tree index engine on 4KB slotted binary pages

  • Write-Ahead Logging (BEGIN, COMMIT, ROLLBACK)

  • Native PostgreSQL wire protocol gateway (run luajit bin/luadb_server.lua and connect with psql)

  • Native JSONB operators (details->'address'->>'city')

  • Foreign Keys with ON DELETE CASCADE and ALTER TABLE migrations

  • Master-master cluster replication with hinted handoff

Check out the GitHub repo: https://github.com/jncastilho/luadb

Would love to hear your thoughts and feedback!


r/lua • • May 25 '26

lua-rs: Lua 5.4.7 implemented from scratch in Rust - passes upstream Lua C test suite fully

12 Upvotes

Github: https://github.com/ianm199/lua-rs/tree/main

Highlights:

  • Passes full upstream tests

  • Performance is near parity with C checkout dashboard here on optimization. Table ops seem to be much faster

  • Has GC, VM, and supports all Lua sytnax. Any pure lua script should run

  • Limited unsafe calls - mostly just in the GC for now

My motivation here was that in the long run we want the core internet utilities to run on memory safe languages, big ones like redis and nginx expose scripting via Lua so if we really want to replace core infra fully in Rust, you'd need a full Rust Lua that doesn't bundle C. After that you should be able to i.e. build drop in replacements for those without a C ABI (or that's part of the way there).

Long term goals:

  • Get to stable, production ready

  • Get performance at parity or faster then Lua C

  • Replace current unsafe GC with fully safe if possible

  • (Maybe) support Lua 5.1, LuaJIT


r/lua • • Jan 05 '16

SO I want to Learn Lua

0 Upvotes

I guys i i'm insterested on learning lua, do you suggest any books /tutorials /language doc's you use/used??


r/lua • • Mar 19 '26

Help Looking for Free Online Resources to Learn Lua for Roblox Development

1 Upvotes

I am very interested in becoming a Roblox developer and would like to find an online resource where I can learn Lua programming for free.


r/lua • • Apr 01 '16

[lua-l] Lua 5.4 will drop Windows support in favor of Linux optimization

Thumbnail lua-users.org
0 Upvotes

r/lua • • Aug 17 '26

How to Obfuscate and Protect Source Code of My Love2D game?

Thumbnail reddit.com
0 Upvotes

r/lua • • Apr 10 '22

VSCode Lua don't have wait.

0 Upvotes

So, I make code that's supposed to make Hello, World! every second and it don't work as there's no wait. I'm used to having wait in Roblox studio. As that wait is task.wait(Insert seconds here) and if you do it all it gives is wait is a nil value.


r/lua • • Dec 16 '22

Help LUA Video Game Code

0 Upvotes

I am turning to the lovely pages of Reddit to find someone who is experienced in LUA or possibly specifically LUA that belongs to a video game to take a look at a code file that deals with player appearance in Madden 22 for PC. I am part of a Modding community for the game as we are trying to get rid of certain meshes by editing the LUA but none of us are fluent to understand or decipher how or what to get rid of. If anyone could help or want to take a look at the code it would be greatly appreciated :)


r/lua • • Jul 02 '22

Help There is NO way to "build".

1 Upvotes

I think I've looked everywhere to find a way to compile or build lua into an executable.

I thought this would've been simple, since lua is interpreted in C, but I can't find nothing that's right for me.

I'm working on a project and I really think that lua is an amazing language, but I'd also like to someway hide my code so that not everyone can come and just mess with it.

If there is anything that can be done to achieve this, for example translating lua to C and then compiling, please tell me, at this point I don't know what to look for

EDIT: The solution was to use luac to compile the files into bytecode and luastatic to pack the code into a standalone version


r/lua • • Sep 13 '24

Discussion Is Lua worth learning?

4 Upvotes

For mostly game-making


r/lua • • Dec 09 '22

Find some clues guys

Post image
0 Upvotes

r/lua • • Apr 06 '16

We are +2000 friendly learners, students and pro developers who are ready to help you when you get stuck. Come join our chat!

Thumbnail devchat.devolio.net
1 Upvotes

r/lua • • Feb 08 '20

what about a localized Lua ( i.e. keyword in non-english languages ) ?

1 Upvotes

Hello,

For kids and teens, a first barrier when learning to code is the language... I mean.... not Lua vs. c++, English vs. Italian or French ;-)

I have not seen any programming-language which would be spoken-language neutral. (i googled without success)

i.efor i=1,f(x) do print(i) end could be written pour i=1,f(x) faire afficher(i) fin in French para i = 1, f(x) hacer mostrar(i) terminar, etc...

Altough it does not seems to hard on the surface, I have not seen that implemented in anywhere. so, i must not be that easy ....

I know a few things about coding ;-) but to be honest, I have 0 knowledge in compiler/interpreter/debbuger/IDE development, so I do not really know what I am talking about ...

( the source code text changes, even if the tokenization/lexical analysis would have the same output ... not smart enough to assess how bad this would be .... )

Does anyone known why it has not been done, what it can not be done ?

if not at the interpreter-level, any thought on the complexity implement that in the IDE ? adding a babel fish (;-) )in the syntax highlighter, for instance and defining a way for 3rd parties to provide the translation of their functions, etc...

Thanks !


r/lua • • Dec 17 '21

lua G HUB code HELP

0 Upvotes
EnablePrimaryMouseButtonEvents(true);

function OnEvent(event, arg)
    if IsMouseButtonPressed(3) then
        PressMouseButton(4)
        Sleep(200)
        ReleaseMouseButton(4)

    end
end

someone can help me here im using G hub and mouse g502 and what i want to do is when i click my left click it will send my X1 click on my mouse.

for some reason both 4,5 not working with the PressMouseButton the only ones that work are 1,2,3,

tnx.


r/lua • • Apr 29 '14

Math confusion (1 < 1 = true)

0 Upvotes

Okay. So I'm kinda tired and have probably missed something. But check this out please:

test = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1
if test > 1 then
    print(test .. " is more than 1")
elseif test == 1 then
    print(test .. "  is 1")
elseif test < 1 then
    print(test .. " is less than 1")
end

The output I get from the code above is that 1 is less than 1. Why? Shouldn't the output be 1 is 1? What have I missed? Have I fucked up my local Lua installation somehow?

Edit: The following code (in addition to the one above) does not make any sense to me at all...

test2 = test - 1
print(test2)

Output:

-1.1102230246252e-16

r/lua • • Feb 29 '20

Colour And RGB Values?

0 Upvotes

I recently just got into Lua and wanted to see if it was possible to swap out the Color value with a RGB value instead


r/lua • • Aug 16 '16

TIL You can create function with single arguments, return the function itself, and call it without any parenthesis.

0 Upvotes

Consider this function

function asd(...)
	print(...)
	return asd
end

Then, I call it like this

asd "Hello" "World"

It will display

Hello
World

EDIT: Fixed return calls of asd


r/lua • • Mar 23 '25

How do I learn Lua???

3 Upvotes

Hello I recently had the idea to learn how to code I heard that lua is better than python while still being as easy or easier than python the only problem is where do I start? What resources should I use to learn Lua? Can somebody help me. Thank You.