Monday, June 13, 2011

opaque: blogging software written with Opa

A week or two ago, I was invited to the Opa private beta. Opa is basically a statically typed functional programming language designed for writing web applications. Yes - Opa is a programming language. And it's more than just that - Opa includes its own database server, as well as its own HTTP server. As a result, when you write programs, the result of the compiler is a single executable file that you can run and have 'just work.' Furthermore, when coding, both client-side and server-side code are written using the same language, and code that runs on the server is compiled to native code, while client side code is compiled to JavaScript. Another selling point of Opa is that you can automatically scale it across multiple machines and use a HTTP load balancer along with it (currently haproxy.) There is nothing special involved in doing this. You just have to run your executables using opa-cloud, and it'll "just work." This also applies to the database, and even real-time client-side updates that may be posted to all current visitors.

I also recently signed up for projectaweek, a small movement started by Mark to try and emulate the ferocious productivity of Don, and the goal is simple - to release 1 project a week, no matter if it is incomplete or partially busted, but it can't be late. So I put the two together, and decided to write something over the past week using Opa. The result is some simple blogging software that I've named opaque.

Right now it's pretty primitive. It displays posts though, and you can read it, and that's what counts! But it does have:

  • Syntax highlighting (via SHJS)

  • MathJax support (via MathJax CDN)

  • Markdown support for entries (via upskirt)


Which I think are pretty necessary for anything that's to be taken even remotely seriously.

I was ridiculously happy with how easy it was to write, honestly. The trick is that you can write programs which are, in reality, asynchronous or stateless between client/server, in a nice, imperative/functional style, and the compiler just "does the rest" and transforms it appropriately. Also, because you write client and server side code in the same language, you get type checking on both client and server side, and so the compiler can eliminate certain classes of errors between the two. Opa's type system apparently is apparently a bit more powerful than say, ML or Haskell's, and lacks the existence of principal types (and thus may require some type annotations,) but overall the amount of type annotations needed is nearly zero. At least in my case. The compiler can also apparently catch other classes of errors, but I haven't looked into it, nor the type system (it'll have to wait for source code to be released.)

Opa isn't publicly available at the moment - it's an invite only preview. Source is coming. And it's very much worth noting that once the source is released, it will be AGPLv3, meaning any apps even written with Opa will need to be licensed under the AGPLv3 as well, unless you buy a license from MLState.

I have some invites still available for the Opa preview, before it goes open source, so you can try it before then. Feel free to contact me if you'd like one. I'll also probably be writing a little bit more about Opa up here with some examples, as well as a comparison between it and the formidable Ur/Web.

Now it's time to go play The Witcher, as I've clocked in my project this week.

No comments:

Post a Comment