Opa (programming language)
Encyclopedia
Opa is an open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 for web applications.

The language was first officially presented at the OWASP
OWASP
The Open Web Application Security Project is an open-source application security project. The OWASP community includes corporations, educational organizations, and individuals from around the world. This community works to create freely-available articles, methodologies, documentation, tools, and...

 conference in 2010, and the source code was released on
GitHub
Github
GitHub is a web-based hosting service for software development projects that use the Git revision control system. GitHub offers both commercial plans and free accounts for open source projects...


in June 2011, under a GNU
GNU
GNU is a Unix-like computer operating system developed by the GNU project, ultimately aiming to be a "complete Unix-compatible software system"...

 Affero General Public License
Affero General Public License
The Affero General Public License, often abbreviated as Affero GPL and AGPL , refers to two distinct, though historically related, free software licenses:...

.

Design and features

Opa comprises a web server, a database and distributed execution
engine.
Code written in Opa is compiled to native code on the server side and
to JavaScript using jQuery
JQuery
jQuery is a cross-browser JavaScript library designed to simplify the client-side scripting of HTML. It was released in January 2006 at BarCamp NYC by John Resig...

 for cross-browser compatibility on the client
side.
The advantage of the approach compared to Rich Internet Application
Rich Internet application
A Rich Internet Application is a Web application that has many of the characteristics of desktop application software, typically delivered either by way of a site-specific browser, via a browser plug-in, independent sandboxes, extensive use of JavaScript, or virtual machines...

 (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.
This helps Opa to avoid many security issues, like SQL injection
SQL injection
A SQL injection is often used to attack the security of a website by inputting SQL statements in a web form to get a badly designed website in order to dump the database content to the attacker. SQL injection is a code injection technique that exploits a security vulnerability in a website's software...

s or XSS attacks
Cross-site scripting
Cross-site scripting is a type of computer security vulnerability typically found in Web applications that enables attackers to inject client-side script into Web pages viewed by other users. A cross-site scripting vulnerability may be used by attackers to bypass access controls such as the same...

.

The core language is functional
Functional programming
In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state...

, and enjoys a static type system
Type system
A type system associates a type with each computed value. By examining the flow of these values, a type system attempts to ensure or prove that no type errors can occur...

 with type inference
Type inference
Type inference refers to the automatic deduction of the type of an expression in a programming language. If some, but not all, type annotations are already present it is referred to as type reconstruction....

.
Opa also provides sessions which encapsulate an imperative
Imperative programming
In computer science, imperative programming is a programming paradigm that describes computation in terms of statements that change a program state...

 state and
communicate using message passing
Message passing
Message passing in computer science is a form of communication used in parallel computing, object-oriented programming, and interprocess communication. In this model, processes or objects can send and receive messages to other processes...

, similarly to Erlang
Erlang
Erlang may refer to:* Agner Krarup Erlang , a mathematician and engineer after whom several concepts are named** Erlang , a unit to measure traffic in telecommunications or other domains...

 processes.
Opa provides many structures or functions that are common in web development, as first-class object
First-class object
In programming language design, a first-class citizen , in the context of a particular programming language, is an entity that can be constructed at run-time, passed as a parameter, returned from a subroutine, or assigned into a variable...

s,
for instance HTML
HTML
HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....


and parsers, based on Parsing Expression Grammar
Parsing expression grammar
A parsing expression grammar, or PEG, is a type of analytic formal grammar, i.e. it describes a formal language in terms of a set of rules for recognizing strings in the language...

s.
Because of this adhesion between the language and web-related concepts,
Opa is not indicated for non-web applications (for instance desktop applications).

Hello world

The traditional Hello world program
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...

 can be written in Opa as:


server = one_page_server("Hello", -> <>Hello, web!)


It can be compiled to a stand-alone executable binary with:

opa hello_web.opa

Running the resulting binary launches the web application:

./hello_web.exe

Opa is packaged with the opa-cloud tool to help deployment on several instances.
The following command launches the application, configures load balancing and makes servers share information automatically:

opa-cloud hello_web.exe --host localhost --host my@my_server1 --host my@my_server2

See also

  • Dart
    Dart (programming language)
    Dart is a Web programming language developed by Google. It was unveiled at the in Aarhus, 2011 October 10-12. The goal of Dart is "ultimately to replace JavaScript as the lingua franca of web development on the open web platform."- Reason for a new language :Dart is intended to solve JavaScript's...

     - similar programming language for web apps
  • HaXe
    HaXe
    haXe is a versatile open-source high-level multiplatform programming language described on its website as a "universal language".It can produce:* Flash applications and games* Multi-platform client-side web applications* Apache CGI web applications...

    - another similar programming language for web apps
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK