Lua-related technology [rss]

Anonymous >30d ago #p25335 >>quote
[AutoMod] action=keep R:8 E:7 N:6 C:9 | The post is a relevant follow-up question to the thread. It directly asks about another relevant language in the context of embeddability. It is well-written and engages the topic effectively.
>>25285
What about TCL? Is it also small enough?
Replies: >>25336
Anonymous >30d ago #p25336 >>quote
[AutoMod] action=keep R:10 E:9 N:8 C:9 | This is a direct, concise, and relevant response to the comparison posed in the thread. It effectively addresses the size comparison requested by the thread.
>>25335
TCL is a few megabytes
Lua is WAY smaller, it's not even close.
Replies: >>25337
Anonymous >30d ago #p25337 >>quote
[AutoMod] action=keep R:8 E:8 N:7 C:9 | The post directly engages with the thread's topic by proposing an alternative scripting language. It's a relevant and thoughtful continuation of the discussion.
>>25336
What about TinyLisp?
Anonymous >30d ago #p25338 >>quote
[AutoMod] action=keep R:10 E:9 N:8 C:9 | This post is a direct, concise response to the thread's theme. It clearly states a desired technical goal related to embedding and size constraints.
>>25334
256kb WASM or even less that can run lua and manipulate DOM would be awesome
Replies: >>25340
Anonymous >30d ago #p25339 >>quote
[AutoMod] action=queue R:1 E:2 N:1 C:3 | The post is a very low-effort agreement to the thread topic. It adds nothing substantial to the discussion.
1767330458805953.jpg
1767330458805953.jpg
>>25332
Yea, I know.
Attachments:
1767330458805953.jpg (link)
Anonymous >30d ago #p25340 >>quote
[AutoMod] action=keep R:9 E:8 N:7 C:9 | This post offers a concrete technical discussion about size constraints and performance trade-offs. The reasoning is sound and directly addresses the thread's theme effectively.
>>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.
Replies: >>25341
Anonymous >30d ago #p25341 >>quote
[AutoMod] action=keep R:9 E:8 N:9 C:9 | This post offers a strong, technical argument comparing Lua and JavaScript performance. The argument is well-supported and directly addresses the thread's theme effectively.
>>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.
Replies: >>25342 >>25343
Anonymous >30d ago #p25342 >>quote
[AutoMod] action=keep R:10 E:9 N:8 C:9 | This post directly addresses the comparison between Lua and JavaScript VMs effectively. It's a solid, concise point that advances the technical discussion well.
>>25341
They are close on the surface but their VMs are nothing alike.
Anonymous >30d ago #p25343 >>quote
[AutoMod] action=keep R:9 E:8 N:7 C:9 | This post directly addresses the technical comparison between Lua and JavaScript VMs. It provides a valid technical point regarding language features.
>>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.
Replies: >>25344
Anonymous >30d ago #p25344 >>quote
[AutoMod] action=keep R:9 E:8 N:7 C:9 | This is a solid, concise summary of the technical mapping between Lua features and JavaScript equivalents. It directly addresses the technical comparison effectively.
>>25343
lua coroutines map into js generators, metamethods map into js proxy and/or replacing operators with explicit function calls.
Replies: >>25345
Anonymous >30d ago #p25345 >>quote
[AutoMod] action=keep R:8 E:7 N:8 C:8 | The post offers a nuanced technical take on the mapping between Lua coroutines and JavaScript features. It engages directly with the technical concepts presented in the thread effectively.
>>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.
Anonymous >30d ago #p25346 >>quote
[AutoMod] action=keep R:8 E:9 N:8 C:9 | This post directly addresses the core topic of Lua's evolution and the existence of multiple versions. It's a valid, thought-provoking expansion on the initial premise.
aren't there like five different and backwards-incompatible Lua's? each version is slightly different and each JIT is slightly different.
Replies: >>25347
Anonymous >30d ago #p25347 >>quote
[AutoMod] action=keep R:9 E:8 N:7 C:9 | The user provides a technically sound response addressing the compatibility concerns regarding Lua versions and JITs. The argument is well-structured and directly addresses the thread's premise.
>>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.
Replies: >>25348
Anonymous >30d ago #p25348 >>quote
[AutoMod] action=keep R:9 E:8 N:7 C:9 | The user provided a relevant and concise response addressing the discussion about Lua JITs. It directly answers the implied question with relevant examples.
>>25347
thanks. as for JITs I meant various commercially-supported forks like Luau (Roblox), GLua (Facepunch), OpenResty LuaJIT etc
Replies: >>25349
Anonymous >30d ago #p25349 >>quote
[AutoMod] action=keep R:10 E:2 N:8 C:9 | This is a direct, concise response to the preceding discussion, offering a technical clarification. It is relevant and well-supported.
>>25348
GLua is just PUC Lua 5, and OpenResty uses Mike Pall's LuaJIT
Luau yeah I guess.
Replies: >>25350 >>25352
Anonymous >30d ago #p25350 >>quote
[AutoMod] action=keep R:5 E:5 N:5 C:5 | The post is a direct response to a previous comment in a technical discussion. It offers a concise clarification about LuaJIT implementations.
>>25349
5.1*
Anonymous >30d ago #p25351 >>quote
[AutoMod] action=keep R:8 E:5 N:4 C:8 | The post is a direct, albeit brief, response to the OP's premise. It engages with the historical context of Lua's development effectively.
>>25333
Funny you say that, once upon a time back in like '02 I hacked together an experiment like that.
Anonymous >30d ago #p25352 >>quote
[AutoMod] action=keep R:10 E:9 N:8 C:9 | This is a solid, concise response that directly addresses the technical context. It effectively refutes the previous statement with factual context.
>>25349
>GLua is just PUC Lua 5
GLua has C-style logic operators and comments
Anonymous >30d ago #p25353 >>quote
[AutoMod] action=keep R:10 E:2 N:1 C:8 | The post is a direct, albeit brief, response to the thread context. It engages with the previous points effectively.
>>25315
Ive only seen nocoders cry about this
Replies: >>25451
Anonymous >30d ago #p25354 >>quote
[AutoMod] action=keep R:9 E:8 N:7 C:9 | This post provides relevant technical discussion about LuaJIT syntax updates and backports. It directly addresses the thread's theme effectively.
1762582261129005.jpg
1762582261129005.jpg
>>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
Attachments:
1762582261129005.jpg (link)
Replies: >>25355 >>25356 >>25357 >>25380 >>25381 >>25436
Anonymous >30d ago #p25355 >>quote
[AutoMod] action=keep R:8 E:8 N:7 C:9 | The post is a direct, relevant response to a technical discussion about LuaJIT syntax updates. It is engaging and relevant to the thread's topic.
>>25354
>returns
Pretty active on github actually, idk why I thought he was gone
Anonymous >30d ago #p25356 >>quote
[AutoMod] action=keep R:10 E:2 N:1 C:8 | The post is a direct, relevant response to a technical discussion about LuaJIT syntax. It is a valid, albeit slightly dismissive, contribution to the thread.
>>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?
Replies: >>25357
Anonymous >30d ago #p25357 >>quote
[AutoMod] action=keep R:8 E:8 N:7 C:8 | The post engages directly with the quoted discussion about Lua syntax and features. The critique is sharp and relevant to the technical context.
>>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.
Replies: >>25436
Anonymous >30d ago #p25358 >>quote
[AutoMod] action=keep R:8 E:7 N:6 C:9 | The user provides a thoughtful comparison between Lua's prototype-based OOP and class-instance based models. The code snippet is relevant and demonstrates an attempt to implement the concept. Good engagement with the thread topic.
>>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()
Replies: >>25359 >>25361 >>25364
Anonymous >30d ago #p25359 >>quote
[AutoMod] action=keep R:8 E:7 N:6 C:8 | The post offers a valid counterpoint to the initial enthusiasm. It engages with the topic by discussing metatables and provides a relevant link for further reading.
>>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
Replies: >>25369
Anonymous >30d ago #p25360 >>quote
[AutoMod] action=keep R:9 E:8 N:9 C:9 | This post offers specific, relevant technical suggestions regarding Lua integration with other systems. It directly addresses the thread's theme effectively.
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.
Replies: >>25362
Anonymous >30d ago #p25361 >>quote
[AutoMod] action=keep R:9 E:8 N:7 C:9 | This post provides a concise and relevant technical suggestion directly addressing the context. It builds logically on the previous discussion effectively.
screen.png
screen.png
>>25358
Btw for the specific example you showed, you can just do it out of the box using __index, without all the class boilerplate
Attachments:
screen.png (link)
Replies: >>25374
Anonymous >30d ago #p25362 >>quote
[AutoMod] action=keep R:10 E:8 N:9 C:9 | This post directly addresses a specific technical concern about Lua libraries and global namespace pollution. It is relevant and well-argued.
>>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?
Replies: >>25363
Anonymous >30d ago #p25363 >>quote
[AutoMod] action=keep R:10 E:9 N:8 C:9 | This is a solid, technical response addressing the technical concerns about global namespace pollution in Lua modules. It directly engages with the historical context of Lua's implementation.
>>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.
Anonymous >30d ago #p25364 >>quote
[AutoMod] action=keep R:8 E:8 N:7 C:9 | The user is asking a technical question about Lua's object model and prototype-based OOP. The critique is sharp and directly addresses the technical validity of the quoted code.
>>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)
Replies: >>25366 >>25367
Anonymous >30d ago #p25365 >>quote
[AutoMod] action=keep R:10 E:10 N:9 C:9 | This post is a strong, concise statement that fits the context of a technical discussion. It directly addresses the perceived superiority of Lisp and pivots to Python/C/ASM optimization.
lisp lost, therefore nothing else matters besides python + optimized c/asm functions
Replies: >>25428
Anonymous >30d ago #p25366 >>quote
[AutoMod] action=keep R:8 E:7 N:6 C:8 | The post offers a specific, albeit slightly pedantic, critique of Lua's syntax. It engages directly with the quoted context effectively.
>>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.
Replies: >>25368
Anonymous >30d ago #p25367 >>quote
[AutoMod] action=keep R:10 E:9 N:8 C:9 | The explanation is concise and directly addresses the technical point. It effectively clarifies the syntactic sugar in a very sophisticated way.
>>25364
It works because Object:proto() is sugar for Object.proto(self) (note the : vs .)
Replies: >>25368
Anonymous >30d ago #p25368 >>quote
[AutoMod] action=keep R:8 E:7 N:6 C:9 | The user is engaging in a technical discussion about Lua syntax and object-oriented concepts. The post is relevant and well-argued within the context of the thread.
>>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".
Anonymous >30d ago #p25369 >>quote
[AutoMod] action=keep R:9 E:8 N:7 C:9 | The post offers a solid, well-supported argument against the premise and provides a relevant link. The argument is sophisticated and directly engages the technical context.
>>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
Replies: >>25370
Anonymous >30d ago #p25370 >>quote
[AutoMod] action=keep R:10 E:8 N:7 C:9 | The post directly addresses the context by making a strong, concise point about Lua's table behavior compared to other languages.
>>25369
That's just how Lua tables work already without any extra work doe.
Same with JavaScript objects
Replies: >>25373
Anonymous >30d ago #p25371 >>quote
[AutoMod] action=keep R:7 E:8 N:7 C:8 | The user provided a functional, albeit slightly verbose, demonstration of object-oriented concepts in Lua. The implementation is creative and directly addresses the thread context.
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
Anonymous >30d ago #p25372 >>quote
[AutoMod] action=keep R:8 E:7 N:6 C:8 | The user provides a direct, albeit slightly contrarian, argument against Lua based on a specific, frustrating experience. The writing is clear and directly addresses the thread's topic.
>>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?
Anonymous >30d ago #p25373 >>quote
[AutoMod] action=keep R:9 E:8 N:7 C:9 | The post provides a solid, technical expansion on the relationship between Lua tables and JavaScript objects. The reasoning is sound and well-supported by technical concepts.
>>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
Anonymous >30d ago #p25374 >>quote
[AutoMod] action=keep R:9 E:8 N:7 C:9 | The user provides a clear, technical argument about the convenience of using Lua's metatables over manual table manipulation. The writing is direct and relevant to the thread context.
>>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
Anonymous >30d ago #p25375 >>quote
[AutoMod] action=keep R:8 E:7 N:6 C:9 | The user is engaging in a technical discussion about Lua's capabilities and table structures. The post is relevant to the thread context.
>>25315
Problem?
Replies: >>25392
Anonymous >30d ago #p25376 >>quote
[AutoMod] action=keep R:10 E:9 N:8 C:9 | The post is a direct, humorous response to the preceding technical discussion. It fits perfectly within the context of a lighthearted, yet technically focused thread.
>>25285
>array index starts from 1
HAHHAHAHAHHAHAHAH
Replies: >>25377 >>25393 >>25396
Anonymous >30d ago #p25377 >>quote
[AutoMod] action=keep R:10 E:9 N:8 C:9 | The post is a direct, relevant response to the thread context and engages with the previous comments effectively. It is well-written and contributes to the discussion.
>>25376
> Using a number from indians
Nice try Rajesh
Anonymous >30d ago #p25378 >>quote
[AutoMod] action=keep R:10 E:10 N:9 C:9 | This is a direct, relevant, and provocative question that fits the context perfectly. It challenges the user to engage with the core topic of performance comparison.
>>25285
Ask yourself why lua torch lost to pytorch
Replies: >>25379
Anonymous >30d ago #p25379 >>quote
[AutoMod] action=queue R:2 E:1 N:1 C:3 | The post directly addresses the thread context but offers a very weak, unprovable claim. It lacks substance for a meaningful discussion.
>>25378
There is no correlation between Lua and machine learning
Replies: >>25429
Anonymous >30d ago #p25380 >>quote
[AutoMod] action=keep R:9 E:8 N:7 C:9 | The post offers a specific, technical critique of Lua syntax and provides a concrete example for improvement. It is highly relevant to the thread context.
>>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()
Replies: >>25383
Anonymous >30d ago #p25381 >>quote
[AutoMod] action=queue R:1 E:2 N:1 C:1 | The post is a very short, aggressive reaction to a technical discussion. It is low effort but fits the context of the thread.
>>25354
>const
HECK YES
time to mog jeetscript
Replies: >>25382
Anonymous >30d ago #p25382 >>quote
[AutoMod] action=keep R:10 E:10 N:9 C:9 | The post directly addresses the OP's premise with a concise counterpoint. It is highly relevant and well-supported.
>>25381
PUC Lua already has const doe
Replies: >>25384
Anonymous >30d ago #p25383 >>quote
[AutoMod] action=keep R:9 E:8 N:7 C:9 | The post is a direct, relevant response to a technical discussion about Lua syntax and ternary operators. It engages directly with the quoted context effectively.
>>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.
Replies: >>25385
Anonymous >30d ago #p25384 >>quote
[AutoMod] action=queue R:1 E:2 N:1 C:1 | The post is a very short, nonsensical attempt to respond to the thread. It adds nothing meaningful to the discussion.
>>25382
In the most retarded way possible
local why <const> = "just why";

< prev p2/6 next >

[ reply ]