Opa (programming language)#Hello world

{{short description|Programming language for developing scalable web applications}}

{{Infobox programming language

| name = Opa

| logo = Opa logo cloud.png

| paradigms = multi-paradigm: functional, imperative

| typing = static, strong, inferred

| scope = lexical

| developer = [http://www.linkedin.com/company/mlstate MLstate]

| year = {{Start date and age|2011}}

| latest release version = 1.1.1 (stable)

| latest release date = {{Start date and age|2014|03|08}}{{Cite web |title=Release 1.1.1: MLstate/opalang |url=https://github.com/MLstate/opalang/releases/tag/v4308 |access-date=2021-01-29 |website=GitHub |language=en}}{{Cite web |title=Some great news on Opa |url=http://blog.opalang.org/2013/02/some-great-news-on-opa.html |access-date=2021-01-29}}

| operating system = Linux, macOS, Windows

| programming language = OCaml, Opa, JavaScript, Shell,C, Standard ML

| license = AGPLv3, MIT

| website = {{URL|opalang.org}}

| influenced by = OCaml, Erlang, JavaScript

}}

Opa is a programming language for developing scalable web applications. It is free and open-source software released under a GNU Affero General Public License (AGPLv3), and an MIT License.

It can be used for both client-side and server-side scripting, where complete programs are written in Opa and subsequently compiled to Node.js on a server and JavaScript on a client, with the compiler automating all communication between the two.{{cite web |last1=Koprowski |first1=Adam |url=http://www.developer.com/open/opa-vs.-node.js-javascript-framework-comparison.html |title=Node.js vs. Opa: Web Framework Showdown |publisher=developer.com |date=24 February 2012}}Opa supports various server-side backends, Nodejs being the most popular one. Opa implements strong, static typing, which can be helpful in protecting against security issues such as SQL injections and cross-site scripting attacks.{{cite journal |last1=Robertson |first1=William |last2=Giovanni |first2=Vigna |year=2009 |url=http://www.mendeley.com/research/static-enforcement-of-web-application-integrity-through-strong-typing/ |title=Static Enforcement of Web Application Integrity Through Strong Typing |journal=SSYM'09 Proceedings of the 18th Conference on USENIX Security Symposium}}{{Dead link|date=April 2020 |bot=InternetArchiveBot |fix-attempted=yes}}

The language was first officially presented at the Open Worldwide Application Security Project (OWASP) conference in 2010,{{cite web |date=June 2010 |publisher=OWASP

|url=https://www.owasp.org/index.php/OWASP_AppSec_Research_2010_-_Stockholm,_Sweden#OPA:_Language_Support_for_a_Sane.2C_Safe_and_Secure_Web

|title=OPA: Language Support for a Sane, Safe and Secure Web, at OWASP 2010}} and the source code was released on

GitHub{{cite web |url=https://github.com/MLstate/opalang |title=GitHub repository |website=GitHub}}

in June 2011, under a GNU Affero General Public License (AGPL). Later, the license changed to the MIT License for the software framework part (the library) and AGPL for the compiler, so that applications written in Opa can be released under any software license, proprietary or open source.

Design and features

Opa consists of a web server, a database and distributed execution engine.{{cite web |url=http://www.webappers.com/2011/07/22/opa-the-scalable-open-source-cloud-language/ |title=Opa – The Scalable Open Source Cloud Language |publisher=WebAppers |date=22 July 2011}} 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.{{cite web |url=http://www.infoq.com/articles/Opa|publisher=InfoQ|title=Interview: François-Régis Sinot on Opa, a Web Development Platform|date=7 September 2011}}

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.{{cite web |author=Neil McAllister|url=https://www.infoworld.com/article/2620269/introducing-opa--a-web-dev-language-to-rule-them-all.html|publisher=InfoWorld |title=Introducing Opa, a Web dev language to rule them all |date=8 September 2011}} Opa shares motivations with web frameworks, but takes a different approach.{{cite web|url=https://www.infoworld.com/article/2626870/infoworld-review-tools-for-rapid-web-development.html|title=InfoWorld review: Tools for rapid Web development|publisher=InfoWorld|date=12 May 2010}}

Its designers assert that this helps Opa to avoid many security issues, like SQL injections or cross-site scripting (XSS) attacks.{{cite web|url=http://www.heise.de/developer/meldung/Auch-Opa-ist-fuer-Cloud-Anwendungen-1288588.html|title=Auch Opa ist für Cloud-Anwendungen |publisher=Heise Online|date=29 July 2011}}

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 citizen objects, for instance HTML{{cite web|url=http://www.i-programmer.info/news/98-languages/2961-opa-a-unified-approach-to-web-programming.html |title=Opa – a unified approach to web programming |publisher=i-Programmer |date=28 August 2011}} and parsers, based on parsing expression grammars.{{cite journal |last1=Koprowski |first1=Binsztok |year=2011 |url=http://www.lmcs-online.org/ojs/viewarticle.php?id=708&layout=abstract |title=TRX: A Formally Verified Parser Interpreter |journal=Logical Methods in Computer Science}} Because of this adhesion between the language and web-related concepts, Opa is not intended for non-web applications (for instance desktop applications).{{cite web |url=http://linuxfr.org/news/opa-un-nouveau-langage-pour-le-d%C3%A9veloppement-d%E2%80%99applications-web |title=Opa, un nouveau langage pour le développement d'applications Web|publisher=LinuxFr |language=Fr |date=22 June 2011}}

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.{{cite news|url=http://news.idg.no/cw/art.cfm?id=36C6A408-F2EE-3929-CB53260EBA6B884F|title=Programming Opa: Web development, reimagined|publisher=Computerworld|date=1 February 2012}}

The 1.1.0 release in February 2013 also added support for PostgreSQL, paving the way for the support of several SQL databases.

See also

{{Portal|Free and open-source software}}

  • Ur – a functional language for web development
  • Dart – a JavaScript alternative for web apps
  • Haxe – a similar language for web apps
  • CoffeeScript – a language transcompiled to JavaScript for web apps
  • Dark – a language integrating development and deployment of serverless services

References

{{Reflist}}

Bibliography