12 ms·
I read his post less as Rust fanaticism and more someone who has learned their first programming language isn't perfect - strong types? iterators? These are all
by umvi 2y ago
I read his post less as Rust fanaticism and more someone who has learned their first programming language isn't perfect - strong types? iterators? These are all things that are present in many languages, it just sounds like Lua is lacking them and he is discovering some of the cool features of other languages.
- nmz 2y agoBut lua isn't lacking them, <for in do> is for generators, and if you want iterators you can make those as well.
- bmitc 2y agoDo you know if Lua supports type annotations or gradual typing? I use those heavily when using dynamically typed languages.
- QuaternionsBhop 2y agoNo, Lua does not, but check out Roblox's Luau which is a gradually typed extension of Lua.
- nmz 2y agoI'd recommend teal because luau is not really lua.
- nmz 2y agoIt does not. The most viable solution is transpilation, teal is the most recent candidate. You can have a hack of sorts using a schema and tables as in local schema = { a = "number", b="string" } -- key = "type" local data, link = {a=4, b="default value"}, {} -- link -> data, link itself is always empty local tbl = setmetatable(link, { __index = data , __newindex = function (t,k,v) if schema[k] and type(v)==schema[k] then data[k] = v return true end error"type does not match schema" end }) tbl.b = 5 -- this will error because its the wrong type There are certain solutions you can do with functions, lsp is also really good at telling you when you went wrong.