Live data from Hacker News

What do I think about Lua after shipping a project with 60k lines of code?

blog.luden.io

51–60 of 146 posts

Re: What do I think about Lua after shipping a project with 60k lines of code?

#51
post #5

With 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 pa…

>This meant when we update a function signature we would often incorrectly update call sites, etc.

The same thing happened with our huge legacy PHP monolith, which was written before type hints were a thing. Developers were reluctant to refactor large chunks of code when the time came, because it was just too easy to introduce bugs - you couldn’t be confident about anything without manually digging through tons of code. So, when business requirements changed, they’d just bolt on some hacks to avoid touching the existing, tested code, and call it a day. It became a self-reinforcing loop: fear of refactoring → more hacks to avoid refactoring → more brittle code → even more fear of refactoring. Eventually, they added type hints and a linter to analyze them, but by that point you start to wonder - why are we even using a dynamic language and fighting its quirks?

Re: What do I think about Lua after shipping a project with 60k lines of code?

#52
post #6

One 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…

Years ago I wrote/maintained a modal console-based email client. It was written with some UI primitives in C++ and the UI actually maintained and controlled by lua.

Viewing a list of folders? Lua. Viewing a list of messages? lua. Viewing a single message? Lua. Those were the three main modes and UI options.

All the keybindings, layout, colour setup, and similar was dynamic. It actually worked out really well. For comparison I just ran "wc -l" against he codebase: 60k lines. Combination of C++ and Lua, but mostly Lua.

Having good scope and good tests made such a thing fine to support. Mostly the pain was broken MIME messages and handling dealing with the external world - e.g. invoking gpg to handle decryption and encryption.

I'd work with big-lua again if I had the need, it's a fun language and very flexible.

Re: What do I think about Lua after shipping a project with 60k lines of code?

#53
post #42

Earlier quoted context omitted.

> Much like C++ then — the machine code to which it translates lacks types! Ehh, not exactly. Most C++ compilers won't output machine code for inputs they don't understand. Though of course, you could simply translate some C++ code yourself into machine code and then say C++ is just like TypeScript in that way. "If you turn C++ into machine code, the machine code lacks types!" "If you turn TypeScript into JavaScript,…

> TypeScript compiler essentially treats types as a lint Sorry, I think you've been swindled. The Typescript compiler is made by Miscrosoft and is called tsc. It very much heeds the type annotations, and very much rejects ill-typed programs. An LSP based on it does the same in an editor. Also tsc supports refinement types via flow control analysis and a bunch of other static correctness checks. Deno, bun, swc are not…

> and very much rejects ill-typed programs

No it doesn't. Even on the strictest settings, Typescript is unsound in trivial ways, which I hit every time I use it in anger (e.g. undefined in unassigned variables). And Microsoft libraries seem perfectly ok with asserting their type errors away without any validation, specially for JSON values.

I had a similar experience with Python until I found Pydantic.

I haven't had a chance to try Elixir's new type system (is it ready yet?), but at least their strong-arrow model would ensure that runtime checks for dynamically-typed values are done eventually.

Re: What do I think about Lua after shipping a project with 60k lines of code?

#54
This 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...

Re: What do I think about Lua after shipping a project with 60k lines of code?

#55
I 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.

Re: What do I think about Lua after shipping a project with 60k lines of code?

#56
post #5

With 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 pa…

>when interfacing between C and Lua

Except for the indexing mismatch, I've found calling Lua from C and vise-verse very easy.

Re: What do I think about Lua after shipping a project with 60k lines of code?

#57
post #54

This 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...

The 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.

Re: What do I think about Lua after shipping a project with 60k lines of code?

#58

Earlier quoted context omitted.

Roughly 60k lines more than my Helix config.

How do you configure awesome plugins for helix then?

I 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

Re: What do I think about Lua after shipping a project with 60k lines of code?

#59
post #29
post #10

Earlier quoted context omitted.

> With 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. True for any language really. There's an entire category of blog posts: "I used language X for 2 weeks and here's my hot take". Okay, great. But what do you really know? For every language I've used for a serious amount of time I've changed opinion over tim…

This is what makes Java underrated these years. Some annoying stuff pays off over a decade several times. You can make insane complexity with ease.

Java is a great language, and the JVM a great platform. I think that the thing which makes Java underrated isn't the language, but rather Java Developers. There are tons of great Java developers, but they are probably great developers in any language. But Java being the language of choice at so many enterprises results in a large number of very low skilled and inadequate Java programmers, who would be bad developers in any language, but specialize in Java.
Post reply on HN