2 Transparent Client-Server Programming With Opa
In this chapter we’ll turn our attention to Opa. Opa sits right in the intersection of all of the themes of this book. In fact, Opa itself was what first spurred my thinking on toward what later became this book. Opa is described on its website as being a "framework for JavaScript", but this is a slightly misleading statement. Opa falls in among the growing ranks of languages that compile to JavaScript and so Opa-the-language is something other than plain-old-JavaScript. But far from being a drawback, this frees Opa to add many great features that would be hard or impossible to implement just as a JavaScript library. Opa features many of the 'Transparent Web' characteristics: a single language for both client and server, a static type checker, a database domain-specific language, and a healthy dose of functional programming.
Before diving right into reading an Opa app, let’s cover the basics of the language. The good news is that there are lots of syntactic similarities to JavaScript. So at least on the surface, Opa code will resemble what you may already be used to seeing. In many ways, you can almost pretend that Opa is a souped-up, super-JavaScript. The differences between Opa and JavaScript stem from Opa going some extra lengths to catch many errors at compile-time.