15 ms·
Honestly Lua is one of those languages that seems decently nice to use, fairly performant, and just makes me wonder why it hasn't been adopted for use more broa
by amilios 4y ago
Honestly Lua is one of those languages that seems decently nice to use, fairly performant, and just makes me wonder why it hasn't been adopted for use more broadly in domains beyond just like being embedded in game engines. Am I missing something?
- spacechild1 4y agoLua has been designed as an embeddable scripting language and it is used as such in various domains and programs. It's not really suited for developing large applications, though.
- citrin_ru 4y agoYou can write largish standalone application in Lua and it is not always a poor choice - Prosody [1] first comes to mind. But qualities which make it a good embedded language make it less _attractive_ for other uses. Lua has very simple syntax and small stdlib which allows its implementation to be very small - you can add Lua to your application and not increase its size significantly. But when the size is not a concern most programmers prefer languages with rich, powerful syntax lots of features and batteries-included stdlib (which is completely opposite of Lua). [1] https://prosody.im/ https://prosody.im/
- orthoxerox 4y agoNo batteries included. It's designed to be embedded as a scripting language, so its stdlib is tiny. People managed to write web frameworks in Lua, but it's hard to snowball a good package collection when you've got Python and node next door.
- sam_lowry_ 4y agoIt is heavily used in some niche domains. Openresty comes to mind next to game dev. OTOH, it is too close to C and not really a breakthrough language like Rust or Go. As far as style and brevity goes, Lua wins hands-down, but who cares?
- aredox 4y agoIt's also used as the main scripting language in NeoVim. But if you want something more "out there", it's also the main language used to program open-source radio control remote (openTX) for drones/planes/gliders: https://medium.com/rc-soaring-digest/ive-got-the-power-opentx-871dade77895 https://medium.com/rc-soaring-digest/ive-got-the-power-opent... https://github.com/jfrickmann/SoarOTX https://github.com/jfrickmann/SoarOTX
- rahkiin 4y agoI’ve worked in a large Lua codebase, and its lack of any types gets very cumbersome. It is also non-trivial to get the full performance and by doing so lose some of the nicer features. For example, creating tables causes an allocation which is slow, so forget about using tables for vector types. These tables could have bad a metatype for operator overloading, but metatables cause multi-level lookups which is also slower. I could use it for some light scripting, but definitely would not write whole projects in it.
- spc476 4y agoAt work, I use Lua (and LPEG) to process SIP messages for the Oligarchic Cell Phone Company, processing calls in real time, and only once in the seven years it's been running did I have to tune the code. It certainly works for us.
- rahkiin 4y agoThat’s great :) I do think it has its place. We ran >200k lines of Lua for a 3d game at >60fps. We could not do allocations on the hotpath, or we would run out of our frame budget (which was around 1ms). Games are very hard to auto-test when not built with that in mind from the ground up, so any change to the code might unknowingly break any caller, and we would only know for sure once the game runs. Sadly the code base is 20 years old.
- kgeist 4y ago>For example, creating tables causes an allocation which is slow, so forget about using tables for vector types I once added vector4 as a primitive type in my fork of Lua (to avoid allocations altogether) - it was surprisingly easy to add, took me a weekend.
- rahkiin 4y agoWe were using LuaJit which is a whole other beast.
- otikik 4y ago
- leephillips 4y agoLua and lualatex allow access to TeX internals and (relatively) easy programming of typeset documents: https://lwn.net/Articles/731581/ https://lwn.net/Articles/731581/. Lua is the official language for writing Pandoc filters. And, of course, NeoVim. These are the contexts in which I use it; its embedding into TeX and Pandoc provides some powerful capability.
- ggm 4y ago> Lua is the official language for writing Pandoc filters Given pandoc is written in haskell.. an interesting choice. I guess investing in a DSL syntax was a cost too far.
- shadowofneptune 4y ago1. Each minor version of the language is distinct enough to be incompatible with the previous version. A project embeds one specific version of Lua and never upgrades it. 2. Since it is embedded, it has a pretty small standard library that the embedder can remove or extend. Both lead to Lua communities being more about individual projects which embed it.
- frou_dh 4y agoA good example of this is the Max/MSP audiovisual environment, which, amongst other things, has both Lua 5.1 and an ancient JavaScript engine (JaegerMonkey from Firefox 4) embedded in it to this day.
- lenkite 4y agoNo static typing, No ergonomic language features like lambdas, No functional programming, magic nil behaviour, global by default, no integer type (not sure if this was addressed), index tables instead of having a proper array/list type, missing switch, No assigning operators..the list goes on and on. It was an average PL a decade ago and it is simply mediocre now. Only superb implementations like LuaJIT prop the language up. I would prefer writing Enterprise Java (gasp) over writing Lua code for anything >5k lines. It's OK for small scripts but rapidly breaks down for anything larger. It's a bit funny that a complicated system PL like Rust is more comfortable to code than Lua. Only using Lua personally nowadays due to Neovim and now that https://github.com/noib3/nvim-oxi https://github.com/noib3/nvim-oxi has come out, I am going to use it even less.
- maegul 4y ago> now that https://github.com/noib3/nvim-oxi https://github.com/noib3/nvim-oxi has come out, I am going to use it even less. Woah, interesting ... provided there's success and uptake with this ... I'm imagining it could lead to a really slick and responsive editing experience that those of using (at least) slightly sluggish plugins might have been missing for a while now.
- fanf2 4y agoLua has had proper lexical closures and function expressions since 5.0 https://www.lua.org/manual/5.1/manual.html#2.5.9 https://www.lua.org/manual/5.1/manual.html#2.5.9 It has had 64 bit integers since 5.3 https://www.lua.org/manual/5.3/manual.html#2.1 https://www.lua.org/manual/5.3/manual.html#2.1
- Benjamin_Dobell 4y agoWhat do you mean by no lambdas exactly? Lua supports anonymous functions and they're in fact closures, since those functions capture variables from their outer scope. I use functional programming extensively in Lua also. Could you elaborate on what it doesn't permit? Integers were introduced in 5.3. Assigning operators? It has metatables, you can absolutely implement your own operators. If you want static typing you can use my IDE: https://github.com/Benjamin-Dobell/IntelliJ-Luanalysis/ https://github.com/Benjamin-Dobell/IntelliJ-Luanalysis/ Granted, my IDE is incredibly opinionated and not for everyone. Also, Lua is not my favourite language to use, doesn't even make top 3. However, the robustness of its design, considering its simplicity, is incredibly elegant.
- intelVISA 4y agoSome games use it for a UI/scripting layer but it's a nightmare to work with for anything complicated.
- cardanome 4y agoLua just doesn't have the marketing other languages have. No big corporation behind it. It does not have any exciting or frequent releases. It is basically done as a language since 5.1. New versions can be safely ignored, especially when you want to use LuaJit. These days people simply expect lots of churn and frequent releases to keep the hype for a language up. Also the current trend it towards static type checking which is especially hard to implement for Lua. There are some solutions for gradual typing but there is not exactly first-class support for that. The small standard library might also have been a problem in the past but these days I would argue that JS has normalized that part quite a bit.
- jhoechtl 4y agoIndex by 1
- remram 4y agoThis was such a weird decision. Lua is meant to be embedded, meaning it will have to call application code where indexes start at 0. Why make the Lua indexes not match?
- shadowofneptune 4y agoSome big influences on the syntax are Modula and Fortran. The first allows you to start an array with any index you like, the second starts it with one. As the article says, it started as a data language for engineers who may have been familiar with Fortran. The C-like languages were not as overwhelmingly common back when Lua started, as well.
- pull_my_finger 4y ago> When we started Lua, the world was different, not everything was C-like. Java and JavaScript did not exist, Python was in an infancy and had a lower than 1.0 version. So there was not this thing when all the languages are supposed to be C-like. C was just one of many syntaxes around. > And the arrays were exactly the same. It’s very funny that most people don’t realize that. There are good things about zero-based arrays as well as one-based arrays. > The fact is that most popular languages today are zero-based because of C. They were kind of inspired by C. And the funny thing is that C doesn’t have indexing. So you can’t say that C indexes arrays from zero, because there is no indexing operation. C has pointer arithmetic, so zero in C is not an index, it’s an offset. And as an offset, it must be a zero — not because it has better mathematical properties or because it’s more natural, whatever. > And all those languages that copied C, they do have indexes and don’t have pointer arithmetic. Java, JavaScript, etc., etc. — none of them have pointer arithmetic. So they just copied the zero, but it’s a completely different operation. They put zero for no reason at all — it’s like a cargo cult. https://habr.com/en/company/vk/blog/459466/ https://habr.com/en/company/vk/blog/459466/
- renox 4y ago
- otikik 4y ago> it hasn't been adopted for use more broadly in domains beyond just like being embedded in game engines It might not be in your particular awareness bubble. Parts of the infrastructure that transmitted the request that allowed you to post your comment (the most prominent one is Nginx, but routers and switches with Lua-scripting do exist). In my case, I work in Kong (which has a very healthy Lua plugin), I edit my code with Neovim (Lua is its main plugin-writing language). So I kind of "live and breathe" Lua. Still I am aware of other pieces of software that embed it that I don't use (Redis, Wireshark, even Wikipedia supports Lua on its templates). One interesting characteristic of the language is that it is "barebones". It doesn't have features that are "built-in" in other languages. Things like parsing a json file or making an http request. As a result, the "host program" needs to provide those. Which ends up making "flavor Lua" - Lua with certain assumptions about the host. In this way, Lua is not "one big continuous landmass", but instead an "archipelago". This lack of central point makes it impossible to attach a "marketing/hype machine" to it. It's more like a silent revolution, the language stands on its own merits, for better or worse.
- hulitu 4y agoI was compiling a game which needed Lua. Lua used its own make system without config files which failed with an obscure error message. Since then i avoid it.
- babarock 4y agoLua used to fill a niche very similar to Javascript: small lightweight OOP language that focuses on being embedded in a larger C program. Javascript won this war, mostly based on the explosion of the Web and the insane optimization work that was put on JS engines during the late 2000s. JS ate Lua's cake, not on pure technical merits (the two languages are very similar) but because of their respective environments.
- runevault 4y agoFor reference JS isn't actually object oriented, it is a prototype language. You can fake it being OOP within that style, but it isn't really OOP, even if you can code in it that way.
- Atomskun 4y agoJust like Lua, hence their similarities.
- runevault 4y agoThat's fair. I didn't realize Lua was also a prototype language as I've barely looked at it. Been curious but it never fit my current set of curiosities.
- babarock 4y agoIf we want to be pedantic, prototypal inheritance is a kind of OOP[1]. What you're talking about is referred to as "classical OOP" (OOP using classes). [1]: https://en.wikipedia.org/wiki/Prototype-based_programming https://en.wikipedia.org/wiki/Prototype-based_programming