r/lua • • Nov 01 '25

Does anyone else use lua as their main language for system automation and shell scripting?

it's no secret that Lua is heavily underrated. ironically, i used to be against lua until i understood how nifty it is as a language. i formerly thought that one had to use index or metatable to create objects, only to find out that i could do this

```

function NameOfObject(instanceVariable1, instanceVariable2)

return{

method1 = function(self)

end,

method2 = function(self)

end,

method3 = function(self)

end,

}

end

```

and just like that it overtook the appreciation i had for how objects can be created in other languages.

in a less subjective sense, however, given how ridiculuously fast lua is compared to the bulk of languages that are interpreted, i committed to it for all my scripting needs.

lua has now become my premier choice for automating anything related to my environment: my file system, my window manager, and even my system settings. it also greatly helps that i can automate repetitive and tedious text editing in neovim with lua as well.

i formerly used python for my scripting needs, and in retrospect, it's rather comical to me how poor python is as a scripting language compared to lua; it's a night and day difference. i can always trust lua for a startup time that is as good as instantaneous, whereas such a thing would be a fool's game in python.

granted, python does have all the abstractions one can hope for, but for system tasks, it's just outright overkill. one does not need a gazillian abstractions for system admin or shell scripting needs

anyways, i've rambled long enough. is there anyone else that uses lua for shell scripting needs and system automation, as opposed to roblox, C programming, game dev, and other low level tasks?

75 Upvotes

61 comments sorted by

View all comments

Show parent comment

3

u/GrainTamale Nov 01 '25

Check out subprocess.Popen. I don't think os.execute is deprecated or anything but it sure isn't preferred.

1

u/RiverBard Nov 01 '25

Will do! How does that differ from io.popen? A quick search doesn't show it in the Reference Manual. I just started using Lua for this earlier this week.

2

u/GrainTamale Nov 01 '25

Lua's io.popen opens files for read/write, while Python's subprocess.Popen spawns processes

2

u/lambda_abstraction Nov 04 '25

Eh? Io.open opens files. Io.popen starts a process and returns a read or write pipe to that process.

1

u/RiverBard Nov 01 '25

Oh I thought you were referring to a Lua function, I thought it was odd that it was capitalized! 

I'll still check it out though, I haven't really used Python for system scripts.