Using Lua with C++
edw.is
Using Lua with C++
1–10 of 43 posts
Re: Using Lua with C++
#2Having tables as the primary underlying data structure gives it a very LISP-y feel despite having an ALGOL syntax, providing a nice middle ground between the two styles.
Re: Using Lua with C++
#3Lua is a joy to work with, one of my favorite (scripting) languages. Having tables as the primary underlying data structure gives it a very LISP-y feel despite having an ALGOL syntax, providing a nice middle ground between the two styles.
I've done quite a few projects where I built a library of C modules to do the heavy lifting for some particular purpose (data in/out mostly), glommed these functions into the LuaVM, then built the application logic, very rapidly and smoothly, in Lua - outcompeting others working in my group with their big fancy stacks of stuff, time and time again.
I think its really important for any developer, whether they are encased in the glories of the browser or otherwise, to understand how to add the Lua VM - to anything - and then use that as a means of productive application development.
Its very rewarding once you get the VM glomming happening and can start accessing everything you need from within your own scriptable execution environment. More programmers should learn this technique, imho - it moves us from being effected clients of someone elses' ball of string and wax, to actually causative developers building architecture that really, really works.
Whether you like Lua or not, building-in a VM for your higher-level application logic is just good architecture.
Re: Using Lua with C++
#4Lua is a joy to work with, one of my favorite (scripting) languages. Having tables as the primary underlying data structure gives it a very LISP-y feel despite having an ALGOL syntax, providing a nice middle ground between the two styles.
Lua really is a joy, and after 40 years of software development is still one of the top ways, in my personal list, to get serious software built. I've done quite a few projects where I built a library of C modules to do the heavy lifting for some particular purpose (data in/out mostly), glommed these functions into the LuaVM, then built the application logic, very rapidly and smoothly, in Lua - outcompeting others wo…
Re: Using Lua with C++
#5Earlier quoted context omitted.
Lua really is a joy, and after 40 years of software development is still one of the top ways, in my personal list, to get serious software built. I've done quite a few projects where I built a library of C modules to do the heavy lifting for some particular purpose (data in/out mostly), glommed these functions into the LuaVM, then built the application logic, very rapidly and smoothly, in Lua - outcompeting others wo…
I discovered this technique only a few months ago, and couldn't agree more. I also cannot believe I've missed out on it for so long, having been a software engineer professionally for 13 years now, with 10 years of computer science specific education before that. How is this not taught in every computer science curriculum?
If anyone reading this wants to see what the fuss is, you can get started very easily with antirez' (Redis fame) simple toy project, LOAD81 - which is a great example of just how powerful things can get when you bring Lua into your life. (http://github.com/antirez/load81.git) - note that this is a great project to learn this technique, but if you do anything interesting in the load81 context - please push it back to LOAD81. :)
Re: Using Lua with C++
#6Re: Using Lua with C++
#7Earlier quoted context omitted.
I discovered this technique only a few months ago, and couldn't agree more. I also cannot believe I've missed out on it for so long, having been a software engineer professionally for 13 years now, with 10 years of computer science specific education before that. How is this not taught in every computer science curriculum?
I think it once was taught, but was considered passé in various places during the "Java" revolution, and in general I think there is a degradation of capabilities in most comp-sci programs, a consequence of interference by market players who invest in the schools in order to keep their technologies relevant. If anyone reading this wants to see what the fuss is, you can get started very easily with antirez' (Redis fam…
[1] https://www.oreilly.com/library/view/creating-solid-apis/978...
Re: Using Lua with C++
#8This is the only part of the article I disagree with. I've found that the biggest problem with using Lua in a C++ game is writing code in the "wrong" language, and the mess that can cause. The boundary between Lua and C++ needs solid validation to keep bugs out, and this makes it neither performant nor convenient, so minimising the boundary is important. As soon as code ends up in the wrong language, you generally need to add a large amount of unnecessary boundary code.
An important part of designing a Lua/C++ game for me is having a good mental model of what the "right" language to write any piece of code in is, and only deviating from that when performance mandates.
Re: Using Lua with C++
#9This in practice means you have to use Array of 64 byte Structure for your shared data.
Lua is not going to change that. You can hot-deploy C with a .so/.dll without losing performance.
Re: Using Lua with C++
#10Lua seems to be widespread in games, but in fact is a very nice tool to make day-to-day apps user-extendible (with neovim and mpv being a couple of examples).
A recent project involved doing fluidic particulate quantification in an embedded, field portable instrument, which was delivered on time and under-budget - and represented a major revenue source for the customer (40 million dollars worth of orders) when it was shipped. The client was told it "could not be done" with the hardware as specified - not only did we do it with Lua, it has since been widely recognized as the most advanced bit of architecture the company has implemented for its instruments ..
Lua is not just for games. Games are a good place to learn Lua, though.