Archive for the ‘Languages’ Category

Token Filters for Lua

Sunday, September 17th, 2006

In an attempt to at least get a chance at making those haughty Lisp fanatics shut up for a minute about their macros, people have been playing with a patch for Lua which will make some of the same tricks possible: token filters. The idea is that you register with the Lua interpreter your own Lua function which gets the chance to examine and modify the token stream for any subsequent pieces of Lua code that get to be executed. Your function gets called for each token and outputs one or many tokens, but thanks to the tricks made possible by Lua coroutines, you can pretend that you can simply get() any further tokens you need and put() them to the output stream at your own pace.

Of course, this is much more inconvenient than Lisp macros, because a token stream is an order of magnitude harder to examine and make intelligent decisions upon than the no-syntax S-expressions of Lisp, but still, it’s a nice hack. People have started doing truly interesting/useful things, like this function parameter checking facility.

The main problem I see is not with the awkwardness of the token stream mechanics; if this catches on, I think sensible frameworks which allow work with higher-level Lua constructs will emerge. The problem is with the uber-simplistic Lua compiler, which does virtually no optimizations. Most often than not, the idea of macros (and other metaprogramming techniques, such as template metaprogramming in C++) is to introduce simpler syntax for things which will be expanded/calculated, then most of the inefficiency will be optimized away, and all that will happen at compile time. With Lua, there’s nothing to optimize your code, so often you’ll have nothing to gain by running some calculation at compile time instead runtime. And the lack of optimization is a feature - it comes with the “tiny, simple, embeddable” part of the Lua bundle.

Iron Lua, please!

Thursday, September 7th, 2006

Via Let’s Kill Dave come the news that Iron Python 1.0 is out. And you could even use it to build XNA games, as it compiles to the same MSIL that C# compiles to.

Python is sooo 2004, however. Lua’s where all the cool kids, sorry, responsible game developers are. Several years ago His Moonness, Roberto himself, had worked on a CLR incarnation of Lua; maybe it’s time to dust it off, bring it up to .NET 2.0 and Lua 5.1, and release it. For great justice.

Io

Friday, November 11th, 2005

Via Lambda The Ultimate comes news about Io, A new language in the Lua space - extremely small and meant to be embedded. Seems to be more advanced in the freaky language designer sense, and therefore much, much weirder. Comes with interesting built-in support for coroutines, concurrency, built-in futures, possibility of run-time code modification a ls Lisp, and claims to be comparable in performance to Perl/Python/Ruby. My intense dislike for Lua may make me try it out for real one day.

(Io, as in the Jupiter moon, not as in the blind-but-not-quite father of the gods in Terry Pratchett’s Discworld.)

Herb Sutter’s Concur

Thursday, November 3rd, 2005

Via DeanoC, a most intriguing lecture by C++ archluminary Herb Sutter on Concur, a project to explore concurrent programming paradigms above the current model of threads and locks. When do we get the compiler?