Remix.run Logo
saghm 5 hours ago

OT, but I learned Lua this year in order to be able to write a mod for a game, and maybe this is due to it being a while since I last used a dynamic language regularly, but Lua really feels like it's basically what JavaScript was intended to be. Both use a map-like data structure for basically everything, with integer keys to make them act like arrays, function values to make them act as objects, but Lua using an explicit function call in `for ... in` loops avoided needing a separate construct to be added later on for iterating over arrays in order (or having to resort to manually iterating over the numbers rather than the array itself). Lua's module system reminds me a lot of how Node's `exports` works (although nowadays I understand there are other ways of importing/exporting stuff in JavaScript), and it's not obvious to me that the power of prototypes in JavaScript are worth the extra complexity over using the module system for the pre-ES6 model of OO that JavaScript used. I feel like Lua basically already has solved most of the stuff that JS has needed to add a lot of new features for in recent years. I imagine this is something that a lot of people were already aware of, but at least personally, even being cognizant of the flaws that JS had been trying to fix, I hadn't realized an already well-established language had a design that solved most of them without also having a lot of additional scope beyond what JS was trying to do (e.g. Python having full-fledged class-based OO) or at least superficially looking a lot different (e.g. some form of lisp, which I know had been at least talked about in the early web days as a potential option but might have faced more of an uphill battle for adoption).