Quote:
Originally Posted by Mk.32
I am a bit confused, how did you guys run Lua on our robots?
|
Greyhound Lua. It has been
discussed before.
The gist is that the Lua interpreter is off-the-shelf code written in clean ANSI C. It compiles with minimal modification under WindRiver, and with some SWIG bindings to grant access to WPILib. It is released under an open source license and is free for other teams to use.
Quote:
Originally Posted by F22Rapture
The choice of Lua is interesting -- what advantages and disadvantages does it afford you over Java/C++/Python?
|
All of what Adam said plus:
The edit/compile/run cycle is dramatically reduced, as BigJ pointed out, but even more than that, the barrier to experimentation is much lower. Students can try out snippets of code in an interactive interpreter and develop on practically any OS, since the Greyhound Lua interpreter only needs to be compiled once. We don't need to develop in WindRiver, so we have students that are using Ubuntu, Mac, Windows, vim, gedit, and Notepad++.
From a teaching perspective, the language of Lua also lends itself to procedural programming, which is easier to demonstrate and reason about for new students. Gone are the discussions of memory management, inheritance, and NULL pointer crashes. Lua instead builds from combining simple concepts. For instance, we can re-bind controls using
closures inside a table.
I've been asked by people inside and outside FRC whether the use of Lua in FRC is a good idea. Their concerns vary from runtime performance to software engineering best practices (usually phrased as "Lua isn't a real language"). If I (as a mentor) were the only one writing the code, you can bet I would be using C++ because the syntax doesn't bother me and the static typing and performance help me during development. But it isn't about me; it's about the students. I've made sure to explain to the new students what the tradeoffs are and why the decision was made. Should all teams be using Lua? No, but it meets our needs, and ultimately, the choice of programming language in a software project does not matter. The real question is: "is your team productive?" And after the last two seasons, I think the results speak for themselves.
On a sidenote, the Python port didn't come until after I finished Greyhound Lua, and IIRC it uses the SWIG bindings I wrote. I initially tried porting Python, but found that the effort required exceeded the amount of time I had before the 2011 season started.
tl;dr: Lua fits our needs.