Opa (programming language)

Last updated
Opa
Opa logo cloud.png
Paradigm multi-paradigm: functional, imperative
Developer MLstate
First appeared2011
Stable release
1.1.1 (stable) / March 8, 2014;8 years ago (2014-03-08) [1] [2]
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.

Contents

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 the server and JavaScript on the client, with the compiler automating all communication between the two. [3] [4] Opa implements strong, static typing, which can be helpful in protecting against security issues such as SQL injections and cross-site scripting attacks. [5]

The language was first officially presented at the OWASP conference in 2010, [6] and the source code was released on GitHub [7] 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. [8] 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. [9] 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. [10] Opa shares motivations with web frameworks, but takes a different approach. [11] Its designers assert that this helps Opa to avoid many security issues, like SQL injections or cross-site scripting (XSS) attacks. [12]

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

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

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

Related Research Articles

<span class="mw-page-title-main">Server-side scripting</span> Technique used in web development

Server-side scripting is a technique used in web development which involves employing scripts on a web server which produces a response customized for each user's (client's) request to the website. The alternative is for the web server itself to deliver a static web page. Scripts can be written in any of a number of server-side scripting languages that are available. Server-side scripting is distinguished from client-side scripting where embedded scripts, such as JavaScript, are run client-side in a web browser, but both techniques are often used together.

<span class="mw-page-title-main">Microsoft WebMatrix</span>

Microsoft WebMatrix is a discontinued cloud-connected website builder and HTML editor for Windows, geared towards web development. WebMatrix enables developers to build websites using built-in templates or popular open-source applications, with full support for ASP.NET, PHP, Node.js and HTML5. Microsoft developed WebMatrix for the purpose of providing web developers with coding, customization, and publishing capabilities all in one place.

In computing, a solution stack or software stack is a set of software subsystems or components needed to create a complete platform such that no additional software is needed to support applications. Applications are said to "run on" or "run on top of" the resulting platform.

TypeScript is a free and open source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript and adds optional static typing to the language. It is designed for the development of large applications and transpiles to JavaScript. As it is a superset of JavaScript, existing JavaScript programs are also valid TypeScript programs.

<span class="mw-page-title-main">V8 (JavaScript engine)</span> Open-source JavaScript engine developed by Google

V8 is a free and open-source JavaScript engine developed by the Chromium Project for Google Chrome and Chromium web browsers. The project’s creator is Lars Bak. The first version of the V8 engine was released at the same time as the first version of Chrome: 2 September 2008. It has also been used on the server side, for example in Couchbase and Node.js.

<span class="mw-page-title-main">Node.js</span> JavaScript runtime environment

Node.js is an open-source server environment. Node.js is cross-platform and runs on Windows, Linux, Unix, Mac OS, etc. Node.js is a back-end JavaScript runtime environment. Node.js runs on a JavaScript Engine and executes JavaScript code outside a web browser.

CommonJS is a project with the goal to establish conventions on the module ecosystem for JavaScript outside of the web browser. The primary reason for its creation was a major lack of commonly accepted forms of JavaScript module units which could be reusable in environments different from that provided by conventional web browsers running JavaScript scripts.

<span class="mw-page-title-main">Amber Smalltalk</span>

Amber Smalltalk, formerly named Jtalk, is an implementation of the Smalltalk-80 language that runs on the JavaScript runtime of a web browser. It is designed to enable client-side development using the Smalltalk programming language. The programming environment in Amber is named Helios.

Mustache is a web template system with implementations available for ActionScript, C++, Clojure, CoffeeScript, ColdFusion, Common Lisp, Crystal, D, Dart, Delphi, Elixir, Erlang, Fantom, Go, Haskell, Io, Java, JavaScript, Julia, Lua, .NET, Objective-C, OCaml, Perl, PHP, Pharo, Python, R, Racket, Raku, Ruby, Rust, Scala, Smalltalk, Swift, Tcl, CFEngine, and XQuery.

<span class="mw-page-title-main">MEAN (solution stack)</span> JavaScript software stack

