12 ms·
What do I think about Lua after shipping a project with 60k lines of code?
- gnabgib 1y ago(2024) Discussion ~at the time (321 points, 260 comments) https://news.ycombinator.com/item?id=40538540 https://news.ycombinator.com/item?id=40538540
- helsinki 1y agoAlmost as many lines as my Neovim config.
- MrLeap 1y agoThis made me laugh.
- xedrac 1y agoBut not nearly as many as my Emacs config.
- __MatrixMan__ 1y agoRoughly 60k lines more than my Helix config.
- para_parolu 1y agoHow do you configure awesome plugins for helix then?
- chii 1y agoobviously pre-configured to be awesome already!
- teo_zero 1y agoDid I miss something? Plugins for helix? Since when?
- __MatrixMan__ 1y agoLikely soon: https://github.com/helix-editor/helix/pull/8675#issuecomment-2811627446 https://github.com/helix-editor/helix/pull/8675#issuecomment... My initial point was just that it's kind of nice to have something that's usable from the get-go. I don't miss my gigantic neovim config one bit.
- john-h-k 1y agoI fork the editor and write them in myself. This way I can boast about my tiny config while ignoring the tens of hours of hacking the editor itself
- mabster 1y agoWith dynamically typed languages I feel it's better to wait until you've tried to maintain the code for a while before you consider the languages effectiveness. I had to maintain a very large Lua codebase that has been active for several years. One big problem with Lua was how it will happily take more or less parameters to functions and continue to execute compared to something like Python where it is an error to pass the wrong parameters. This meant when we update a function signature we would often incorrectly update call sites, etc. I can't remember the specifics but we had a few issues with tables being both dictionaries and lists. IIRC, if you delete a list index and there are later list indices, they will turn into dictionary keys. We had a few bugs to do with not traversing the entire array portion of a Lua table because of this. I also implemented a few classic algorithms, e.g. bisect in Lua and you have to be very careful with 1-based indices. You also have to be very careful when interfacing between C and Lua. I prefer 0-based indices and [start, stop) style ranges for everything nowadays. I much prefer statically typed code during maintenance. But dynamically typed languages like Python or Typescript where you can bolt on types, later if you wish, are not too bad. Also using named parameters as much as possible is great for maintenance.
- nine_k 1y ago> dynamically typed languages like Python or Typescript You likely mean JavaScript. Typescript is very much statically typed, unless you allow everything to be `any` and `unknown`. Typescript is mentioned in TFA as a desired (but not available) option, because of the great static typechecking support.
- LoganDark 1y agoTypeScript is sort of "dynamically typed but statically verified".
- nine_k 1y agoMuch like C++ then — the machine code to which it translates lacks types! A TS compiler will reject an ill-typed program. You of course can just strip the type syntax and get a valid (though buggy) JavaScript code.
- nine_k 1y agoOne big takeaway: a 60k LOC project in Lua is doable, and it will not crumble under its own weight. Surprisingly, LuaJIT is not mentioned even once. Luau is mentioned, Teal is mentioned, Fennel, not. (But Haskell is mentioned!) Little is told about the general code structure, likely because it's dictated by the (C++-based) game engine with Lua bindings. It would be interesting to see an analysis of a comparably large game built with Löve, for instance.
- lifthrasiir 1y ago> it will not crumble under its own weight It is possible to make it not crumble under its own weight, right? I had my share of Lua nightmare with more than 100K lines of code back when I was a gamedev [1], and it seems that there are some requirements in order to remain sane with the growth. Thankfully there are now multiple working type checkers for Lua, unlike when I had to built my own. [1] https://news.ycombinator.com/item?id=18351788 https://news.ycombinator.com/item?id=18351788 is my canonical answer, but I have written many other comments about Lua which should be easy to search.
- jerf 1y agoYou can make anything, even assembler, not "crumble under its own weight" if you, the developer, bring enough discipline and care to it. The main reason I like static languages and other such things is that after many decades of the programming community developing, since before I was born, we have not found very many best ways of "bringing enough discipline" to a codebase. It really all amounts to the same disciplines over and over. Check the types. Be sure guarantees are maintained. Document the input and output parameters. If there were dozens of very distinct and mutually-contradictory ways to impose this discipline, and there was no clear domination among those ways, then it might make sense for all of our languages to be loosey-goosey and not impose anything directly. But since we all generally find the same disciplines, we might as well pull those up to the language level and thereby enable them to be fully supported, and share the tooling among each other rather than expecting every junior dev to reinvent it from scratch... which they won't.
- debugnik 1y ago
- thi2 1y agoSince when is LoC some kind of measurement?
- kanbankaren 1y agoLast 50 years? Have you studied Software Engineering? They discuss LOC in depth and many academic papers on KLOC are in SE literature.
- chickenzzzzu 1y agoI can write a program that is 1,000,000 lines of code, and a program that is 200 lines of code, and to the end user they would be doing the same thing. Now, if you start establishing some rules about the type of code I'm allowed to write, then your statement becomes truer. But by no means do people actually follow that in the real world all the time.
- atomicnumber3 1y agoYou're the only person confused about what's meant by LOC here
- pests 1y agoThe number was given just so we have a sense of scale of the project being talked about. Its not a competition nor are measures being made. If you wrote a program that is 1,000,000 lines of code you could also write a blog post about your thoughts on "writing 1,000,000 lines of code". You could also write a program that is 200 lines long and write a blog post about "writing 200 lines of code". One is not better than the others, you are just informing your audience of the topic under discussion.
- otikik 1y agoYou can assume the measurement is “Lines of Code that matter” then.
- TJSomething 1y agoSure, but, assuming you are actually only counting lines of code and not whitespace or comments, if that end user asks for a new feature, it's probably going to be a lot easier to figure out where to put it in 200 lines than in 1,000,000 lines.
- zharknado 1y agoI played the demo of Craftomation 101 a while back. It was good! Had a good balance of watching emergent behavior and feeling the need to micro-manage/accelerate the process. Graphical-only instructions were maddening, though! Especially organizing ideas by dragging them around in 2d space. I would have loved the ability to drop into written code.
- ludicrousdispla 1y agoInteresting article, although I am confused by the section referencing 'functional vibes' as the examples given just looks like standard code.
- mattpallissard 1y agoThe functional code isn't reassigning the same variable. The and/or have something that looks like an implicit return.
- nirav72 1y agoThis is the second game I've found out recently that is written in Lua. The first one one being - Beyond All Reason.
- scambier 1y agoRecently released, Moonring and Balatro are both written in Lua, and I think both with LÖVE.
- msephton 1y agoYOYOZO, my game that received a "Best Games of 2023" accolade, was also written in Lua. It is only 39KB despite containing two music tracks, physics and particle systems, online high score board, dynamic sounds, two fonts, a tutorial and more. https://news.ycombinator.com/item?id=38372936 https://news.ycombinator.com/item?id=38372936
- nvlled 1y agoGrim fandango too
- ecshafer 1y agoLOVE is a popular Lua game framework, so quite a few indie games are written in it.
- ramesh31 1y ago>This is the second game I've found out recently that is written in Lua. The first one one being - Beyond All Reason. Lua is traditionally the scripting language of choice for game development. It was absolutely ubiquitous in the industry before the days of Unreal/Unity. Famously, all of the WoW UI was Lua.
- pansa2 1y agoYeah, this presentation by Roberto Ierusalimschy (one of Lua's three authors) lists over 50 games that use Lua (slide #9): https://www.inf.puc-rio.br/~roberto/talks/curryon2017.pdf https://www.inf.puc-rio.br/~roberto/talks/curryon2017.pdf
- xlii 1y agoI’ve recently moved to the Neovim but even though I learned Lua enough to use it I never found it ergonomic. Recently had some time to spare and moved to Fennel. It has some sharp edges but in the end I find it much easier to maintain. In fact, I think it’s good enough to replace any kind of Lua for me.
- rendall 1y agoIt's an unexpectedly funny interview: > O.C.: Have you consulted about this “tables” approach with other Lua developers? > I.T.: 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.
- rahil627 1y agogood to see defold win. I prefer the love2D/dragonruby framework ways instead of engine now, but can’t deny defold has it all for 2D: game editor, common game structures provided modularly, deployment, no bloat. I could only wish it was the first engine I used. Life would’ve been so much better!
- kgeist 1y agoRoblox has 85 mln daily active users and they use a fork of Lua for most logic. Although most games are very basic, some roleplay games must have tens of thousands of LoC.
- tc4v 1y agoThis dev seems really inexperienced and has weird uninformed takes. The "functional vibe" but it's just using boolean logic, the "reference in a table" bugs that would happen in any language but C, the ignorance of type annotations and so much time spend on problems caused by said ignorance...
- lolc 1y agoThe example is not just boolean logic! In Lua logical ops, the last evaluated value is returned. The example makes use of that to assign something other than a bool. Not all languages do that. In Java for example, boolean logic always evaluates to a bool. I'm not sure which part of that you missed, but maybe don't go too hard on calling others inexperienced based on your takes.
- kragen 1y agoHe may not be super expert, but he doesn't pretend to be. His experience is still valid even if he doesn't really understand what functional programming is yet. (His example isn't just boolean logic.) Being surprised by aliasing would have happened the same way in many languages, but not everything but C. It can happen in C too! But maybe in Python you would have used an (x, y) tuple and gotten an error from trying to mutate it, and certainly in Haskell or OCaml you wouldn't introduce mutability implicitly. In Tcl there's no way to get that problem in a list of lists, and in languages like Golang or Rust or C# you'd probably use an array of structs which would also be immune to aliasing. You could have the same problem, but it's less likely. I've known experienced programmers who were surprised by aliasing bugs, and even had trouble debugging them, maybe because they spent a lot of time in languages where they were possible but less likely. What do you mean about ignorance of type annotations?
- jokoon 1y agoI am using godot, which uses gdscript, which is known to be a slow language. But if your engine is already doing the heavy lifting, a slow scripting language will not matter, because it's not doing much. Also gdscript is pretty nice to use, even if it's lacking tuples, unpacking and other things.
- kragen 1y agoHeh: > ...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.
- airstrike 1y agoReads tongue in cheek but also to be clear, as a PUC-Rio alum I can say there's no such thing as a collective "pontifical catholic universities" board that determines how programming languages behave or how students and faculty should go about their businesses in a software engineering class...
- pansa2 1y agoAre there any other programming languages designed by Pontifical Catholic Universities?
- kragen 1y agoAlmost certainly! The one here in Argentina has campuses in six cities and is well regarded, though it doesn't rank well in worldwide rankings. It has 24000 students at any given time, with alumni including the Queen of the Netherlands and one of the founders of OLX. It seems likely that the number of programming languages designed by one or another professor or student there at one time or another is in the dozens. One repo I found on GitHub uses a dialect of Smalltalk I'm not familiar with, but I don't know if it originates at the university: https://github.com/uca-argentina/2021-bigtalkers/blob/master/repository/BaselineOfIngSoft2/BaselineOfIngSoft2.class.st https://github.com/uca-argentina/2021-bigtalkers/blob/master... The PUC in Santiago de Chile is even better, academically, and has some 34000 students at any given time. It would be very surprising if different languages originating from these universities had significant design features in common!
- pansa2 1y agoInteresting, thanks!
- ksymph 1y agoSo much lua stuff on HN the past few days, I love it. Defold is a great engine. It has a somewhat steep learning curve (steeper than you'd expect, anyway) and its fair share of quirks, but more often than not the quirks are deliberate tradeoffs that steer you in the direction of structuring your game well. It really feels like an extension of the lua philosophy of giving you a narrow set slightly odd, but very robust and flexible tools that you build everything else out of. I'm back to using LOVE2D for general tinkering but a few months with Defold really changed how I approach things. I've been meaning to write up a post about it. Either way though, I'd highly recommend checking out Defold to anyone interested.
- suzzer99 1y agoEight space tabs. My eyes! The goggles they do nothing!