Jump to content

Opa (programming language)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 209.66.74.34 (talk) at 22:20, 16 February 2012 (→‎Design and features: correcting moronic use of big words). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Opa
File:Opa logo.png
Paradigmmulti-paradigm: functional, imperative
DeveloperMLstate
First appeared2011
Stable release
S3.5 (build 1121) / January 3, 2012; 12 years ago (2012-01-03)
Typing disciplinestatic, strong, inferred
OSLinux, Mac OS X
LicenseAGPL
Websiteopalang.org
Influenced by
OCaml, Erlang

Opa is an open source programming language for web applications.

The language was first officially presented at the OWASP conference in 2010[1], and the source code was released on GitHub[2] in June 2011, under a GNU Affero General Public License.

Design and features

Opa consists of a web server, a database and distributed execution engine.[3] Code written in Opa is compiled to native code on the server side and to JavaScript using jQuery for cross-browser compatibility on the client side.[4] 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.[5] Opa shares motivations with web frameworks, but takes a different approach.[6] This helps Opa to avoid many security issues, like SQL injections or XSS attacks.[7]

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[8] and parsers, based on Parsing Expression Grammars.[9] Because of this adhesion between the language and web-related concepts, Opa is not indicated for non-web applications (for instance desktop applications). [10]

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: [11]

Server.start(Server.http,
  { title: "Hello",
  , page: function() { <>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

References

  1. ^ "OPA: Language Support for a Sane, Safe and Secure Web, at OWASP 2010". OWASP. June 2010.
  2. ^ "GitHub repository".
  3. ^ "Opa – The Scalable Open Source Cloud Language". WebAppers. 22 July 2011.
  4. ^ "Interview: François-Régis Sinot on Opa, a Web Development Platform". InfoQ. 7 September 2011.
  5. ^ Neil McAllister (8 September 2011). "Introducing Opa, a Web dev language to rule them all". InfoWorld.
  6. ^ "InfoWorld article about emerging web technologies, including Opa". InfoWorld. 12 May 2010.
  7. ^ "Auch Opa ist für Cloud-Anwendungen". Heise. 29 July 2011.
  8. ^ "Opa - a unified approach to web programming". i-Programmer. 28 August 2011.
  9. ^ Koprowski, Binsztok (2011). "TRX: A Formally Verified Parser Interpreter". Logical Methods in Computer Science. doi:10.2168. {{cite web}}: Check |doi= value (help)
  10. ^ "Opa, un nouveau langage pour le développement d'applications Web". LinuxFr. 22 June 2011.
  11. ^ Alastair Aitken (26 July 2011). "Opa, the cloud language – a test drive". Morgan Hill.

See also

  • Dart - similar programming language for web apps
  • HaXe - another similar programming language for web apps