News for hackers. Stuff that matters.
Re:Using Lua as a Serialization Format by ReactiveJelly on Wednesday June 17, 2020 @09:51PM (#23558961)
I tried this on 1 or 2 small projects, years ago.

It was okay. It's cool that you can import data directly into Lua scripts, since Lua usually has poor library support for any other data format.

But I hit a wall with a limit on the number of tables in a file or something, that was specific to the Lua impl I was using. (Probably LuaJIT)

Sometimes I miss Lua. I think with only a few big breaking changes it could be a much better language.

Re:Using Lua as a Serialization Format by scruple on Wednesday June 17, 2020 @10:40PM (#23559266)
I used Lua as a data exchange format for some embedded devices (software defined radios) because it played nicely with the C code and the Lua scripts we would run on the device (which served as a sort of interface bridge between hardware device drivers). The Lua binary can be compiled down to < 100kB and the language itself is fast enough for a scripting language to have been useful in this context (I don't know if that still holds today, I left embedded in 2014).

It was a really pleasant experience but we were not working with a very large number of tables. I miss Lua all of the time, too, and play around with it whenever the opportunity arises. It holds a really special place in my programmer heart, alongside lisp, C, and Ruby, for having shown me some really interesting things at the right time in my career. It's too bad it doesn't have more widespread adoption, I think a lot of people could benefit from using it for the things it's good at.

Re:Using Lua as a Serialization Format by rstupek on Wednesday June 17, 2020 @11:05PM (#23559393)
There are a number of places it's being used today. There's an nginx module with an entire web front end development environment (openresty), Cloudflare uses the nginx lua module heavily, you can develop cross platorm (ios, android, web) games in Solar2D.
Re:Using Lua as a Serialization Format by duskwuff on Thursday June 18, 2020 @03:36AM (#23560705)
The NodeMCU[1] environment for ESP8266/ESP32 microcontrollers is pretty neat too -- it targets a $2 microcontroller with wireless network access (and Bluetooth in ESP32), with builtin functions to make HTTP requests and interact with external devices.

[1]: https://www.nodemcu.com/

Re:Using Lua as a Serialization Format by scruple on Wednesday June 17, 2020 @11:17PM (#23559455)
I'm aware, but I've never seen a shop I've consulted for or any of my employers use it. I've tried to get it in use a few times and ultimately it went no where because I would be the only programmer in a department with > 100 FTEs who would be able to work on it or maintain it unless some others took the time to learn it. It's been a non-starter as a result.

When I ask around, I don't hear about it in use locally (edit: that's actually not entirely true, Blizzard uses it and maybe some of the other local game shops, but I don't see it anywhere else locally). I met someone at a conference a year or two back who was using Kong. That's been it. Maybe I'm just missing it but I don't really see widespread use.

Re:Using Lua as a Serialization Format by vvanders on Wednesday June 17, 2020 @11:44PM (#23559609)
It never really saw adoption outside of games from what I've seen.

Its such a simple but powerful language, has one of the best interop apis with C and I love how they approached coroutines.

It's really a shame it doesn't see wider use. We used it to ship all our game logic on the PSP, 400kb prealloc block and it worked like a charm.

Re:Using Lua as a Serialization Format by zwirbl on Thursday June 18, 2020 @02:06AM (#23560228)
It's used in CHDK, the Canon custom Firmware Project for user definable scripts https://chdk.fandom.com/wiki/CHDK Besides this I've rarely encountered Lua in the wild

Edit: And of course in Magic Lantern, for Canon EOS DSLRs https://magiclantern.fm/

Re:Using Lua as a Serialization Format by dividuum on Thursday June 18, 2020 @10:26AM (#23563386)
I built a digital signage solution for the Raspberry Pi based on Lua (https://info-beamer.com) which turned into a company. API documentation is on https://info-beamer.com/doc/info-beamer, while most source code for what's running on the screens can be found on https://github.com/info-beamer/. Couldn't have done it without Lua.
Re:Using Lua as a Serialization Format by zimpenfish on Thursday June 18, 2020 @10:33AM (#23563448)
Kong[1] is basically a bunch of Lua scripts on top of OpenResty.

Redis[2] lets you write internal scripts in Lua.

Edit: Forgot Torch[3] which is great for generating nonsense with RNNs.

I think it's definitely getting more of a foothold in the world outside of games.

[1] https://konghq.com [2] https://redis.io/commands/eval [3] http://torch.ch

Re:Using Lua as a Serialization Format by lactobacillis on Thursday June 18, 2020 @03:18AM (#23560600)
The are a few lua lapis users out there: https://leafo.net/lapis/
Re:Using Lua as a Serialization Format by jddj on Thursday June 18, 2020 @06:57AM (#23561875)
I'd used lua in my early teens to script some games and ended up receiving money for my efforts, so I put it on my resume coming out of university.

It turned out that one of the first companies (embedded, automation) I interviewed with used it for integration between various third party subsystems. I think those conversations helped me feel like less of an imposter at the time.

I never use it anymore, but the language is nice. I wonder what web development world we'd live in now if they'd embedded lua instead of creating JavaScript.

Re:Using Lua as a Serialization Format by adwn on Thursday June 18, 2020 @03:12AM (#23560570)
> It's too bad it doesn't have more widespread adoption, I think a lot of people could benefit from using it for the things it's good at.

I think that's because there aren't many things it's really good at. It excells at a niche – as a light-weight, easily embeddable scripting language – but is mediocre as a general-purpose programming language, because it's standard library is extremely spartan and lacks so many things you need on a day-to-day basis.

Re:Using Lua as a Serialization Format by jmiskovic on Thursday June 18, 2020 @03:51AM (#23560794)
I disagree, there are many things it is great at.

The language is well designed, with orthogonal features that complement each other. Coroutines and meta-tables are easy to understand and still powerful way to organize and control code base.

You can actually learn it in a week, and hold all of the language in your head. A very valuable thing in my opinion. The code is very readable to beginners (unlike Perl, Haskell or APL).

The interpreter is incredibly fast. Even non-JIT implementation is surprisingly fast.

The LuaJIT FFI is so convenient that the difference between C/C++ libraries and Lua libraries almost disappear.

There are cross-platform hosting frameworks that allow you to write and execute dynamic interpreted code on otherwise locked down platforms (Android, Switch, TVs...).

I would say Lua lacks tooling and better organization of community. Biggest Lua communities were built around products that embed Lua like WoW, Roblox, Corona (now Solar2D).

Re:Using Lua as a Serialization Format by spc476 on Thursday June 18, 2020 @05:35AM (#23561421)
I use Lua at work to process incoming SIP messages (using LPEG [1]). It's handling million of calls per day without issue.

[1] Lua Parsing Expression Grammar http://www.inf.puc-rio.br/~roberto/lpeg/

Re:Using Lua as a Serialization Format by ejflick on Wednesday June 17, 2020 @10:22PM (#23559158)
Would you mind iterating on how it could be improved and how these changes relate to the context in which you've worked?

I've used it a bit for simple game development(Love2D). It's an okay language but it seems only suitable for building anything beyond small systems. No good IDE support and needing to emulate OOP was a bit annoying to me.

Re:Using Lua as a Serialization Format by legends2k on Wednesday June 17, 2020 @10:51PM (#23559323)
Try ZeroBrane, a pretty good IDE for Lua with debugger.

As for object-orientation it takes Go or Rust-like approach where there isn't an explicit class construct but conventions; you can build your own or use libraries to get there. In fact Rust or Go are younger so Lua should be appreciated for doing this a lot earlier. Having rigid object-oriented-ness will generally make the language less usable with other paradigms like functional, imperative, generic, etc.

Re:Using Lua as a Serialization Format by corysama on Wednesday June 17, 2020 @11:16PM (#23559451)
OO in Lua is the same as OO in classic JavaScript, just slightly more manual. In fact, in lots of ways Lua can be viewed as a cleaned up, simplified JS.
Re:Using Lua as a Serialization Format by shakna on Wednesday June 17, 2020 @11:18PM (#23559468)
I often use a mix of moonscript [0] and Lua, because the Lua that moonscript generates for classes takes away a heap of the overhead when dealing with a whole heap of stateful things that you expect to run across for game dev.

[0] https://moonscript.org/

Re:Using Lua as a Serialization Format by ufo on Wednesday June 17, 2020 @11:41PM (#23559595)
You might have run into the problem of LuaJIT only allowing 2^16 constants per function.

http://lua-users.org/lists/lua-l/2010-03/msg00238.html

Re:Using Lua as a Serialization Format by anonymoushn on Wednesday June 17, 2020 @10:47PM (#23559298)
What breaking changes would you like? I have a big collection of desired breaking changes that I plan to actually implement sometime, but I'll try not to bias your reply by listing them :)
Re:Using Lua as a Serialization Format by sillysaurusx on Thursday June 18, 2020 @02:34AM (#23560377)
Ah, I know exactly what limit you're talking about. I ran into it too.

You can't have more than N local variables, I believe. The problem goes away if you put them into a top-level table.