| ▲ | Lua 5.5(lua.org) |
| 217 points by km a day ago | 64 comments |
| |
|
| ▲ | bsimpson 2 hours ago | parent | next [-] |
| I recently happened into Balatro through a Game Pass trial. I fell deep down the rabbit hole of trying to get it to run on SteamOS. It's fascinating to see a commercial game whose source is easily read inside the application bundle, and all the modding opportunities it opens up. (It's written in Lua with LÖVE.) Balatro was one of the biggest games of last year, and I'm sure the tinkerability was a big catalyst to that - people porting it to obscure platforms and making mods to extend the game. It's also really cool to see how the game handles all the different ecosystems it exists in (Steam, Game Pass, Apple App Store, Android, Nintendo Switch…). I've got a Nix derivation that ought to be able to run any version of the game in Linux. Now I just need to figure out why it crashes when opened in game mode. All this is way more effort than just spending the $10 to get it to run in Steam natively, but it's more interesting this way. |
| |
| ▲ | GaggiX 11 minutes ago | parent [-] | | I managed to run Balatro on a Trimui Brick on a very minimalist Linux distro, steamos should be easy. |
|
|
| ▲ | cturtle a day ago | parent | prev | next [-] |
| One of the new features I found interesting, declarations for global variables, is buried in the reference manual. Here's a link to the section that discusses it: https://www.lua.org/manual/5.5/manual.html#2.2 |
| |
| ▲ | HellsMaddy 2 hours ago | parent | next [-] | | Global-by-default scoping was one of Lua's largest mistakes. I wish they'd fix it, but of course it would break backwards compat. | |
| ▲ | rhelz 3 hours ago | parent | prev [-] | | Why did you find this interesting? | | |
| ▲ | kevin_thibedeau 15 minutes ago | parent | next [-] | | It indicates paving the path for local scoping in a future release where Lua 5 code is upgraded with global declarations to keep it working. | |
| ▲ | embedding-shape 3 hours ago | parent | prev [-] | | For me it's interesting because global variable declarations haven't been needed before, so why now? Also, I'm not sure `global` was reserved before, but now it seems to be. |
|
|
|
| ▲ | gucci-on-fleek 21 hours ago | parent | prev | next [-] |
| ConTeXt has been using beta versions Lua 5.5 for a few years now, so you can look through its source [0] or try running it [1] if you're curious what a large codebase written in Lua 5.5 looks like. [0]: https://codeberg.org/contextgarden/context [1]: https://wiki.contextgarden.net/Introduction/Installation |
|
| ▲ | klaussilveira 4 hours ago | parent | prev | next [-] |
| > declarations for global variables That's huge. I wish LuaJIT adopted this, or at least added a compile time flag to enable it. |
| |
| ▲ | shmerl 4 hours ago | parent [-] | | Yeah, I wish someone would pick up LuaJIT development. From what I've heard it in practice isn't developed anymore and is stuck at Lua 5.1 still. | | |
| ▲ | dividuum 4 hours ago | parent [-] | | Not true. It's getting a constant stream of bugfixes. It's also not "stuck" on Lua 5.1, but is deliberately not following Lua's path, except for some backports. There's also a recent post about how a LuaJIT 3 might work. | | |
| ▲ | shmerl 3 hours ago | parent [-] | | OK, then I got some wrong info. If it's stuck at it deliberately, then it's worse. May be someone should fork it and bring it up to date with recent Lua versions. Why is this split needed? | | |
| ▲ | ori_b 25 minutes ago | parent | next [-] | | > May be someone should fork it and bring it up to date with recent Lua versions. Why is this split needed? Good news, you're someone. If you care, you're welcome to go for it. | |
| ▲ | upofadown 3 hours ago | parent | prev [-] | | My understanding is that there was a language fork after 5.1. One thing was a complete reworking of how math works. It used to be just floating point for everything but the new idea was to make it like Python 3. So most operations are float/integer with some weird exceptions. As with any language fork there will be some who stay and others who switch to the new thing. Often a fork will drive people away from a particular language as in my case. | | |
| ▲ | ksymph 2 hours ago | parent | next [-] | | Lua's nature as a primarily embedded language means backwards compatibility is not guaranteed between any version. If 5.2 was a language fork then so was 5.3, 5.4, 5.5, etc. (5.2 did have some more significant changes though) For that reason luajit staying at ~5.1 actually works in its favor. Rather than trying to follow the moving target of the newest version, it gives a robust focal point for the lua ecosystem, while modern versions can be developed and continue to serve their purpose in embedded systems and whatnot where appropriate. | | |
| ▲ | shmerl an hour ago | parent [-] | | I don't see a reason not to update LuaJIT still. Changes in Lua aren't just version numbers, it should be improving something, meaning that would be missing in LuaJIT. | | |
| ▲ | ksymph 41 minutes ago | parent | next [-] | | LuaJIT does have some backported features from newer versions. But Mike Pall -- the mad genius behind LuaJIT -- has made it clear he doesn't agree with many of the changes made in newer versions, hence why it's staying where it's at. | |
| ▲ | electroglyph an hour ago | parent | prev [-] | | the beauty of open source is there's nothing stopping you! this might be your calling. best of luck |
|
| |
| ▲ | shmerl 2 hours ago | parent | prev [-] | | Language fork is unfortunate. Python situation isn't much of a fork really. Python 2 is basically EOL. | | |
|
|
|
|
|
|
| ▲ | Kerrick 5 hours ago | parent | prev | next [-] |
| We never got a new edition of Programming in Lua for 5.4... does that mean we won't ever get one for 5.5? |
| |
|
| ▲ | maxpert 5 hours ago | parent | prev | next [-] |
| I feel like Lua is absolutely underrated. I just wish one of the mainstream browsers actually puts their foot down and starts supporting Lua as scripting language. |
| |
| ▲ | inejge 4 hours ago | parent | next [-] | | > I feel like Lua is absolutely underrated. This sounds like an offhand Youtube comment, I'm afraid. Underrated how? Its principal strength, easy embedding with the ability to work as an extension language, is well known in the circles where it matters. The authors never gave an impression that they'd aim to make it a language to bury all other scripting languages, which I find refreshing in the winner-take-all culture of programming language discussion. Lua is modest and works well for what it is. No need to go all grandiose. > I just wish one of the mainstream browsers actually puts their foot down and starts supporting Lua as scripting language. I sincerely hope not, that would be a very counterproductive dilution of effort. Browser authors already have their plate full with all other web platform problems. | | |
| ▲ | bsimpson 2 hours ago | parent [-] | | That was originally what Dart was created for. Beside all the rabblerousing that it came from the same company as Chrome, there was a real concern about compatibility and spreading the platform too thin, if every engine had to maintain multiple VMs in parallel. It seems like the only language browsers will ever have is JavaScript (although it's still up to us to decide how that language evolves over time). |
| |
| ▲ | esrauch 4 hours ago | parent | prev | next [-] | | One of the super powers of Lua is that it doesn't need to be very stable: because you are always embedding an interpreter your code and interpreter have a matching version. That's directly contrary to what would make it acceptable as a web spec, compared to e.g. wasm being powerful enough to be a compile target that can support wasm. | |
| ▲ | tormeh 5 hours ago | parent | prev | next [-] | | Ypu could probably run it in wasm. Of course, without access to the DOM it won't go any further than anything else on wasm. The whole thing is nuts if you ask me. So much lost potential. | |
| ▲ | sellmesoap 4 hours ago | parent | prev | next [-] | | I think that's doable.
https://github.com/zacharie410/lua-browser-dom-demo | | | |
| ▲ | 1313ed01 5 hours ago | parent | prev | next [-] | | If they can lock it to some version to avoid breaking code every time there is a new Lua version. Or Lua stop making breaking changes. | |
| ▲ | klysm 5 hours ago | parent | prev | next [-] | | Curious how this fits in with WASM | |
| ▲ | irishcoffee 4 hours ago | parent | prev [-] | | Kind of feels like they would pick python before lua. |
|
|
| ▲ | parlortricks a day ago | parent | prev | next [-] |
| Excellent new release, now for Fennel and Love2d to update, fun times! |
| |
| ▲ | derstander 4 hours ago | parent [-] | | Only a dabbler in Love2d here but I’d expect that update to be a bit down the line. If I’m not mistaken the current Love2d version 11.5 is (mostly) tied to Lua 5.1 because of LuaJIT, though I understand some later Lua features are backported. And the changelog for the in-dev 12.0 release talks about compiling Love2d for Lua 5.4 as if it’s an optional thing. I don’t really follow LuaJIT too closely so I’m not sure if they’re even targeting Lua 5.4 let alone 5.5. I remember reading some GitHub issue that suggested some of the design decisions in Lua 5.4 wouldn’t really support LuaJIT goals re: performance. With that said I’ve been enjoying Love2d even with Lua 5.1 features — as a hobbyist it works just fine for me. Would certainly appreciate any corrections by those more in-the-know though! |
|
|
| ▲ | altairprime 5 hours ago | parent | prev | next [-] |
| List of changes: https://lua.org/manual/5.5/readme.html#changes |
|
| ▲ | ksymph 5 hours ago | parent | prev | next [-] |
| > for-loop variables are read only Seems like an odd change, I wonder what the rationale is. Just making it clear to people new to the language that you can't adjust it mid-loop to change the loop count I guess? |
| |
| ▲ | pvitz 4 hours ago | parent | next [-] | | From the manual: The control variable in for loops is read only. If you need to change it, declare a local variable with the same name in the loop body.
Also [0]:
Roberto Ierusalimschy
> So what's the rationale to make them constant now? Does it have performance
> reasons?Yes. The old code does an implicit "local x = x" for all loops, in case
you modify 'x'. With the new semantics, the code only does it when you
ask for it. [0] https://groups.google.com/g/lua-l/c/SlAG5QfpTac | |
| ▲ | ufo 4 hours ago | parent | prev | next [-] | | That was already the case in previous versions of Lua. You could assign to the loop variable but the assignment would be overwritten in the next loop iteration. https://www.lua.org/manual/5.3/manual.html#3.3.5 The loop count was fixed at the start of the loop. One of the reasons for this was performance. For loops behave differently if the step count is positive or negative, and it's a bit faster to compute that once, before the loop, than to repeat it every iteration. | |
| ▲ | GranPC 4 hours ago | parent | prev [-] | | In previous versions, you could change it mid-loop. This apparently caused some unintuitive behavior when paired with generators (e.g. `for k, v in pairs(table)`). I haven't run into this myself, but it does make sense, and eliminating this footgun sounds like a good idea. |
|
|
| ▲ | gsck a day ago | parent | prev | next [-] |
| Cannot wait for another version of Lua to sit unused basically everywhere. Truly is a shame, everything seems to have settled on 5.1 for the most part without ever being updated, or any intention of it being updated. Some really nice features post 5.1 I understand each version of Lua introduces breaking changes in the language, which isn't great as the language becomes fragmented (Or not really, once again 5.1 is pretty ubiquitous) |
| |
| ▲ | ronsor a day ago | parent | next [-] | | The real reason everyone settled on Lua 5.1 is because that's the version LuaJIT is compatible with, and most people are unwilling to give up the performance gains. | | | |
| ▲ | pull_my_finger a day ago | parent | prev | next [-] | | 5.1 (by way of LuaJIT) gets a lot of use, but to suggests no one uses the modern versions is just not true. Lua being an embedded language just takes the pressure away to upgrade. It's a feature, not a bug. | |
| ▲ | BugsJustFindMe a day ago | parent | prev [-] | | > everything seems to have settled on 5.1 Not exactly. LuaJIT has backported various hot features from 5.2 and 5.3 as long as they're unlikely to break 5.1 code. | | |
| ▲ | thayne 5 hours ago | parent | next [-] | | True. But 1. The luajit documentation basically just had a list of features. AFAIK there isn't any documentation that combines the 5.1 reference with luajit extensions (including things that were backported) 2. In some cases, for example Neovim, luajit extensions aren't guaranteed to be available. It just says there will be a lua runtime compatible with 5.1. Which means a truly portable neovim plugin can't use those extensions 3. There are features from later lua versions I would like to have (in particular <const> and <close>) that will probably never get backported. 4. Some features require luajit to be built with special flags | |
| ▲ | petcat 6 hours ago | parent | prev [-] | | I'm pretty sure that's only OpenResty's distribution of LuaJIT. I think the real LuaJIT is strictly 5.1 | | |
|
|
|
| ▲ | robofanatic 5 hours ago | parent | prev | next [-] |
| How hard is it to put a simple hello world example on the homepage. |
| |
| ▲ | BanazirGalbasi 4 hours ago | parent | next [-] | | Because Lua's Hello World is just `print("hello, world")`, which looks a lot like Python and doesn't tell you much about actually using the language. | | |
| ▲ | robofanatic 4 hours ago | parent [-] | | The point is, it shouldn’t be too hard just to find an example and get a sense of the language. | | |
| |
| ▲ | b33j0r 4 hours ago | parent | prev [-] | | Well. You’d have to demonstrate that a[1] is the first offset in an array, and it’s not a great curb appeal to anyone who has programmed computers before. | | |
| ▲ | pasquinelli 3 hours ago | parent [-] | | i think i might prefer indexing starting at zero, but it really isn't important. with c it makes total sense for zero-based indexing. frankly though, for lua, how it works and what an array is, it makes more sense for one-based indexing, the only counter-argument being that 1-based indexing puts off people who learned a thing one way and are unable or unwilling to do it a different way. to even include it on a list of considerations for not choosing lua is a bit silly, but to highlight array indexing and only that as the only thing you'd need to know... well i don't know how to put it that wouldn't be impolite. either way, at least you can't toggle between indexes starting at zero and one, (at least not that i can recall.) | | |
| ▲ | BanazirGalbasi 2 hours ago | parent [-] | | > either way, at least you can't toggle between indexes starting at zero and one You can, you just have to explicitly assign something to a[0]. Lua doesn't have real arrays, just tables. You have to do it for every table you use/define though, so if you mean "toggle" as in change the default behavior everywhere then I believe you are correct. |
|
|
|
|
| ▲ | mysterEFrank 4 hours ago | parent | prev | next [-] |
| OG torch strikes back? |
|
| ▲ | sunshine-o 17 hours ago | parent | prev | next [-] |
| I never coded in Lua but I found out recently that Lua is now in FreeBSD base [0]
This is huge for Lua and FreeBSD. Now something that worry me is whenever you need to make an HTTP request or parse some JSON you need to go on a quest for a "library" on the Internet. It doesn't seems to have a (semi-)official "Extended Standard Library" I can quickly trust. - [0] https://man.freebsd.org/cgi/man.cgi?query=flua&apropos=0&sek... |
| |
| ▲ | Fwirt 6 hours ago | parent [-] | | The Lua ecosystem is more like the Lisp ecosystem than Python. The language is small enough that there’s a lot of stuff out there that’s just… finished. Hasn’t been updated in 10 years but still works. The LunarModules org tries to gather it up and keep it compatible. For an extended standard lib, the closest thing is probably Penlight. https://github.com/lunarmodules/Penlight
If you want async IO, sockets, etc, check out Luvit.
https://luvit.io Lua is really designed as an extension language but it’s such a nifty little language that sometimes you really wish you could use it in place of Python or Perl, which is why LuaJIT is so popular. But LuaJIT is really just one guy’s project. Its metaprogramming features are really nice and let you build some Lisp-style DSLs, and if you want full Lisp syntax you can drop in Fennel. If you’re just writing extension code you often don’t need a standard lib because it’s easier just to roll your own function to fill the gap. Personally, I found it easier and quicker to just read the reference manual to learn the language. It’s small and simple enough that you shouldn’t have trouble getting up to speed if you have a couple other imperative languages under your belt. IMO metatables are much easier to work with than JavaScript’s prototype inheritance. |
|
|
| ▲ | andrewmcwatters a day ago | parent | prev | next [-] |
| Interesting, it looks like you can use ´global myvar’ now, as compared to ´myvar’ implicit globals, say from back in 5.1, or ´local myvar’. It’s worth noting that global is a reserved keyword now, so environments that had a ´global()´ function for escaping environments will now need to rename their helper function. |
| |
| ▲ | darubedarob 19 hours ago | parent [-] | | But.. why ? Globals are just variables that reside in the wrapping env table that also contain the C functions. If a closures is a onion of table lookups out of the function context from local -> function scope -> global scope is simply the last lookup before a not found variable with nil is declared? | | |
|
|
| ▲ | artemonster 5 hours ago | parent | prev [-] |
| please resurrect Mike Pall |
| |
| ▲ | thayne 5 hours ago | parent [-] | | Mike Pall made a commit to LuaJIT just a couple of weeks ago. |
|