logoalt Hacker News

vascocostayesterday at 12:51 PM6 repliesview on HN

For me Lua, from a minimalism point of view, feels like the Go of dynamically typed languages.

I love how you can acquire the language easily within a very short period of time (apart from some idioms, which like in other languages take more practice). I appreciate the low number of keywords and that you have only one real way to structure data, through tables. Yet, you can use meta tables to "emulate" classes as blueprints for object creation and even inheritance, if you really need OOP, or for that matter other paradigms. In a way this reminds me of JavaScript prototypes.

As an indie game dev, Love2D really clicked. Lua is awesome as a scripting language inside a host language like C/C++/Rust, because it is simple, intuitive (both for imperative or functional styles) and rather fast.

I'm even using it as my go-to scripting language for the Linux CLI instead of Python. Python, as great as it is, feels sometimes too comprehensive for small scripts. I like to script using a language I can fully keep in my "working memory", without having to refresh my memory about some constructs/idioms. That said, I use Rust as my main statically typed language, so maybe I'm just finding excuses for my love for Lua...

I also think Lua is underrated as a possible first language. Its simplicity, readability and details like using keywords for blocks (do, end, etc) IMO make it suitable for beginners.


Replies

widdershinsyesterday at 1:04 PM

I agree on all points, especially the idea of using Lua as a first language. It has so few features that you're really forced to focus on fundamental concepts like functions and (simple) data structures. And its flexibility to be used in an imperative or functional manner is great too. It's almost like a stripped back Javascript, and anyone who learns it will find jumping to JS easy.

I guess one might argue that 1-based indexing could cause beginners to get confused when they move to another language. But maybe it's good for them to get used to the idea that things like this can be different across languages.

show 4 replies
rng-concernyesterday at 9:23 PM

For every new language I learn, there's a task I eventually want for various purposes, and that's to use whatever reflection system that is available to traverse data structures in memory, and at the very least, dump a log of those structures to a certain depth.

C# took about 2h to do this acceptably. Javascript took 4h or so and I'm still not happy with it. Too many warts and odd ways of accessing arrays etc...

Lua took 30 minutes and it just worked perfectly. There was nothing left to do. it's just so simple.

I love that about it.

jchwyesterday at 2:36 PM

In my opinion, Lua would kill for many use cases... If it had a bigger standard library, and batteries-included module/packaging system. I know LuaRocks exists, but it doesn't seem terribly common.

Types/type checking would also be nice. Luau does seem to offer some level of static typing, but it isn't used by a whole lot that I've seen.

That said, I think a lot of people are also glad it doesn't include much, because one of the biggest draws of Lua is that it's extremely compact and embeddable. And I do understand that, too. I remain a huge fan of Love2d even though I haven't actually released anything with it.

show 3 replies
johnisgoodyesterday at 1:10 PM

I love Lua (LuaJIT is great for many reasons, I love its FFI and its high efficiency), and Go, they are simple and easy to be productive in them, for sure.

vkazanovyesterday at 1:19 PM

Lua is definitely a likeable language and due to its (very) limited nature can be used as a first language.

But as a Linux CLI lang, or for simple one-off scripts... Python is better. Scripts (and also competitive programming) favour languages capable of compact solutions and universal stdlib. Lua, because is has no stdlib to speak of and a limited amount of syntax sugar. It is just so much less useful for these purposes.

As for competitive flavours of programming... I recently gave it a go for Advent of Code 2024.

My impressions: https://www.reddit.com/r/adventofcode/comments/1hvnou1/2024_...

My repo: https://github.com/vkazanov/advent-of-code-2024?tab=readme-o...

TL;DR Python is better here.

show 2 replies
timewizardyesterday at 9:35 PM

I feel like most languages are easy to learn. There's only so many ways to write a parser.

It's the standard library that forms the "grammar" of the language and is often the hardest part to incorporate.