4 ms·
Lua will be 30 this year
- phaedryx 4y agoLua is older than JavaScript and I want to believe, in an alternate universe, it supplanted it.
- hlship 4y agoHow did we manage to post that same observation almost simultaneously?
- LAC-Tech 4y agoThere's alot of similarities - weak dynamic typing, closures from day one, both came with mechanisms to do something like self-style prototype OO, only have a double for a numeric data type, both fairly small langs designed for "simple" scripting (though JS has grown).
- deleted 4y ago[deleted]
- phaedryx 4y agogreat minds... :)
- JonChesterfield 4y agoScheme would have been a wonderful choice for browser scripting too. Alas.
- hlship 4y agoImagine the state of the world if Brendan Eich had known about Lua and spent those nine days integrating that into Netscape. I believe it had a compatible license, even back in 1995.
- LAC-Tech 4y agoYeah imagine all the Lua transpiling we'd be doing.
- oweiler 4y agoLua actually has a bunch of transpilers, like Moonscript.
- chubot 4y agoThen it would probably be frozen in time as Lua 1.0 without all of the breaking improvements that have happened since then Lua is an embedded language and I think most users who want compatibility run or forked Lua 5.1, which is from 2006 It’s not clear to me that Lua in 1995 was better than JavaScript in 1995
- BrendanEich 4y agoGood answer. No coros, in particular. https://news.ycombinator.com/item?id=1905155 https://news.ycombinator.com/item?id=1905155
- liendolucas 4y agoAh, Lua... That programming language that still invites you to implement a split function a zillion ways and get it wrong: http://lua-users.org/wiki/SplitJoin http://lua-users.org/wiki/SplitJoin Found this out when I had to implement a snippet in nginx... Avoided at all costs since then.
- lifthrasiir 4y agoAh, lua-users.org... That wiki which pretty much looks like the comment section in the PHP manual but with a less chance to be correct for many reasons. And I'm not sure if there's other (preferably more trusted) source of snippets. Back in time when I messed with Lua [1], I needed a version of `pairs` that returns keys in the sorted order. Lua-users has a page for that [2], so I looked it up, and found that it has a subtle but important enough bug---it relies on `__orderedIndex` stored in the original table, which never gets updated nor GCed. I'm sure many enough people had been and will be tripped up by this snippet. [1] So much that I had written a type checker for Lua: https://github.com/devcat-studio/kailua/ https://github.com/devcat-studio/kailua/ [2] http://lua-users.org/wiki/SortedIteration http://lua-users.org/wiki/SortedIteration
- JonChesterfield 4y ago` t.__orderedIndex = nil` looks like it cleans up at the end of the iteration, am I missing something? Mutating a table while iterating over it is fairly hazardous anyway
- lifthrasiir 4y agoAh, yeah, the problem won't be visible with a normal loop. However if you break out of the loop without hitting the very last key, or remove a key during the iteration [1], or loop against the same table inside another loop, then the snippet will fail in unexpected ways. The correct way to do this is as follows. First you collect all keys and sort them as usual, and then return an iterator function that contains those keys as an upvalue. Essentially you need to create a single-use `pairs` function that holds all necessary states. [1] You can't insert a key during the iteration, but removing an existing key is guaranteed to work correctly, no matter if you've already past the deleted key or not: https://www.lua.org/manual/5.4/manual.html#pdf-next https://www.lua.org/manual/5.4/manual.html#pdf-next
- PicassoCTs 4y agoAnd it will supplant javascript, as all the kids starting to code today use it (robblox and minecraft) (https://create.roblox.com/docs/tutorials/scripting/basic-scripting/intro-to-scripting https://create.roblox.com/docs/tutorials/scripting/basic-scr... https://minecraftcomputercraft.fandom.com/wiki/Simple_Lua_(New) https://minecraftcomputercraft.fandom.com/wiki/Simple_Lua_(N...). Then again its just syntax..
- deleted 4y ago[deleted]
- ungravitomic 4y ago[dead]