16 ms·
What I think about Lua after shipping a project with 60k lines of code
- fwsgonzo 2y agoCongrats on shipping a game! It's truly an insane amount of work these days, with all the competition out there.
- gamescodedogs 2y agoThank you for the kindness :) Doing our best!
- xandrius 2y agoTo be fair, shipping itself has nothing to do with competition. Still a tough feat nonetheless!
- bru3s 2y agoCongrats on your game! Which would you say were the major hurdles you'd found with C++ that convinced you against using it again?
- lyu07282 2y agowhat do you think about this take by Jonathan Blow about scripting languages in gamedev: https://www.youtube.com/watch?v=y2Wmz15aXk0 https://www.youtube.com/watch?v=y2Wmz15aXk0
- ralfd 2y agoSummary of the video please?
- lyu07282 2y agoJonathan Blow criticizes the use of scripting languages in modern game development as outdated and inefficient, pointing out that they slow down performance, are error-prone, and complicate the development process with extensive engine integration needs. He notes that while initially appealing for allowing quick iterations and non-programmer accessibility, scripting languages often result in poor quality, bug-ridden code that requires significant oversight from professional programmers. Advocating for robust, compiled languages like C++, Blow dismisses scripting languages as a failed experiment and praises the shift towards more constrained and user-friendly visual scripting systems in platforms like Unreal and Unity. (i don't mean to suggest that i agree with him, I just was curious)
- IshKebab 2y agoInteresting. I feel like his opinion makes sense for first party code, but what if you want to support mods? I don't really have time to develop them anymore but I did a couple in QuakeC back in the day (I'm old) and really enjoyed it. IIRC it had lots of domain specific niceties like native vector types. One slightly hilarious thing is any loop that looped more than 100k times was killed with an infinite loop error. Actually saved me a couple of times. I feel like if there was a nice modern statically typed language that was easy to embed I would go with that. Something like Dart maybe. But I don't think that's easy to integrate.
- wudangmonk 2y agoWas a lot of the functionality of Quake done in QuakeC or was that scripting language added for the sole purpose of allowing for mods to the game?. I think scripting languages are a very bad idea for the core functionality of a game and I see no benefit to them. If its done after you have nailed down all your core mechanics and just want to add mod support for things such as player created maps then I think that's fine. That means that a scripting language should only be added towards the very end of a project. Adding it towards the beginning when you don't even know your core mechanics yet seems crazy to me since I see no benefit to it.
- IshKebab 2y agoThe engine was all C. QuakeC was used to script the game logic - how weapons behave, doors open, items move around, etc. It was reasonably powerful. You could make grappling hooks, proximity mines, etc. I guess the core mechanics of Quake were very obvious. It wasn't a very innovative game in that sense; basically identical to Doom but with way fancier graphics, controls and so on.
- int_19h 2y agoQuakeC was powerful enough to create mods like Quess (https://www.youtube.com/watch?v=TD2Qz_hH2U4 https://www.youtube.com/watch?v=TD2Qz_hH2U4) and Quake Rally (https://www.youtube.com/watch?v=Fg0hTSLE-NM https://www.youtube.com/watch?v=Fg0hTSLE-NM). Although the latter was really pushing the limits of the engine. And lest we forget, Reaper Bot, the thing that made PvE deathmatch a reality. To this day I'm amazed that so much cool stuff was done in QuakeC despite the language not even having arrays...
- bsder 2y agoUntil Blow open sources Jai, his opinions are mostly irrelevant.
- aodonnell2536 2y agoHow come? This doesn’t seem true to me, and your second clause reads like a non-sequitor
- bsder 2y agoBecause Johnathan Blow programs in Jai and his experience is talking about the tradeoff set with <technique X> when using Jai. Since we plebians can't use Jai, that tradeoff is irrelevant. For example, Jai has hot loading, IIRC (somebody please correct me if I'm wrong). The utility of an embedded scripting language is completely different if your tooling has really good support for hot loading of your engine implementation language. Furthermore, because we plebians can't use Jai, we can't verify anything said about it in context, either.
- frankjr 2y ago> Jai has hot loading It doesn't have any hot reloading capability out of the box.
- wsc981 2y agoI don't think so. He's shipped a few quality games. He can speak from experience. That's not to say I agree with all his opinions.
- tialaramex 2y agoJonathan Blow has shipped two games, Braid is very well liked and The Witness got more mixed opinions but certainly there aren't many people who think it's just terrible - more that it wasn't appealing for them. But two is a very small sample size, and the fact that The Witness annoyed more people isn't necessarily a great sign - given more time and money, Blow made a game he presumably liked better but others did not. Maybe Jon will like Jai very much when it's done. Is that enough? In some sense maybe. But why should anybody else care? In 2014 there weren't a lot of people doing this, maybe you'd look around and say "At least somebody is trying something". In 2024 there are plenty of programming languages to choose instead of C++ even if you specifically want to write video games. If you like roughly where Jai wants to be, no interesting ideas just do stuff we know works, there are even other languages in that space, including Odin and Zig.
- AnotherGoodName 2y agoEvery config file becomes something close to a scripting language at some point. Build files, video game maps, etc. Eg. You have a game with enemies spawning in some circumstance. The file that defines the level of the game now needs a bit of logic to specify that the enemy spawns given conditions. If you don't use a scripting language you'll have a field in that file that takes parameters for the conditions. Now do this 1000 times over for all the other little things you may want in the level. Pretty soon your file that defines the level is slowly becoming a shitty adhoc scripting language.
- AlphaWeaver 2y ago> After that, I went back to Dmitry and asked him if my understanding of “everything is a table” was correct and, if so, why Lua was designed this way. Dmitry told me that Lua was created at the Pontifical Catholic University of Rio de Janeiro and that it was acceptable for Pontifical Catholic Universities to design programming languages this way.
- oh_nice_marmot 2y agoIt's unclear to me what you are trying to say here.
- nmz 2y agoThere's no explanation.
- jmspring 2y agohttps://en.m.wikipedia.org/wiki/Lua_(programming_language)#:~:text=Lua%20was%20created%20in%201993,Rio%20de%20Janeiro%2C%20in%20Brazil https://en.m.wikipedia.org/wiki/Lua_(programming_language)#:....
- gary_0 2y agoIt's a joke wryly comparing its uncommon origins with its uncommon design.
- koeng 2y agoI’ve used teal before, the statically typed Lua that is mentioned at the end. It’s actually really good! There are some limitations (especially around generics) that can be annoying, however. Overall, I really enjoyed using it and would use it again.
- ardit33 2y agoI haven't used the static version, but almost eveyrone that I know have used Lua loves it. There is beauty to its simplicity/bare bones approach to programing.
- chadcmulligan 2y agoteal is for the command line only though afaik, you can't embed it, but would be pleased to be proved wrong.
- koeng 2y agoNope, you can embed it. Teal is written in teal, and compiles down to lua - so you can simply put teal as a lua dependency. I used it with gopher-lua (Golang lua environment). https://github.com/teal-language/tl/pull/523 https://github.com/teal-language/tl/pull/523
- chadcmulligan 2y agoThat's great! thanks
- cardanome 2y agoWhile I do think Teal is pretty cool, I think adding gradual typing by the having a static language that compiles down to a dynamic language Typescript-style is the worst way to add gradual typing support. The extra compile step and the added complexity kind of kills the advantages of using a simple dynamic language like Lua in the first place. You can only compile a file if the types are correct. You might think this is good but no, not at at all. This is horrible for prototyping because sometimes you might want to test a specific path even when you haven't yet refactored the rest of the program. It is much less hassle to just add type annotations as comments and have the linter figure it out. So you can have your cake and eat it too, having both type safety when you need and want it and the power and flexibility of dynamic typing in one. Now, an even better way is probably what Luau is doing because you also have type information available at runtime which then can be used for reflection and performance. Especially as they have an option to disable the type checking if needed.
- QuaternionsBhop 2y agoAfter 10 years and many projects, the greatest with 40k lines of code including a time-of-intersection-solving single body physics system, I have come to know how to use Lua for my purposes. Even so, from the moment I started watching Rust hype videos on YouTube, I knew I would eventually be converted into a Rust fanatic. At the end of a 2 year project to rewrite my Lua game with a new physics system, I felt it was a good time to learn Rust (and rewrite the game again in Rust). So far I have spent 6 months in Rust and my old tool looks like a toy. How did I ever live without iterators, algebraic data types, the safety of a strong type system, and especially separate types for arrays and hashmaps for god sakes? Lua makes the scope of learning programming smaller compared to other languages, so it is probably fair to say that it is a good language to learn programming with. However, knowing the details of heap vs stack, array vs hashmap, and explaining that to someone learning programming for the first time within a language that attempts to hide those details is frustrating. I can't see the smaller picture and view a table simply as a thing that you get and set values from, I can't see the weak types as anything more than an annoying source of bugs at runtime, and I crave the borrow checker which saves me from myself. My 10 years of Lua set me up to appreciate Rust's fantastic design choices, and I'm having a great time in Rust land. I wish to remain in Rust land but my finances demand me to use my Lua skills at least a little while longer. End of ramble
- _ugfj 2y agoThe fanaticism of Rust programmers are well known and off putting. Why, one of them just posted about it into a Lua thread. It couldn't be less relevant. Much as I don't have a hard choice between picking assembly and PHP for a task, Rust and Lua are just not in the same problem space.
- umvi 2y agoI 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.
- _ugfj 2y agoIt's interesting to see Haskell vibes mentioned. Where's the "well yes but actually no" meme when one needs it. It's not Haskell, it's Scheme. https://www.lua.org/doc/hopl.pdf https://www.lua.org/doc/hopl.pdf > Semantically, Lua has many similarities with Scheme, even though these similarities are not immediately clear be- cause the two languages are syntactically very different. The influence of Scheme on Lua has gradually increased during Lua’s evolution: initially, Scheme was just a language in the background, but later it became increasingly important as a source of inspiration, especially with the introduction of anonymous functions and full lexical scoping Of course, Haskell was also Scheme influenced although it's an ML descendant. Speaking of this, I wonder what would've happened if they embedded Lua into Netscape instead of writing JavaScript...
- nmz 2y agowell, lua existed back then, but that lua is not lua5, even lua4 looks incredibly different especially when it comes to tables.
- chx 2y agoYeah that would've been lua2.1 described here: https://www.lua.org/spe.html https://www.lua.org/spe.html
- suby 2y agoI think if Lua were adopted as the web language, it would have lost its spirit / design philosophy of simplicity. I think the web would have exerted an evolutionary pressure on whatever language was the chosen as the exclusive way of writing code. Everyone forced to use a single language as the only option plus too many people clamoring for their own pet language feature to be added plus design by committee will probably always lead to a mess.
- at_a_remove 2y agoI have been having thoughts, wild and incoherent, about the evolution of a given programming language. What does it take to survive and thrive? I might describe my programming career as being kind of a refugee: on the web, I moved from plain .asp to Perl, fled Perl for Python ... At the start, a language needs the ability to evolve. I recall reading a book on Python before I adopted it, a book which was so off-putting that I ended up delaying my attempts to use Python, and it went on about Python's philosophy when it came to division. I knew that, at some point, Python would have to change away from integer division by default. And it eventually did. It was a mistake because it was non-obvious, and the language changed to fix it. Good. Now, though, all kinds of things have crept into Python which are decidedly non-Pythonic: the walrus operator, which looks like something that escaped from a Perl dungeon; the docopt module, which has a weird trap of it being a module you must know about, but only if someone has decided to use it; the utter shambles which is the whole environment and library packaging "let entirely too many ways to do it exist;" or the community's preference for Requests while it somehow has yet to be co-opted into the standard library. I am sure I have gored someone's ox here. Perhaps a language needs a certain window before it is finally frozen in place. Or a more stringent, forceful mandate than the Zen of Python, which I think has been Not Enough. In a way, I am reminded of the Agile Manifesto, which was well-intentioned but had no enforcement, no orthodoxy; it lacked teeth to nip at the heels of those who fail, who go astray. Originally, I had considered that the Network Effect as a way to freeze things, but it seems to only work on protocols and less so on languages.
- jmclnx 2y agoLua is one language I have been wanting to use, especially since it has hooks into the NetBSD kernel. And >And what about the lack of classes in Lua? to me is a big plus :)
- ardit33 2y agoI have used it production (embeded/mobile), and I liked a lot. Their associated tables are just awesome. The problem with Lua is that object oriented programing is not necessary a first class citizen (you have to create it from scratch with object prototypes) and that Python occupies the same space and has sucked the oxygen out of it. Think of Lua as a much leaner/simpler Python, and better for embeded situations.
- diarrhea 2y agoLua can also be massively faster than Python (LuaJIT).
- thement 2y agoThe problem with "lack of classes" is that every non-trivial program makes its own implementation of something-like-classes, but built on top of metatables. So before you can start hacking on anything in Lua, you have to first understand the class system, which may or may not be documented.
- mhh__ 2y agoLua is a language that I really hate quite a few aspects of the design of but still like quite a lot. Weird that.
- giraffe_lady 2y agoI have a lot of technical respect for the project, especially in how carefully they have selected a goal and always develop towards it. And gaining expertise in lua is almost like taking a master class in language design: you are nearly forced to learn about the underlying constraints and how they have been addressed. It definitely improved my understanding of coding more than most languages have. All that said I simply don't like it very much and don't think it's a good choice for most things I see it used for. When I see people talking about how much they enjoy it it's usually on small projects, or solo projects, or both. The simplicity of the language and variety of runtimes and distribution methods means every significant lua project is a totally unique framework with homegrown standard library. It also really badly needs better string handling utils. I appreciate the constraints they're working under and admire the decisions they've made in respect to them. But one of its most common practical uses is as a DSL or scripting extension to another environment. I agree with the decision not to include regex, and patterns are incredible for what they are but they aren't sophisticated enough for many cases. Some parser rudiments or even a peg engine built in would completely solve the problem. But if that's too big just a dozen or so common string tools would go pretty far.
- xedrac 2y agoI still can't get over the 1-based indexing, even if you don't necessarily need to use it that often.
- nequals30 2y agoI'm wrapping up a multi-year personal project, a game written fully in lua using love2d. To me, the beauty of lua is the simplicity and lack of learning curve: I can usually accomplish whatever I need to without looking anything up (as the author said, everything is a table so there isn't much to overthink). Also, the community and support around love2d is fantastic. One thing that's bothered me is that lua silently returns nil when you reference non-existing elements. That's been a pain when debugging, since a line with a typo (`a = typo`) doesn't fail, and the code fails much farther downstream (e.g. when doing arithmetic on `a`). So almost all my errors end up being "trying to do operation on a nil value", and there is no indication of why it's nil.
- wwwigham 2y agoYou can define a metatable on your objects of interest (or the root table meta table if you don't mind breaking the language's conventions and thus libraries) with __index and __newindex members. Then you can throw in those by calling the `error` function when they'd otherwise normally return nil, should you desire it. But runtime checks have a cost, and static types that transpile away are a bit better for overhead so long as you don't mind the build step, so using one of the typed lua variants is probably a bit nicer in the long term. Catching those typos early is their bread and butter.
- dividuum 2y agoI think you can add a metatable to _G with an __index function. This should be called when accessing undefined local variables (as they end up trying to access the global scope _G) and you can thrown an error.
- deleted 2y ago[deleted]
- edflsafoiewq 2y agoA linter like luacheck is better for accidental globals, but I think the GP was talking about doing a = someTable.typoedFieldName.
- 2y ago
- bhaney 2y ago> I thought I knew C++, but working with ClickHouse showed me otherwise Only language where you can keep having this realization over and over forever. Of course people prefer lua if they can get away with it.
- marcosdumay 2y agoAs a comparison, Haskell is a language where you can keep learning more and more advanced things, forever. But yeah, I guess C++ is the one single language where you can keep learning more and more fundamental things, forever.
- exe34 2y agohaskell is great if you enjoy learning haskell. there's always a new build system, a complete redesign of how things are done, etc. i lost the plot around the time everything became an arrow (or was it a lens ?) myself, but I'm sure a few more generations of improvement have happened already!
- marcosdumay 2y agoEverything never became an arrow. Arrows are a flexible enough abstraction if you are trying to cram some things that the language supports badly into it, like FRP. Also, everything never became a lens.
- exe34 2y agoit just seemed like the tutorials just pivoted from monads to lenses to arrows. but fair enough, I never did "get" haskell. I loved the functional aspect of functional problems (e.g science equations), but once it came to carrying state, everything just turned into a mess for me.
- marcosdumay 2y ago> everything just turned into a mess for me I just want to say, this one is absolutely normal. That's what learning new stuff feels like most of the time. Then, after you pass through it, you go and write a tutorial so other people are spared. But then... I'm not sure this part works :)
- BaculumMeumEst 2y agoMy favorite thing about Lua is that it trivially builds anywhere with a C compiler. Lots of other languages that bill themselves as "embeddable" are a real pain in the ass to build on weird platforms.
- thement 2y agoI even managed to get Lua built on z/OS mainframe! The productivity gains were *amazing* (compared to REXX).
- ctenb 2y agoCan you quantify this and link to the implementation?
- ufo 2y agoFun example: there's a project (Lunatik) that embeds Lua inside the Linux kernel, where no userspace C APIs are available. You'd expect that would require extensive patching but they mostly just had to tweak the makefile and a configuration header file.
- hgyjnbdet 2y agoI've been wanting to pick up lua for ages. My only issue, as always, is where to start. Is there a runtime I can install where I can start creating with lua? Cross platform, windows and Linux? That will allow someone with no c/c++ experience to start doing stuff with it?
- longor1996 2y agoPerhaps redbean might be of interest? It's a web server with all the batteries included, scripted via lua. https://redbean.dev/ https://redbean.dev/
- krapp 2y agoLove2D is popular (https://love2d.org/ https://love2d.org/) Also Lua binaries are available here (https://luabinaries.sourceforge.net/ https://luabinaries.sourceforge.net/) And a big list of Lua frameworks (https://github.com/uhub/awesome-lua https://github.com/uhub/awesome-lua) I'd suggest working with LuaJIT as well because of the C API (you can easily use something like SDL and build metatypes around them) with the caveat that it's stuck at an older version of Lua[0,1]. [0] https://luajit.org/ https://luajit.org/ [1] https://github.com/LuaJIT/LuaJIT https://github.com/LuaJIT/LuaJIT
- Red_Tarsius 2y agoI have used Lua a long time ago and I don't remember ever touching C/C++. You can even make simple games without ever going low level thanks to https://love2d.org/ https://love2d.org/! If I recall, most https://stabyourself.net/ https://stabyourself.net/ games are based on Love2d. If you're using Linux/MacOS, you can copy-paste these commands on the terminal and you should be settled: curl -L -R -O https://www.lua.org/ftp/lua-5.4.6.tar.gz tar zxf lua-5.4.6.tar.gz cd lua-5.4.6 make all test You should find the lua executable inside the lua-5.4.6/src folder.
- gatane 2y agoThere are also "fantasy consoles". Most of them use Lua+their own api for dealing with the virtual console internals. * PICO-8 (paid, 8$) https://www.lexaloffle.com/pico-8.php https://www.lexaloffle.com/pico-8.php * TIC80 (opensource, supports more langs like python, scheme, so on) https://tic80.com/ https://tic80.com/ Have fun!
- luasuxlolz 2y ago[flagged]
- thefaux 2y ago> However, when it comes to separating code into modules or packages, Python is more convenient. Kind of curious about this. I find packaging in Lua quite convenient. I make a file and return either a value or a table full of values and then I require that file in the dependent file that uses the package. Also, wrt to the missing features like an increment operator. It is possible in at most a few thousand lines of lua to implement a lua' -> lua transpiler where lua' adds some missing features, such as increment operators, in an idiomatic way. In other words, the generated code looks almost exactly the same as the input code except in places where say `x++` gets translated to `x = x + 1`. As long as your file is less than a few thousand lines of code, the transpiler can run in < ~200ms (and obviously much less for shorter files or much faster if the transpiler is implemented in a faster language). Of course the tradeoff is that the original source code may break existing tooling for lua, though the generated code will work fine.
- CapsAdmin 2y ago> Kind of curious about this. I find packaging in Lua quite convenient. I make a file and return either a value or a table full of values and then I require that file in the dependent file that uses the package. While that aspect of it is nice, I think the way paths are handled by default can get annoying. Since everything has to be relative from the current directory, it's not very convenient to move files around or make a contained module that depend on its own module. If you're in charge of your own environment, sure, you can roll your own thing, but then you deviate from the norm and your code becomes less portable. There is also the LuaRocks package manager, which I believe is decent, but it's largely ignored by a big portion of the Lua community.
- spc476 2y ago> Since everything has to be relative from the current directory, it's not very convenient to move files around or make a contained module that depend on its own module. What? Not in my experience. For instance, I have lpeg install ~/.luarocks/lib/lua/5.4 and LuaXML in /usr/local/share/lua/5.4 (just to name two modules I use). To use them, it's just local lpeg = require "lpeg" local xml = require "LuaXml" I'm confused as to what you mean.
- JSR_FDED 2y agoI wrote a trading system where the strategies are written in Lua. It has been a delight, fast and simple. The traders have the expressivity of a full programming language and I can add any function to that language and provide any data as well so that their programming (and execution) sandbox is extremely ergonomic and suited to their specific task. In other words, a trading DSL. Other code outside the sandbox pulls in up to date price data and if certain safety rules are violated will automatically close out positions. So even if the traders code their way into an infinite loop or make other mistakes, the supervisor can step in and automatically prevent disaster. Using Lua to make a language for others has been a wonderful experience. FYI, it was approx 11K lines of Lua).
- nattaylor 2y agoA friend built a system where the ad campaigns with all their targeting rules were Lua scripts and it was also fast and simple in a glorious way!
- knighthack 2y agoWhy wasn't Python used? I imagine for such a use case it wouldn't be that much heavier to use Python vs Lua.
- qwertox 2y agoSpeed, probably. Lua is much faster.
- nattaylor 2y agoYes, speed. 1,000,000+ QPS and 1,000s of ads to evaluate is common. At that scale it's very distributed, so replication is another challenge. In a way, its a search problem where bid≈relevance and targeting_match≈recall, so I've seen Solr used here too.
- catlifeonmars 2y agoIntegration complexity could be a factor. I’m making an assumption about the architecture, but embedding Lua in a program is dead simple and you can do so without introducing external dependencies. Python IIRC requires you to ship and package the standard library or have it already installed, the Lua interpreter can be statically embedded in a program.
- bartwe 2y agoWe used Lua in the past, but mostly because doing quick iterations in c++ in that project was unrealistic due to 10+ minute build times.
- indymike 2y agoI learned Lua modding the game Homeworld and writing access control filters for NGINX. So easy to understand, mostly because Lua is pretty bare bones. I've always wanted to fit it into a project, but Javascript and Python are tough competition for a language like Lua.
- rewgs 2y agoCongrats to the author, but I really can't stand Lua. It takes its commitment to simplicity too far IMO, especially with regards to tables not really specifying between (in Python terms) "dict-like" and "list-like" tables. Recursively searching through a table of tables can for this reason be annoyingly difficult. Every time I write it, I find myself wanting a language with just a few more batteries included.
- vitiral 2y agoYou might like https://github.com/civboot/civlua https://github.com/civboot/civlua if you ever find yourself wanting to use it.
- kbd 2y agoAnyone here use https://fennel-lang.org/ https://fennel-lang.org/ to make Lua more palatable/fun?
- giraffe_lady 2y agoYes I love fennel for this. I've done a lot of professional lua work and I don't enjoy it as much as people here tend to. Fennel is an astounding technical accomplishment, laser focused on the worst practical issues with lua and completely avoiding lisp nerd quagmires. It's extremely practical too: you can hook the compiler into the lua module loader and since it's just a syntax layer over lua semantics you can drop it into any lua project. Being able to freely share functions and tables between the two makes working on legacy lua code so more comfortable. I've used it extensively and have almost nothing bad to say about it, extremely rare for me with any programming language.
- canadianfella 2y ago[dead]
- andrewmcwatters 2y agoI don’t know whether or not it’s still the case that at Planimeter we ship the largest pure Lua game engine published on GitHub, but I remember our biggest issue being rather unrelated to the language itself in that game development has some real performance concerns that are hard to measure even with standard tools.
- dcreater 2y agoTL;DR?
- hwbunny 2y ago[dead]
- smaddox 2y ago> It seems that using OOP in Lua can quickly and surprisingly lead developers into a situation where adding new features becomes really hard. Not just in Lua...
- rmetzler 2y agoIs it intentional that the variable is named “place_f_older” and not “place_h_older”?
- wiradikusuma 2y agoMy experience with Lua is only writing Redis scripts. Maybe I'm pampered, but I found its lack of editor support is off-putting. I juggle between different languages (I'm writing a "full stack" book about building mobile apps, https://opinionatedlaunch.com https://opinionatedlaunch.com), so I always need auto-complete when coding. Edit: FYI I use IntelliJ with Lua support, and I'm comparing it relative to other languages that I also use (Java/Scala, Dart, Python, JS)
- vaylian 2y agoThere is https://github.com/LuaLS/lua-language-server https://github.com/LuaLS/lua-language-server > Edit: FYI I use IntelliJ with Lua support, In other words, you don't like Lua, because your favorite IDE doesn't properly support it? (Or maybe it does, when you install the aforementioned language server)
- klibertp 2y ago> In other words, you don't like Lua, because your favorite IDE doesn't properly support it? That's normal. Many - perhaps most - programmers lack appropriate mental tools to compare languages meaningfully. They instead use any kind of heuristic they find useful at the time. The never-ending discussions that mistake familiarity with readability are another example of this mechanism.
- shmerl 2y agoI got exposure to Lua with Cyberpunk 2077 mods and neovim plugins. Some stuff is indeed strange (like array indexes starting from 1 by default), but overall it's easy to use. Not sure I'd want to use it for something big though.
- samiv 2y agoI've embedded Lua in my game engine and I'd say that - performance is a joke - GC can cause really bad hick-ups - loose runtime typing makes it hard to build static tooling for developer support - lack of predetermined more rigid structure makes some things confusing (like you can mess with the internals such as the meta tables and stuff, which can be useful but also confusing) + functionality wise it's adequate for a game programmer, perfect for writing (smallish) scripts of game play + it's simple to integrate and provide bindings for + lots of flexibility how you use it and what kind of code you use to write with it In my experience I'd say that if you're planning to integrate and use Lua in your projects you need to - have a fallback for performance sensitive code, either by being able to mix and match native and Lua user (game) code or provide functionality natively in your engine OOTB - make sure you can run things properly (using real threads not joke threads) in parallel as much as possible - stay on top of perf at all times and integrate performance tests and bench marks to your development process Despite the problems I've managed to build a Lua code editor that has a) auto formatting b) syntax highlighting c) auto completion (limited but still) d) simple navigation support e) built-in help The editor is integrated in my game engine's editor. You can find more details on my GitHub https://github.com/ensisoft/detonator https://github.com/ensisoft/detonator
- JustSkyfall 2y agoI believe Roblox's Luau would be suitable for this case? It's got pretty good performance and typing support. Still supports metatables I think (they needed backwards compatibility with old Lua 5.1 code), but it's a start ¯\_(ツ)_/¯
- rfl890 2y agoAFAIK metatables are still in Lua 5.4?
- PhilipRoman 2y ago>GC can cause really bad hick-ups What version were you using? Recent Lua versions have a smoother GC overall
- pacoverdi 2y agoI had two encounters with Lua many years ago. The first to write "stored procedures" in Redis (I forget the correct terminology). It allowed to improve the performance of Django endpoints by an order of magnitude. In the second, I wrote a Wireshark plugin (also not sure of the proper term) to dissect a proprietary protocol. I don't remember the details but this is not a programming experience I look forward to renew... (Same feeling about Perl btw) Possibly indices starting at 1 were the most disturbing.
- vitiral 2y agoIndexes do start at one. Offsets start at zero. If you have a table of 5 apples and the middle one is rotten do you say the rotten one is the 2nd or 3rd?
- pacoverdi 2y agoThat was a surprising downvote. I was referring to this: "it is customary in Lua to start arrays with index 1" [1] Not being a native English speaker, I may have phrased something wrong. I find "one-based indexing" in arrays not particular intuitive, and error-prone. Better? [1] https://www.lua.org/pil/11.1.html https://www.lua.org/pil/11.1.html
- vitiral 2y agoNo, what you phrased is a common argument but IMO doesn't follow from natural language. The fact that C uses pointer offsets as it's "indexes" is IMO the truly counterintuitive thing. Obviously I use 0 based indexes for most of my programming. I have not found 1 based indexing to be a serious problem since Lua is a high enough language that I'm rarely doing complex index arithmetic. FYI I didn't downvote you.
- frank_bb 2y ago[dead]
- wruza 2y agoLua is both cool and not, depends on how you look at it. I used it for several years before going elsewhere. I wrote a graphical toolkit with animations in it (based on pango/cairo), embedded it for a business-objects platform and used in Quik trading platform for trading bots. It’s very nice, but it has rough edges that never get addressed, despite being proposed in the mailing list in every proposal phase. __newindex only works once, then it’s not “new” anymore. You have to proxy your table with an empty table and a metatable, also make sure you now implement all metamethods for your proxy table to be indexable, iterable, #-able, tostringable and so on. No __setindex for you. Every version of Lua has little changes in there (it uses no semver), so your 5.x iteration protocol/etc are bound to that x. Why would you upgrade then? Cause every 5.x lacks something you really want and it’s in 5.<x+1>. There’s also something you don’t want. “a and b or c” and “b or c” paradigm doesn’t work with boolean “false”, because it’s unsurprisingly as false as nil. It’s not haskell vibes, it’s a lack of ?: and ?? operators right there. Nil/false are basically second class citizens in Lua cause only these two share the same room, also nil is prohibited from any array. Lua ignores most syntactic ergonomics. You can’t destructure a table, everything has to be “local a, b, c = t.a, t.b, t.c”. And vice versa: “{a=a, b=b, c=c}”, which is syntactically non-fixable due to table duality. Its “…” literal has inconvenient semantics of collapsing before another argument: f(…, x) is equivalent to f({…}[1], x). So you have to “local t = {…}; table.insert(t, x); f(unpack(t))”. No way you can get something like t.push(x) either, for reasons too long for a medium sized comment. Lua is also highly function-esque, but there’s no way to shorten “function (x) return <mylambda> end”. Also its gc is pretty much stop the world. They experimented with it in recent versions, but at 5.1 times you didn’t expect your complex scripts to not freeze for a substantial amount of frames if you “wow so simple”d them and created {} here and there. It takes time to collect the garbage. Rocks, Lua package manager tends to build everything locally, but your windows box ecosystem is out of luck. If you can’t find a pre-built dll, you’re in the mud. That’s windows fault, but your problem at the end of the day. Luckily you can make it yourself, cause Lua has great C API and LuaJIT has ffi. No /s here, I made all my wrappers and connectors myself. Overall it’s a nice language idea, fully functional prototype, you name it. It works in the falling in love phase and has unique features for a non-esoteric lang. But don’t expect too much from it in a “marriage” if you’re one of those who want things to get out your way and you don’t get why an obvious feature cannot be done for ideological reasons while compatibility gets broken regularly anyway. I understand that this post looks negative, but that’s because it enumerates only downsides, which are real, although sometimes subjective. I have pretty fond memories of it, but still had to move on.
- NelsonMinar 2y agoBalatro is another game written in Lua, using the Love2d engine. About 30,000 lines of code (including comments) you can read if you unpack the Steam distribution. Great game and runs very well on many platforms.
- Aerbil313 2y agoLua is a just perfect for application scripting. It fills a real market gap. It's astoundingly simple compared to any other language. In my mental map of programming languages, it's C but garbage collected, it's Python but simple, it's for the express purpose of application scripting. You can have and mutate global variables in Lua. I'd never voluntarily write in any language with global mutable shared state. But after using Lua in my job for several months I've realized that using mutable global shared state is really the right tool for the job scripting.
- annaglotova 2y ago60k lines sounds crazy for Lua...