Newspeak on Bitbucket

2009-07-20 22:00

I pushed all code of Newspeak on Bitbucket. And I got a new domain for Scala (and Java) because I don’t like “package info._8_p { …”.

Newspeak don’t use Lift. Instead I choose Jetty 6, Tokyo Cabinet and my Amrita-inspired template engine.

Jetty 6

Newspeak uses Jetty without XML. Here is my main function:

  def main(args: Array[String]) = {
    val app = new waf.Application

    app.mount("/", (req, resp) => {
      render("index", Map("title" -> "Newspeak"))
    })
    ...
    app.run(8000)
  }

My application code depends javax.servlet.*, not Jetty. But waf.Application runs Jetty internally.

Tokyo Cabinet

Tokyo Cabinet is modern impl. of DBM. I use “table” database as a primary persistent layer of Newspeak. TC has JNI-based Java API. It’s easy to use from Scala off course.

And TC provides very handy tctmgr (1). I mostly uses “tctmgr importtsv” to built my database. However Newspeak’s database stores commit logs. And commit logs usually contain “\n”. It’s not suitable for TSV.

So I wrote JSON based import command in C++. It uses a picojson as a parser.

Amrita-inspired template engine

Many template engine handle HTML/XML as just a string. I think it’s bad design. But Amrita is not. My template engine is inspired from Amrita.

Conclusion

Scala is good.

Recently, I mainly uses a “dynamic” language (ex. JavaScript, Ruby and Perl). Dynamic language is easy to write, but hard to debug. “Static” language is hard to write, but easy to debug because many bugs are reported by a compiler. It’s fresh to me.

Leave a Reply