Opa is an open source programming
language for developing scalable web applications.
It can be used for both client-side and server-side
scripting, where complete programs are written in Opa and subsequently compiled
to Nodejs on the server and JavaScript on
the client, with the compiler automating all communication
between the two. Opa implements strong, static typing, which can be
helpful in protecting against security issues such as SQL injections and cross-site
scripting attacks.
The language was first officially presented at the OWASP conference
in 2010, and the source code was released on GitHub in June
2011, under a GNU Affero General Public License. Later, the license
changed to the MIT license for the framework part (library) and AGPL for the
compiler so that applications written in Opa can be released under any license,
proprietary or open source.
Opa consists of a web server, a database and distributed
execution engine. Code written in Opa is compiled to JavaScript using Node.js on
the server side and to JavaScript using jQuery for
cross-browser compatibility on the client side. The advantage of the
approach compared to certain Rich Internet Application (RIA)
platforms is that users are not required to install a plugin in their browser. Opa shares
motivations with web frameworks, but takes a different approach. Its designers
assert that this helps Opa to avoid many security issues, like SQL
injections or cross-site scripting (XSS) attacks.
The core language is functional and has a static type system with type
inference. Opa also provides sessions which encapsulate an imperative state
and communicate using message passing, similar to Erlang processes.
Opa provides many structures or functions that are common in web development,
as first-class objects, for instance HTML and parsers, based on Parsing
Expression Grammars.Because of this adhesion between the language and
web-related concepts, Opa is not intended for non-web applications (for
instance desktop applications).
The 0.9.0 release in February 2012 introduced database mapping technology
for the non-relational, document-oriented database MongoDB, similar to object-relational
mapping. The 1.1.0 release in February 2013 also added support for PostgreSQL,
paving the way for the support of several SQL databases.
Examples
Hello world
The traditional Hello world program, producing a web server that
serves a static page with "Hello, web!" as its content, can be
written in Opa as:
Server.start(Server.http,
{ title: "Hello"
, page: function() { <h1>Hello, web!</h1> }
}
)
It can be compiled to a stand-alone executable JS file with:
$ opa hello_web.opa
Running the resulting executable JS file launches the web application:
$ ./hello_web.js
Top 10
Reasons to Develop with Opa
1. One Language to Rule
Them All
Write simultaneously the frontend
and backend code, in the same language, within the same module. Even
better: the Opa Slicer automates the calls between client and server. No more
manually written AJAX calls or value serialization!
And when auto is not
enough, add hints to the code to enforce client or server-side, privacy,
synchronous or asynchronous.
2. Access All JavaScript
Libraries
Opa generates and is fully
compatible with standard JavaScript code.
Reuse tons of existing
JavaScript libraries and frameworks, such as JQuery which is by default part of the standard library.
3. Robust Runtime
Opa generates JavaScript
on the server too, using Node.js and MongoDB.
Applications built with
Opa can be deployed in most cloud straightforwardly and scaled up or down
easily.
4. Database Automation
Database queries are
also written directly with Opa.
Opa currently supports both the
SQL database PostgreSQL and NoSQL databases MongoDB and CouchDB. More databases are planned for future releases.
Opa provides many unique
advanced operators and automates the database queriesfor maximal
productivity.
5. Typechecker
Opa unique feature is
its advanced typechecker that automatically verifies your
application code, looking for bugs and inconsistencies, and crunching debugging
time.
The Opa Type Checker was
designed to bring static verifications to dynamic programming experience. Type
checking is incredibly fast and features type
inference: Application code stays lean and clean.
6. Truly Non-Blocking
Modern applications use
a lot of asynchronous calls. Dealing with callbacks manually can be painful,
and failing to do so properly blocks the application runtime.
To make asynchronous
programming easy without blocking the application, Opa-generated JavaScript
code uses smart continuations.
In the following example
the Opa compiler automatically takes care of everything.
7. MVC Support
Opa support MVC
(Model-View-Controller) programming and provides a scaffolding mechanism to get
started instantly.
Just minutes away from
creating a real application.
8. HTML5 Native Support
Opa is built for the
modern web. HTML5 fragments can be inserted directly. No more
messing with single and double quotes!
CSS(3) elements
including selectors are also easier than ever to use.
9. Powerful Syntax
Opa is JavaScript on
steroids with many syntax and feature enhancements.
Database, types,
pointers, autoclose, higher-order functions, etc. The list is way too long to
fit here. Find it on the reference card.
10. Power Rows
The core of Opa uses
Power Rows: A powerful, statically-typed, extension of JavaScript objects.
Power Rows is one of the features
that makes Opa safe and fun at the same time.
For more information, please visit, www.programmingyan.com
No comments:
Post a Comment