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

My only context in using Lua is my neovim configuration, does any know of any good books or tutorials that make something more advance using only lua? Anything of note to consider/read/watch?


Shameless plug time: I have written a public domain book which looks at using Lua (Lua 5.1 but the code works in newer versions as well as Lua 5.1/Luau/LuaJIT) as a text parsing engine. The book assumes familiarity with other common *NIX scripting languages (such as AWK, Perl, or Python) and goes over in detail the pain points for people coming from a *NIX scripting background:

https://maradns.samiam.org/lunacy/SamDiscussesLunacy.pdf

Source files (.odt file, fonts used by book):

https://github.com/samboy/lunacy/tree/master/doc

Hope this helps!


Thanks for recommendation and writing the book! I'm reading the introduction, it doesn't answer why you chose to fork lua and create lunacy. What were you trying to solve with lunacy that lua couldn't do?

The TOC looks great, I will read this soon. Need to finish "Debugging CSS" first (another good book IMO).


The main reason I made Lunacy was to have a standard compile of Lua 5.1, since it’s possible to make a Lua 5.1 compile with, say 32-bit floats or which only supports integers but not floats.

Lunacy also has a few built in libraries which are not included with Lua 5.1, such as binary bitwise operations (and/or/xor). It also fixes some security issues with Lua 5.1 (better random number generator, hash compression algorithm which is protected from hash flooding attacks).

In addition, I have made a tiny Windows32 binary of Lunacy.

Don’t worry about the Lunacy changes; all of the examples in the book work with bog standard Lua 5.1 with a bit32 library (bit32 is common enough most OSes with a Lua 5.1 package also have a bit32 package for Lua 5.1).


Don't have tutorials or books, but I've had a ton of fun using Lua with LOVE2D [0] for gamedev, and also Redbean [1] for building super small portable web applications. Earlier this year, I built a mini CMS [2] inspired by rwtxt with Redbean.

[0] https://love2d.org/

[1] https://redbean.dev

[2] https://github.com/kevinfiol/beancms


Haven't heard of love2d but have heard of pico-8. I've avoided most game dev tutorials because they seem overly focused on beginners, which is fine, but want to find more advance materials that assume the reader knows some basics.

Maybe I should reconsider and dive more into game dev.


This series of tutorials might be of interest: https://github.com/a327ex/blog/issues/30

> It's aimed at programmers who have some experience but are just starting out with game development, or game developers who already have some experience with other languages or frameworks but want to figure out Lua or LÖVE better.

Also on the topic of game engines with lua scripting, the wonderful Defold always deserves a mention https://defold.com/


Definitely include Roberto's Programming in Lua book in your list. Specially if you'd like to script Lua together with C. The book has a good primer on the Lua-C api in its latter half.


I always wrote Lua off, scoffing at the 1-based indexing, until I was "forced" to learn it thanks to Neovim. What a delightful little language it is. I do wish I could do certain things less verbosely (lambdas would be nice) -- but then again, I defeat myself by suggesting it, because not having all the features makes Lua so approachable.


I used Lua professionally. I prefer the 1 indexing... it just feels more natural. For some reason the C apologists here will scream how 0 based is the only way to go. (which is not, it is just a historical artifact). Languages like ADA allowed you to use either 0 or 1, (or any arbitrary) starting index.


Same here, in fact something I wish the neovim team would do is create a book where popular plugin authors create tutorials that recreate basic functionality of their plugins.

Seems like a no brainer that would help bring in more revenue too, it'd also be an "evergreen" book as new others can contribute over time.

I can't be the only one that would immediately buy a copy. :D


I'm actually trying to work on a video-series to do just this. I've made my own rudimentary plugins reproducing several popular ones, and would like to walk through how I made: a) file-tree b) picker/fzf replacment c) hop/leap replacement d) surround plugin e) code-formatter f) hydra (sub-modes) g) many "UI" (interactive) buffers, etc.

None of these are published because the popular ones are better and provide more functionality, but I want to share what I believe is more valuable: what I learned while writing them.


That sounds great! Do you have a youtube channel or something to follow when you release it?


Yep, though I'm still trying to hit my stride recording videos. I don't release regularly because of lots of amazing $life things.

https://www.youtube.com/@nocturing

If you want a sneak peak of what I want to walk through, check this repo (see the examples/ folder): https://github.com/jrop/u.nvim


Lua has lambdas. They too suffer from verbosity, of course, but they're there.

    function(x) return x; end


There are patches for this so the above can be expressed with something like this:

  [ (x) | x ]
http://lua-users.org/files/wiki_insecure/power_patches/5.4/l...

And for Lua 5.1:

http://lua-users.org/files/wiki_insecure/power_patches/5.1/l...

(I personally don’t use patches like this because “Lua 5.1” is something pretty standardized with a bunch of different implementations; e.g. I wrote my Lua book with a C# developer who was using the moonsharp Lua implementation)


That's what I meant and didn't communicate well. I'm wishing for short-form syntax of lambdas, to be clear.


Take a look at Roblox, their market cap is almost 100B, they developed Luau and their game engine runs on it.

- https://luau.org/ - https://luau.org/why


I absolutely love Lua and I especially love when others discover Lua and are about to embark on the amazing journey.

Here, you're gonna need this:

https://www.lua.org/gems/




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

Search: