Montag, 22. August 2011

Bottleship: Scripting Woes

What happened so far? Work on the client/server skeleton is finished. The client can now authenticate with the server, and there's a minimal chat client in place that allows all participants to communicate.

I tried both Lua and NodeJS for the server implementation, but finally settled with C++ and Boost.Asio, mostly because that eases sharing code between client and server application. I'm using Redis as a Database backend, and we'll see where that gets me.

The part I'm now working on is the actual creation part. I figured I'd start with a really simple primitive, a quad, on which to get a better understanding of how to implement the network synchronization, database storage & broadcasting infrastructure.

I wanted the tool with which the player is placing the quad in the world (nicknamed "The Billboarder") to be implemented in the magic script language already, to figure out how players could write their own tools.

I started off with an implementation in Lua, using Luabind, but kept having concept issues. I had yet to figure out how to terminate a CPU-hungry script or pass security contexts around. There was also no guarantee that each Lua context was perfectly sandboxed. I had to basically reimplement half of the base library myself to build a whitelist of functions that were allowed to use. To top it off, Lua has an unusual syntax, and I was wondering if maybe something more popular would feel more right.

I moved from Lua to Google's notably fast V8 JavaScript engine, which is written in C++, very well thought out in terms of security/access contexts, memory handling and parallelization. Unfortunately, while there are rather nice boost::python like C++ templates for binding Lua, there is no such thing for V8: V8-juice and V8Convert are just plain weird and cproxyv8 comes close, but is incomplete. I've spent the entire Sunday writing my own set of boost::python style bindings, and it's just no fun, because I want to get done with the actual task at hand, not despair on some shitty ass template metaprogramming.

So, as it seems, I'm going to have to write the bindings using V8 only, by hand, with a handful of helper functions. It sucks, but there is really no other way.

Keine Kommentare:

Kommentar veröffentlichen