Live data from Hacker News

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

blog.luden.io

1–10 of 146 posts

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

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

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

#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 game built with Löve, for instance.

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

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

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

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

#9
post #7
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…

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

TypeScript is sort of "dynamically typed but statically verified".

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

#10
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…

> 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 time. Some things that seemed like neat ideas at the start turned out to be not so neat ideas down the line. Or things I considered pointless or even stupid at the start turned out to be very useful once I better understood the nuances and/or got used to working with it.

And of course it's double hard to judge will come back to haunt you a year down the line.

Even as an experienced programmer I find it hard to properly judge any of that from just a few weeks.

Post reply on HN