Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Author here. I'm delighted to see this is still interesting / useful to folks. In case anyone is curious, here's a short origin story for this tutorial.

I learned Lua for a game jam - during the course of the game jam itself. Like many, I found it a bit weird at first. 1-indexing feels wonky (you get used to it, though); now that I use Python all day, I would miss syntax shortcuts like list comprehensions going back to Lua.

When I was a kid, I learned C from a little pocket reference book while building little self-motivated projects. I still think this is the best way to learn - have a project in mind, and just enough fundamental examples to get you there.

I threw together the Lua tutorial mostly in one sitting, spending some time to edit, and going back and forth on how to keep the whole thing runnable while still explaining how external modules worked. Shortly after publication, Adam Bard contacted me with his idea for learnxinyminutes.com. I said great idea and ok'd the inclusion of the tutorial on Adam's site. Adam invited others to write their own similar-style tutorials, and his site grew up quickly.

Lua itself is a truly beautiful language, though I understand this is not a popular opinion. It's beautiful because you can learn the entire language, through and through, quickly. Memory and comprehension of the language itself get out of the way, so the only hard problems left are your decisions about what to do with the language. (You ask "How will I?" vs "How can I?") Instead of being feature rich through added features, it's feature rich through good language design. I expect some will disagree with me, but as one comparison point, consider the complete syntax of Lua:

https://www.lua.org/manual/5.1/manual.html#8

versus, say, Chapters 11-14 of the ECMAScript spec:

https://tc39.es/ecma262/#sec-ecmascript-language-lexical-gra...

It's not apples-to-apples - the ECMAScript spec is spelling things out in detail, while the Lua section is an overview - but it's still a thought-provoking contrast.



I'm working on a huge existing game dev project that is done in lua, and I can totally agree with you. The last project I did before this one was in, of all things, Typescript, so when I started to use lua I was quite weirded out by how simple it is... "What about type checking, async/await, list operations, refactoring, test coverage, and so on ?! How can I be sure that whatever I'm doing actually works?" But after just around 2 weeks on the project I started to realize that I basically already knew everything about the language and was already very productive on the project. Sure, I didn't have the same safety as with other languages, but I was churning out features and bug fixes, and constantly overestimating work.

Even though I don't think I would start a big project like this on such a simplistic language, I can't ignore the benefits it has. I guess at end of the day, you have to balance out not just how good and secure the code is, but also how quick it is to make changes to it and to onboard people to it.


> Lua itself is a truly beautiful language, though I understand this is not a popular opinion.

I think most people who actually use Lua come away marveling at its elegance and simplicity. The ones that don’t get stuck at “arrays start at 1?! What a garbage language!” In fact, this is a fairly good way to tell if someone has a well-reasoned opinion about Lua ;) (I will put up Go as a counter-example: “hurr durr no generics” is a meme complaint but it remains one once you actually use the language…)


I've used julia and lua and tend to think if people complain about indexes starting at 1 instead of C's offsets starting at 0, they can't be working on anything too difficult, because it just isn't a big issue in the grand scheme of things.


It's a very well designed language. Authors call this 'orthogonal design'; features like iterators, meta-tables and coroutines are independent and you mix and match those to produce architecture you need. It takes some hard work to design things orthogonally, to identify and isolate usable abstractions, and then put them together in a way that has no rough edges. It seems Lua has pulled it off quite well, with very little accidental complexity.

I'm amazed the language hasn't caught on more. It's perfect for education, as it is simple to learn basics and algorithm design. It's already used in some of most popular games (Roblox, Minecraft mods, WoW...) so there's established playground for children creations. Code flows like English language (which is bad for advanced users but perfect for kids). I'd say it's more suited for education than Python because it is simpler and more transparent.

The things missing are tooling and documentation. There's only single popular IDE. The Programming in Lua book is awesome read (I'd recommend it even to non-Lua developers), but it's not a good language reference. The reference itself is quite useful but sparse on examples. I wish there was clojuredocs.org for Lua, community-sourced examples are amazing idea.


Yeah, based on the low quality of the lua wiki I've started using the reference manual as my source for anything that ships with the language, but the reference manual just doesn't fully specify how a bunch of built-in functions work...


‘walternate’ as in Fringe?

https://en.wikipedia.org/wiki/Walter_Bishop_(Fringe)

PS. Love Lua, TY for spreading the learning.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: