Live data from Hacker News

Lua 5.4.0 beta

lua-users.org

41–50 of 103 posts

Re: Lua 5.4.0 beta

#41

People that use lua, what do you use it for and why did you pick lua?

I use it as the scripting, and implementation, language for a console-based mail-client. (Think "mutt", but with real scripting instead of the ad-hoc support that mutt has.)

I use it because it's a simple language that is quick to code in, and trivial to embed inside a C, or C++, host application.

If I were to begin the project again I'd have no qualms about a similar approach. (Writing the core in C++ with a notion of display-modes, email-parsing, etc, and the actual control in Lua. The biggest painpoints were dealing with MIME, and similar broken emails which was largely irrelevant for the lua-side.)

Re: Lua 5.4.0 beta

#42

Earlier quoted context omitted.

> The documentation lacks for some topics of you use the c api. I'm surprised to hear this. I'm doing a lot of Lua and I always thought the documentation is very succinct and complete. I really curious when issues you ran into. > The thing is lua on embedded has no rival. but god did it cost me some nerves. You might take a look at https://bellard.org/quickjs/ and https://duktape.org/ . The latter seems oddly familia…

My info might be a bit out of date, but something that surprised me when I looked into it was how little control I had over the embedded lua interpreter from my outer app. I basically had to hand it control by calling lua_pcall, and either wait for a result or manage a timeout from another thread. I expected to be able to do things like tell Lua to run for X milliseconds or Y opcodes or whatever, but it didn't seem t…

Ah. Yeah applying resource limitations outside of memory usage is always a bit awkward. The only really supported way to my knowledge is to externally set a hook and trigger an error when called: https://github.com/lua/lua/blob/master/lua.c#L40-L59. I think this doesn't always work in tight loops though.

I remember patching Lua over 10 years ago for a programming game. I essentially counted VM instructions and stopped executing when reaching the limit. It survived malicious players on a hacker conference back then ;-)

The probably badly aged code is still available here: https://github.com/dividuum/infon/blob/c25eb749b17df3fd9b7a5...

Re: Lua 5.4.0 beta

#43

We use lua 5.3 on an embedded Platform for scripting and it has been a roller coaster ride. Not a fun one, unfortunately. You want luasocket? The stable one is not compatible with 5.3. Packages are sometimes outdated (for years no updates) and there is no replacement. The lua point releases have breaking changes. The source code itself is a macro hell which is hard to debug. And the code is not very readable. The doc…

I share some of your pain. We use Lua 5.1 on our embedded platform and at one point did development on 5.2.

There's a lot of (seemingly) undocumented changes, even between two minor versions that make you question the semver (and your sanity) at times.

For example, the patterns operate just different enough between the two minors, that I had to resort to dumping everything into JSON and back since that was the only way that one odd case worked similarly between the two versions (albeit sharing the same JSON library).

In regards to the new version, coworker of mine glanced at the 5.4 changelog and could not make out how things had changed, only the fact that they had been changed.

Re: Lua 5.4.0 beta

#45
post #39
post #7

Earlier quoted context omitted.

The performance difference is pretty stunning. https://luajit.org/performance_x86.html

That is comparing with 5.1.5, not 5.3 or 5.4 beta. (The default of comparing x86-32 also does not make sense to me, YMMV.)

I couldn't find a way to deep link to the x64 numbers, but they aren't significantly different.

Hopefully they update it with a more current Lua version.

Re: Lua 5.4.0 beta

#46
post #2

Main changes - new generational mode for garbage collection - to-be-closed variables - const variables - userdata can have multiple user values - new implementation for math.random - warning system - debug information about function arguments and returns - new semantics for the integer 'for' loop - optional 'init' argument to 'string.gmatch' - new functions 'lua_resetthread' and 'coroutine.close' - coersions string-t…

>- utf8 library accepts codepoints up to 2^31 Interesting. Didn't Unicode restrict UTF-8 to allow encoding only 21 bits? Does it mean that it can now do 6 byte UTF-8 encodings? What kind of restrictions did it have before?

Comparing the documentation seems to verify this easily:

- https://www.lua.org/manual/5.3/manual.html#6.5

- https://www.lua.org/work/doc/manual.html#6.5

Re: Lua 5.4.0 beta

#47
post #7

Earlier quoted context omitted.

The performance difference is pretty stunning. https://luajit.org/performance_x86.html

Indeed. Mike Pall blows them out of the water single-handedly. I wonder if Lua developers have learnt anything from him with respect to performance. I would like to see how Lua 5.4.0 would perform in comparison.

The Roblox team is making a new Lua interpreter (not JIT) from scratch with a focus on performance. Don’t think it’ll be open source though.

Re: Lua 5.4.0 beta

#48
I use Lua via OpenResty / lua-nginx-module and in personal C projects for plugins and scripting. Some of these seem useful, like utf8 support and const variables.

For the multiple user data values feature, I've always found lightuserdata more useful than userdata, because it's not often that you need just one bunch of simple memory that can be freed without any other work. Rather, I almost always have more complex data, such as things that need manual cleanup like sockets, handles, etc. Or, the structure has pointers to other things that must also be cleaned up. What I'd like instead is the ability to pass a destructor callback to `lua_pushlightuserdata` so that it get's called when the pointer falls off the stack.

I don't use Lua threads or coroutines currently, so I don't have much to add there. What I do wish is that there were a way to clone or pass objects from one lua state to another to support parallelism. Basically, I'm thinking of it like the work Eric Snow is doing on subinterpreters in Python. Passing values (by copying, no shared memory) between lua instances.

One use case I had is loading a plugin that you then want to run multiple instances of in parallel with different arguments. Ideally, you wouldn't have to load the plugin multiple times (therefore calling the module level code multiple times). So I'd like to copy the entire lua state and then run each one with different arguments. There's no userdata, coroutines, or lua threads, so I don't have to worry about things that aren't possible to copy.

I got as far as looking into how to copy functions and then got busy with other things and stopped. Is there anyone else out there trying to introspect Lua function structures and copy all the opcodes, upvalues, etc?

Re: Lua 5.4.0 beta

#49

People that use lua, what do you use it for and why did you pick lua?

It's the language used in my digital signage service for the Raspberry Pi (see https://info-beamer.com & https://info-beamer.com/doc/info-beamer). The main reason to choose Lua back when I started was the there were no serious alternatives for:

* Easy embedding. Compared to Python and ruby which I looked at back then, Lua is so much simpler.

* Fairly easy to learn for users. After all, the complete syntax is one page long: https://www.lua.org/manual/5.1/manual.html#8

* Quite expressive with coroutines, tail calls, metatables, ...

* Trivially allows multiple interpreter instances within the same program.

* More than fast enough, especially once LuaJIT was released.

Re: Lua 5.4.0 beta

#50

We use lua 5.3 on an embedded Platform for scripting and it has been a roller coaster ride. Not a fun one, unfortunately. You want luasocket? The stable one is not compatible with 5.3. Packages are sometimes outdated (for years no updates) and there is no replacement. The lua point releases have breaking changes. The source code itself is a macro hell which is hard to debug. And the code is not very readable. The doc…

I share some of your pain. We use Lua 5.1 on our embedded platform and at one point did development on 5.2. There's a lot of (seemingly) undocumented changes, even between two minor versions that make you question the semver (and your sanity) at times. For example, the patterns operate just different enough between the two minors, that I had to resort to dumping everything into JSON and back since that was the only w…

Lua does not follow semver (it never has, and has been around longer than semver)
Post reply on HN