The LuaInterface library seems to be prone to crashing. Just as importantly, there is no way for FreePIE to prevent these crashes. The latest issue are buffer overruns smashing something deep in CLR land, and there just is no recovering from that. That I know of.
Thus, I've been looking at alternatives. First I looked for another, fully managed Lua library, but support doesn't seem overwhelming. After that I considered writing a Lua lexer and parser and transform Lua -> C#, and dynamically JIT it into an assembly. I like this idea, any generated code lives 100% inside the CLR, better error handling support (native exception support for one), and probably a healthy speedup to boot.
(you can skip ahead till after the code example if you want - you'll only miss a few technical deliberations)
While it would be fun to develop, there are many kinks to workout. Most of them could probably be worked out, but there is bound to be some impedance mismatch between Lua and C#, not the least of which is that Lua is dynamic and C# is mostly not.
CyberVillain flippantly asked 'why go to all that trouble when you could just use C# directly?'. It's got some merit, no impedance mismatch, no transformation, no parsing. Just some minor hassle with making the user experience a REPL-ish interface.
That's when I found Roslyn. It's the microsoft-implemented replacement for the current C# and VB.Net compilers. It is complete with syntax analysis (basically giving us intellisense for free), compilers and most importantly: a ready-to-go scripting engine.
I've fiddled around a bit with it, it's actually in a local feature branch of FreePIE, and it's up and running. Very easy, but this was just a spike to figure out if it's feasible or not. To give you a taste of the syntax (this works right now):
Code: Select all
if(starting)
trackIR.Update += (s, args) => diagnostics.watch(trackIR.Yaw);
In the near future Roslyn will provide support for the dynamic keyword and everything that entails - which means that the syntax can be even more script-like:
Code: Select all
x = 10;
y = x + "hello";
Roslyn is .net 4.5. That version of .net doesn't run on XP. How many out there are using XP? Can we drop support for it?
Latest update:
Roslyn and C# is scrapped as scripting language. Python is now implemented however, and the code is for now available at https://github.com/maxmalmgren/FreePIE/