Opa (programming language)

From Infogalactic: the planetary knowledge core
Jump to: navigation, search
Opa
File:Opa logo cloud.png
Paradigm multi-paradigm: functional, imperative
Developer MLstate
First appeared 2011
Stable release 1.1.0 (stable) / February 13, 2013; 11 years ago (2013-02-13)[1]
Typing discipline static, strong, inferred
OS Linux, OS X, Windows
License MIT License, AGPLv3
Website opalang.org
Influenced by
OCaml, Erlang, JavaScript

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.[2][3] Opa implements strong, static typing, which can be helpful in protecting against security issues such as SQL injections and cross-site scripting attacks.[4]

The language was first officially presented at the OWASP conference in 2010,[5] and the source code was released on GitHub[6] 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.

Design and features

Opa consists of a web server, a database and distributed execution engine.[7] 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.[8] 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.[9] Opa shares motivations with web frameworks, but takes a different approach.[10] Its designers assert that this helps Opa to avoid many security issues, like SQL injections or cross-site scripting (XSS) attacks.[11]

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

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.[15][16][17] 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:[18]

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

See also

  • Dart - a Javascript alternative for web apps
  • Haxe - similar programming language for web apps
  • CoffeeScript - a programming language transcompiled to Javascript for web apps

References

<templatestyles src="Reflist/styles.css" />

Cite error: Invalid <references> tag; parameter "group" is allowed only.

Use <references />, or <references group="..." />

Bibliography

External links

  1. http://blog.opalang.org/2013/02/some-great-news-on-opa.html
  2. Lua error in package.lua at line 80: module 'strict' not found.
  3. Opa actually supports various server-side backends, Nodejs being the most popular one
  4. Lua error in package.lua at line 80: module 'strict' not found.
  5. Lua error in package.lua at line 80: module 'strict' not found.
  6. Lua error in package.lua at line 80: module 'strict' not found.
  7. Lua error in package.lua at line 80: module 'strict' not found.
  8. Lua error in package.lua at line 80: module 'strict' not found.
  9. Lua error in package.lua at line 80: module 'strict' not found.
  10. Lua error in package.lua at line 80: module 'strict' not found.
  11. Lua error in package.lua at line 80: module 'strict' not found.
  12. Lua error in package.lua at line 80: module 'strict' not found.
  13. Lua error in package.lua at line 80: module 'strict' not found.
  14. Lua error in package.lua at line 80: module 'strict' not found.
  15. Lua error in package.lua at line 80: module 'strict' not found.
  16. Lua error in package.lua at line 80: module 'strict' not found.
  17. Lua error in package.lua at line 80: module 'strict' not found.
  18. Lua error in package.lua at line 80: module 'strict' not found.