Stream: beginners

Topic: Lua Garbage Collection


view this post on Zulip ShalokShalom (Aug 28 2023 at 21:23):

You write on your homepage: Like Lua, Roc's automatic memory management doesn't require a virtual machine.

How do you mean that? Lua has a traditional GC, and as far as I know, does it need a VM?

view this post on Zulip Brendan Hansknecht (Aug 28 2023 at 23:21):

From Wikipedia:

Lua programs are not interpreted directly from the textual Lua file, but are compiled into bytecode, which is then run on the Lua virtual machine.

So probably our site is wrong?

view this post on Zulip Richard Feldman (Aug 28 2023 at 23:26):

oh, I guess so! I always thought Lua didn't have a VM :embarrassed:

view this post on Zulip Richard Feldman (Aug 28 2023 at 23:26):

what example could we use there instead? :thinking:

view this post on Zulip Folkert de Vries (Aug 29 2023 at 00:05):

swift?

view this post on Zulip Folkert de Vries (Aug 29 2023 at 00:05):

is the most high-level compiled (to machine code) language I can think of

view this post on Zulip Brian Carroll (Aug 29 2023 at 17:15):

Go also compiles to machine code and has memory management.

view this post on Zulip Richard Feldman (Aug 29 2023 at 18:23):

yeah I was trying to think of something that people use for "embedding" (like Lua), but maybe there aren't good examples of that :sweat_smile:

view this post on Zulip Brendan Hansknecht (Aug 29 2023 at 18:27):

So you want embedded and refcounting essentially. Cause GC means VM or interpreter generally speaking (or runtime hooks I guess cause that is what go does, right?).

view this post on Zulip Richard Feldman (Aug 29 2023 at 18:30):

I guess Go has neither, but it's not really used for embedding (I think maybe because of C ABI and/or maybe it's not a good fit due to being oriented around the use case of servers?)

view this post on Zulip Brendan Hansknecht (Aug 29 2023 at 18:31):

It has really bad cffi that often is really slow

view this post on Zulip Brendan Hansknecht (Aug 29 2023 at 18:31):

Gotten better over the years, but historically really bad

view this post on Zulip Brendan Hansknecht (Aug 29 2023 at 18:32):

But yeah, swift is closest if you ignore the embedding part. Go probably next closest. But neither really good examples

view this post on Zulip Brendan Hansknecht (Aug 29 2023 at 18:32):

May need to split the example in two. Mention Lua and Swift or something

view this post on Zulip ShalokShalom (Sep 11 2023 at 19:25):

Nim, Vale, Odin, there are a bunch of languages.

view this post on Zulip ShalokShalom (Sep 11 2023 at 19:28):

Richard Feldman said:

oh, I guess so! I always thought Lua didn't have a VM :embarrassed:

I think, because there is LuaJIT, and you confused the original Lua because its different from LuaJIT.
Thats at least, how I make such mistakes :sweat_smile:

view this post on Zulip ShalokShalom (Sep 11 2023 at 19:30):

The text on the homepage still says Lua has no VM:
https://www.roc-lang.org/

I can make a PR, to change this.

view this post on Zulip ShalokShalom (Sep 11 2023 at 19:46):

Just had a chat with the Nim guys.
They basically use a VM for compile time evaluation, but dont bake it into the runtime.

view this post on Zulip Brendan Hansknecht (Sep 11 2023 at 19:48):

LuaJIT is still a VM...though VM is a very general term

view this post on Zulip Brendan Hansknecht (Sep 11 2023 at 19:48):

from https://luajit.org/luajit.html:

For LuaJIT 2.0, the whole VM has been rewritten from the ground up and relentlessly optimized for performance. It combines a high-speed interpreter, written in assembler, with a state-of-the-art JIT compiler.

view this post on Zulip Brendan Hansknecht (Sep 11 2023 at 19:54):

Also, maybe not super useful here, but happened upon this really good read on the luaJIT VM. All linked to from here: https://0xbigshaq.github.io/2022/08/22/lua-jit-intro/

Definitely a classic VM like JS.


Last updated: Jul 05 2025 at 12:14 UTC