MEAN is a free and open-source JavaScript software stack for building dynamic web sites and web applications. A variation known as MERN replaces Angular with React.

Express.js, or simply Express, is a back end web application framework for building RESTful APIs with Node.js, released as free and open-source software under the MIT License. It is designed for building web applications and APIs. It has been called the de facto standard server framework for Node.js.

Nim is a general-purpose, multi-paradigm, statically typed, compiled systems programming language, designed and developed by a team around Andreas Rumpf. Nim is designed to be "efficient, expressive, and elegant", supporting metaprogramming, functional, message passing, procedural, and object-oriented programming styles by providing several features such as compile time code generation, algebraic data types, a foreign function interface (FFI) with C, C++, Objective-C, and JavaScript, and supporting compiling to those same languages.

<span class="mw-page-title-main">RocksDB</span>

RocksDB is a high performance embedded database for key-value data. It is a fork of Google's LevelDB optimized to exploit many CPU cores, and make efficient use of fast storage, such as solid-state drives (SSD), for input/output (I/O) bound workloads. It is based on a log-structured merge-tree data structure. It is written in C++ and provides official language bindings for C++, C, and Java; alongside many third-party language bindings. RocksDB is open-source software, and was originally released under a BSD 3-clause license. However, in July 2017 the project was migrated to a dual license of both Apache 2.0 and GPLv2 license, possibly in response to the Apache Software Foundation's blacklist of the previous BSD+Patents license clause.

Next.js is an open-source web development framework created by Vercel enabling React-based web applications with server-side rendering and generating static websites.

<span class="mw-page-title-main">Deno (software)</span> Secure Javascript and Typescript runtime

Deno is a runtime for JavaScript, TypeScript, and WebAssembly that is based on the V8 JavaScript engine and the Rust programming language. Deno was co-created by Ryan Dahl, who also created Node.js.

References

  1. "Release 1.1.1 · MLstate/opalang". GitHub. Retrieved 2021-01-29.
  2. "Some great news on Opa" . Retrieved 2021-01-29.
  3. Adam Koprowski (24 February 2012). "Node.js vs. Opa: Web Framework Showdown". developer.com.
  4. Opa actually supports various server-side backends, Nodejs being the most popular one
  5. Robertson, William; Giovanni, Vigna (2009). "Static Enforcement of Web Application Integrity Through Strong Typing". SSYM'09 Proceedings of the 18th Conference on USENIX Security Symposium.[ permanent dead link ]
  6. "OPA: Language Support for a Sane, Safe and Secure Web, at OWASP 2010". OWASP. June 2010.
  7. "GitHub repository".
  8. "Opa – The Scalable Open Source Cloud Language". WebAppers. 22 July 2011.
  9. "Interview: François-Régis Sinot on Opa, a Web Development Platform". InfoQ. 7 September 2011.
  10. Neil McAllister (8 September 2011). "Introducing Opa, a Web dev language to rule them all". InfoWorld.
  11. "InfoWorld review: Tools for rapid Web development". InfoWorld. 12 May 2010.
  12. "Auch Opa ist für Cloud-Anwendungen". Heise Online. 29 July 2011.
  13. "Opa - a unified approach to web programming". i-Programmer. 28 August 2011.
  14. Koprowski, Binsztok (2011). "TRX: A Formally Verified Parser Interpreter". Logical Methods in Computer Science.
  15. "Opa, un nouveau langage pour le développement d'applications Web" (in French). LinuxFr. 22 June 2011.
  16. "Hello, database". Opa Documentation. Archived from the original on 2014-01-12. Retrieved 2012-02-22.
  17. "Low-level MongoDB support". Opa Documentation. Archived from the original on 2014-01-12. Retrieved 2012-02-22.
  18. "Programming Opa: Web development, reimagined". Computerworld. 1 February 2012.
  19. Alastair Aitken (26 July 2011). "Opa, the cloud language – a test drive". Morgan Hill. Archived from the original on 25 September 2011. Retrieved 6 September 2011.

Bibliography