We received a lot of entries that were pretty great, but we only had so many prizes to give out. Here are some honorable mentions that we still want to share.
Yesno - Thomas Eding
Yesno was the only entry written in Haskell. Language choice itself isn’t interesting, but if you’ve ever touched Haskell, you wouldn’t expect to see code like this:
main <- function int $ \() -> do {
time_t_ seed <- time(0);
srand(static_cast<unsigned_int>(seed));
int_ n <- rand();
int_ randmax <- readIORef(_RAND_MAX);
int_ randmax2 <- runInstruction$ randmax / 2;
if_(n <= randmax2) {
printf("%d\n", 0);
}
else_{
printf("%d\n", 1);
};
return 0;
}
What Thomas did was add a file called Cppify.hs
which declared functions and preprocessor directives which allowed him to approximate C-style syntax from inside of Haskell.
Thomas wins the Worst Abuse of a Functional Language award, and his prize is whatever is in his pockets right now, plus bragging rights.
DME - stahlratte
This solution has a Decider server, a Decider client, and a Decider Hub for tying all of these together over XMPP. That’s pretty nasty for starters, but it gets better.
“For safety reasons,” stahlratte explained in his entry, “there is an unhackable Serialization protocol implementation.”
What does that serialization method look like?
public function serialize():String {
return "INSERT INTO Object (msg,delay) VALUES ('" + this.msg + "'," + this.delay + ")";
}
And how do you deserialize a message?
public function parse(msg:String):Msg {
var cnx = sys.db.Sqlite.open(":memory:");
cnx.request("
CREATE TABLE IF NOT EXISTS Object (
id INTEGER PRIMARY KEY AUTOINCREMENT,
msg TEXT,
delay INTEGER
)
");
cnx.request(msg);
var rset = cnx.request("SELECT * FROM Object");
neko.Lib.print("Found "+rset.length+" Objects");
for( row in rset ) {
neko.Lib.print("Object " + row.msg + " hs delay of " + row.delay);
var m:Msg = new Msg();
m.id = row.id;
m.msg = row.msg;
m.delay = Std.parseInt(row.delay);
cnx.close();
return m;
}
Everything about this method is wonderful…ly bad.
stahlratte wins the Order of the Pink Bear. His prize is free download of any open-source Jabber client he likes.