Anonymous · original post · 2026-07-11 02:57:26
>>25285
What about TCL? Is it also small enough?
Report · Quote
Anonymous · reply · 2026-07-11 03:00:58
>>25335
TCL is a few megabytes
Lua is WAY smaller, it's not even close.
Report · Quote
Anonymous · reply · 2026-07-11 03:03:25
>>25336
What about TinyLisp?
Report · Quote
Anonymous · reply · 2026-07-11 03:04:47
>>25334
256kb WASM or even less that can run lua and manipulate DOM would be awesome
Report · Quote
Anonymous · reply · 2026-07-11 03:14:53
>>25332
Yea, I know.
Report · Quote
Anonymous · reply · 2026-07-11 03:23:22
>>25338
I haven't worked on it for a while, but the latest I had it compiling down to 375kb. With certain emcc flags I managed to bring it down to closer to 250kb but it hurt the Lua VM performance a lot, so under 400kb is a more reasonable target.
A lot of that is the JS side (type marshaling alone is 1k lines of JavaShit) and additional logic in Lua, like an extension of the garbage collector for circular references between JS and Lua heap.
God I really need to work on this again. I would personally eat my own dogfood and use it over the alternatives already even though it's not done yet since Lua in the browser is just so underserved (there's not many options)
I'm considering removing a bunch of stuff from it just so I can reduce debugging complexity and get it to a state I'm comfortable putting on github.
Report · Quote
Anonymous · reply · 2026-07-11 03:32:39
>>25340
lua and js are close enough that requiring a luajit-sized (300 kb) blob just for running one vm in another is just tragic and a loss of performance, compared to transpiling.
Report · Quote
Anonymous · reply · 2026-07-11 03:34:48
>>25341
They are close on the surface but their VMs are nothing alike.
Report · Quote
Anonymous · reply · 2026-07-11 03:45:05
>>25341
Coroutines and most metamethods can't be represented in JS btw. So you wouldn't be able to support the whole language spec this way.
Report · Quote
Anonymous · reply · 2026-07-11 04:08:24
>>25343
lua coroutines map into js generators, metamethods map into js proxy and/or replacing operators with explicit function calls.
Report · Quote
Anonymous · reply · 2026-07-11 04:16:24
>>25344
Using generators as ghetto coroutines is going to be harder than it looks when you have stuff like a coroutine resuming a coroutine resuming a coroutine, etc. but yeah it could work.
Report · Quote
Anonymous · reply · 2026-07-11 04:18:53
aren't there like five different and backwards-incompatible Lua's? each version is slightly different and each JIT is slightly different.
Report · Quote
Anonymous · reply · 2026-07-11 04:24:28
>>25346
Not really. The closest thing I can think of to what you're implying is that Lua 5.2 changed how function environments work (a 5.1 feature) but that's about it. Lua 5.5 is backwards compatible with Lua 5.2 and most Lua 5.2 code that doesn't touch fenvs will also work with 5.1.
>each JIT
There is only 1 LuaJIT, written by Mike Pall, which is the 5.1 spec with some 5.2 features backported.
Report · Quote
Anonymous · reply · 2026-07-11 04:26:47
>>25347
thanks. as for JITs I meant various commercially-supported forks like Luau (Roblox), GLua (Facepunch), OpenResty LuaJIT etc
Report · Quote
Anonymous · reply · 2026-07-11 04:29:43
>>25348
GLua is just PUC Lua 5, and OpenResty uses Mike Pall's LuaJIT
Luau yeah I guess.
Report · Quote
Anonymous · reply · 2026-07-11 04:30:43
>>25349
5.1*
Report · Quote
Anonymous · reply · 2026-07-11 04:30:57
>>25333
Funny you say that, once upon a time back in like '02 I hacked together an experiment like that.
Report · Quote
Anonymous · reply · 2026-07-11 06:00:06
>>25349
>GLua is just PUC Lua 5
GLua has C-style logic operators and comments
Report · Quote
Anonymous · reply · 2026-07-11 07:55:49
>>25315
Ive only seen nocoders cry about this
Report · Quote
Anonymous · reply · 2026-07-11 09:43:20
>>25285
Mike Pall returns to discuss new syntax additions to be added in LuaJIT 3.0
https://github.com/LuaJIT/LuaJIT/issues/1475
Some of them are already backported to LuaJIT 2.1
https://github.com/LuaJIT/LuaJIT/issues/1476
My favorite are
>ternary
>short functions
>safe navigation operator
Report · Quote
Anonymous · reply · 2026-07-11 09:54:32
>>25354
>returns
Pretty active on github actually, idk why I thought he was gone
Report · Quote
Anonymous · reply · 2026-07-11 11:04:07
>>25354
>ternary
bro you literally call already do that with "and" and "or". do you really think saving to type 3 characters is a significant improvement?
Report · Quote
Anonymous · reply · 2026-07-11 12:19:01
>>25354
I love the idea of short functions, but that syntax is kind of garbage.
The safe navigation operator is definitely my favorite from the list, if I had to pick 1 feature to add to keep Lua de-bloated that would be the one.
>>25356
Not a ternary operator, that's just short-circuited logical operators. Try it yourself and see `a and false or b` returns `b` regardless of whether `a` is true or not. If it was a real ternary operator then it would return false if a was true and b if a was false.
Report · Quote
Anonymous · reply · 2026-07-11 14:35:27
>>25285
I just recently looked into Lua because I got interested into prototype based OOP languages like self and io and to me their object model implementation makes more sense than a class-instance based one
Lua is already similar in terms of delegation to prototype OOP and it's really easy to implement it under Lua. I asked chatgpt to write a simple library and seems to work pretty fine, at least for toying around
-- object.lua
local Object = {}
local Meta = {}
local function lookup(self, key)
local value = rawget(self, key)
if value ~= nil then
return value
end
local proto = rawget(self, "__proto")
if proto then
return lookup(proto, key)
end
end
Meta.__index = function(self, key)
local value = lookup(rawget(self, "__proto"), key)
if value ~= nil then
return value
end
local forward = lookup(self, "forward")
if forward then
return forward(self, key)
end
end
function Object:clone(slots)
local obj = slots or {}
rawset(obj, "__proto", self)
return setmetatable(obj, Meta)
end
function Object:proto()
return rawget(self, "__proto")
end
function Object:slotNames()
local names = {}
for name in pairs(self) do
if name ~= "__proto" then
names[#names + 1] = name
end
end
return names
end
function Object:forward(name)
error("message not understood: " .. tostring(name), 2)
end
setmetatable(Object, Meta)
return Object
So I can do
local Animal = Object:clone {
speak = function()
print(self.sound .. "!")
end
}
local Dog = Animal:clone {
sound = "woof"
}
Dog:speak()
Report · Quote
Anonymous · reply · 2026-07-11 15:01:46
>>25358
I personally don't like it (tables are enough) but people have been doing this for a really long time, it's a completely valid use of metatables
http://lua-users.org/wiki/SimpleLuaClasses
Report · Quote
Anonymous · reply · 2026-07-11 15:07:15
If you use libev as an event loop in your host program you can trivially access it from lua with lua-ev for timers, io watchers etc. Probably works with uv, too.
I'm also a fan of luaposix to access the complete (?) posix C api from lua.
Is there an alternative to luafilesystem? I'm not using it simply because it pollutes the global namespace.
Report · Quote
Anonymous · reply · 2026-07-11 15:10:40
>>25358
Btw for the specific example you showed, you can just do it out of the box using __index, without all the class boilerplate
Report · Quote
Anonymous · reply · 2026-07-11 15:14:06
>>25360
>Is there an alternative to luafilesystem? I'm not using it simply because it pollutes the global namespace.
Does it set a bunch of globals or something?
Report · Quote
Anonymous · reply · 2026-07-11 15:21:30
>>25362
>Does it set a bunch of globals or something?
It registers the module globally as lfs when require'd. Years ago this also used to break lua_ls, no idea if that is the case anymore.
It won't be fixed because there's probably lots of software that depend on that behavior.
Report · Quote
Anonymous · reply · 2026-07-11 15:24:25
>>25358
>function Object:proto()
> return rawget(self, "__proto")
>end
Does this actually work? There is no self reference anywhere.
I'm too used to just creating closure based classes, even tho it's heavier on memory (if you dont use references to functions instead of creating a new function every time you instance a class)
Report · Quote
Anonymous · reply · 2026-07-11 15:27:32
lisp lost, therefore nothing else matters besides python + optimized c/asm functions
Report · Quote
Anonymous · reply · 2026-07-11 15:28:30
>>25364
NTA but it's gay syntactic sugar, if you define a function with the colon syntax after the function keyword like
>function foo:bar() end
It automatically implies a first parameter called self.
Report · Quote
Anonymous · reply · 2026-07-11 15:29:14
>>25364
It works because Object:proto() is sugar for Object.proto(self) (note the : vs .)
Report · Quote
Anonymous · reply · 2026-07-11 15:35:56
>>25366
>>25367
Oh, i see. Usually I do this
function f(s)
end
local a = {}
a.f = f
a:f()
instead of
local a = {}
function a:f()
end
a:f()
I thought it only added the table as the first parameter during "using" and not during "writing".
Report · Quote
Anonymous · reply · 2026-07-11 15:40:40
>>25359
That's actually the "opposite" of the prototype OOP object model (classless objects) inplemened in languages like self, Io and original JavaScript
Tables are just flexible enough to be able to reimplement the "inheritance by delegation" model
https://bibliography.selflanguage.org/_static/organizing-programs.pdf
Report · Quote
Anonymous · reply · 2026-07-11 15:44:12
>>25369
That's just how Lua tables work already without any extra work doe.
Same with JavaScript objects
Report · Quote
Anonymous · reply · 2026-07-11 15:53:30
this is how i do classes btw desu not sure if matters thoughbeit
local function class()
local a = {}
a.type = "class"
return a
end
local function Animal()
local a = class()
a.type = "animal"
a.eat = function(food)
end
return a
end
local function Canine()
local a = Animal()
a.type = "canine"
a.bark = function()
print(a.type, "barks")
end
return a
end
local meow = function(s)
print(s.type, "meows")
end
local function Feline()
local a = Animal()
a.type = "feline"
a.meow = meow -- you must use here : but it will use less memory
return a
end
Report · Quote
Anonymous · reply · 2026-07-11 15:59:51
>>25285
For a few weeks I ran the AwesomeWM window manager. It uses Lua instead of a configuration syntax. It was really annoying to work with. I remember needing to set a variable and it was ignored. Finally I set the variable to the value I wanted twenty times within the Lua script in order to get it to work.
So, yeah, I think Lua is a bad idea.
If you want a tiny language inside of your program, why not BASIC or Forth?
Report · Quote
Anonymous · reply · 2026-07-11 16:05:21
>>25370
>That's just how Lua tables work already without any extra work doe.
Tables are more general than that, that's why you write a library to "restrict" to a specific protocol
To implement the Object, the Lobby and multiple inheritance you want to write down the object model to avoid repeating every time the same code for any object
> Same with JavaScript objects
That's not a coincidence, js is heavily inspired by Self.
Its VM was the first dynamically typed object-oriented VM to achieve performances almost on par of optimized C++ for many workloads, and many techniques that later became standard in modern language runtimes:
> Adaptive compilation
> Inline caches (building on earlier work in Smalltalk)
> Polymorphic Inline Caches (PICs)
> Type feedback
> Dynamic recompilation
Then Js later introduces classes as syntactic sugar but still with prototypes under the hood
The problem is that
- Self is "dead-ish" (not really dead but being live image-based env l don't see it making a comeback)
- Io is still developed but too niche and tarteg wasm by default
- js ecosystem is too web-centric
Lua is a nice modern compromise because it's almost like those languages although more general
Report · Quote
Anonymous · reply · 2026-07-11 16:26:01
>>25361
yes, the object library basically does that
But I rather have to type
UDPconnectionTrait = Conncection:clone {
-- overwrite functions
}
UDPConnection = UDPConnectionTrait:clone {
transport_proto = "udp",
-- representations parameters
}
rather than setting every time the metatables by hand
Report · Quote
Anonymous · reply · 2026-07-11 21:35:04
>>25315
Problem?
Report · Quote
Anonymous · reply · 2026-07-11 21:37:18
>>25285
>array index starts from 1
HAHHAHAHAHHAHAHAH
Report · Quote
Anonymous · reply · 2026-07-11 22:25:10
>>25376
> Using a number from indians
Nice try Rajesh
Report · Quote
Anonymous · reply · 2026-07-11 22:26:10
>>25285
Ask yourself why lua torch lost to pytorch
Report · Quote
Anonymous · reply · 2026-07-12 00:40:09
>>25378
There is no correlation between Lua and machine learning
Report · Quote
Anonymous · reply · 2026-07-12 01:28:25
>>25354
not looking forward for new incompatible syntax.
in particular, ternary operator reusing : is a terrible idea. consider:
value = myobj ? myobj:func() : otherfunc()
oops, now value is either myobj or func():otherfunc()
Report · Quote
Anonymous · reply · 2026-07-12 02:25:49
>>25354
>const
HECK YES
time to mog jeetscript
Report · Quote
Anonymous · reply · 2026-07-12 02:37:12
>>25381
PUC Lua already has const doe
Report · Quote
Anonymous · reply · 2026-07-12 04:51:49
>>25380
>Due to a syntactical ambiguity, expression b cannot directly contain a method call obj:method(). For this case, use parentheses: cond ? (obj:method()) : default
>That said, nope, ?: stays. I'll confess: I'm a heavy user. Addicted, even.
Report · Quote
Anonymous · reply · 2026-07-12 04:53:17
>>25382
In the most retarded way possible
local why <const> = "just why";
Report · Quote