5 ms·
Lua has been used a lot for that kind of embedding in the past. I think because it's easy to move data between Lua and C? Python would certainly be a big step u
by nilsbunger 4y ago
Lua has been used a lot for that kind of embedding in the past. I think because it's easy to move data between Lua and C? Python would certainly be a big step up but I don't know how hard that kind of integration is.
- Waterluvian 4y agoLua is a great language for game scripting. Perhaps that’s a better option.
- 0xffff2 4y agoWhy is it such a great language? As a developer entirely divorced from the gaming industry aside from occasionally dabbling in modding, lua has always seemed completely inscrutable to me when I have encountered it.
- Tyr42 4y agoThe C API is pretty straightforward and has a stack object to avoid lots of reference counting you would need with Python's c API. It's also a tiny codebase which is easy to vendor and ship.
- agentultra 4y agoIts obscenely easy/consistent memory layout. It makes embedding it into another application straight-forward and easy to manage. Extending the host interface to the embedded scripts is very simple because of this. It's also serialize-able to a degree. Python is also a decent glue language but creating a Python interpreter is a bunch more work and the API is a bit harder to work with.
- guipsp 4y agoLuaJIT is insanely good
- elfprince13 4y agoI think the main attractions are that it has pretty minimal syntax + core libraries, does a good job binding to C FFIs, and the interpreter is fast.
- schemescape 4y agoIt’s a tiny but capable language that’s easy to embed, and can be surprisingly fast with LuaJIT.
- kzrdude 4y agoThey have a clean API for embedding. All Lua interpreter state is kept in a struct that you alloc. If you alloc two distinct structs, you have two completely independent Lua vms and you can run them on independent threads if you want to no problem, and so on. (Few language runtimes are clean in this way.)
- cozzyd 4y agoyes, python is basically impossible to embed in a multithreaded app.
- outworlder 4y agoInscrutable? The language is _tiny_ (and kept that way on purpose) Aside from stuff like metatables(which may require you to play around for a bit to understand their value), you can pick it up in a couple of hours. I'm not even kidding. So much so that you see people modifying code without even looking at documentation. https://www.lua.org/manual/5.4/ https://www.lua.org/manual/5.4/ https://learnxinyminutes.com/docs/lua/ https://learnxinyminutes.com/docs/lua/
- v3ss0n 4y agoLua is most hated lang
- deleted 4y ago[deleted]
- w0m 4y agoIt seems reasonable in my ~300 line neovim config :D and yes; i know that's a ridiculous example that's not really comparable for anything significant.
- zemo 4y agodo you work in games
- outworlder 4y ago> Lua is most hated lang Impossible. Most developers outside the games industry don't even know it exists. ... and if they knew about it, they would use it much more.
- bsder 4y agoSorry, Lua is not simply not a great language. The first problem is "Which Lua?" Lua, by itself, is almost completely useless. You first need to compile/install a bunch of things in order to make Lua useful. This has the Perl problem that everybody uses a different dialect of Lua. The second part is that the Lua constructs for programming in the large are very weak. I believe that Adobe had a postmortem about this (Lightroom, I think?) And then there is the language, itself. For me, the 1-based indexing is death in this day and age. Sorry. Zero-based is the dominant ecosystem and not fitting into that is simply not acceptable.
- tomodachi94 4y ago> You first need to compile/install a bunch of things in order to make Lua useful. How is this any different from pretty much any language out there? From a quick eyeball of RustPython's Cargo.toml[1], there are about 70 different dependencies which all need to be compiled. I haven't worked too much with Autoconf, but I am pretty sure CPython has quite a few dependencies. [1]: https://github.com/RustPython/RustPython/blob/main/Cargo.toml https://github.com/RustPython/RustPython/blob/main/Cargo.tom... > The second part is that the Lua constructs for programming in the large are very weak. This is deliberate because it forces you to use the tools you are given instead of reimplementing features that can already be implemented by using other primitives in Lua. > I believe that Adobe had a postmortem about this (Lightroom, I think?) I can't find this article. Has anyone else had any luck?