HOME

TheInfoList



OR:

Multitier programming (or tierless programming) is a
programming paradigm Programming paradigms are a way to classify programming languages based on their features. Languages can be classified into multiple paradigms. Some paradigms are concerned mainly with implications for the execution model of the language, s ...
for
distributed software A distributed system is a system whose components are located on different networked computers, which communicate and coordinate their actions by passing messages to one another from any system. Distributed computing is a field of computer sci ...
, which typically follows a
multitier architecture In software engineering, multitier architecture (often referred to as ''n''-tier architecture) is a client–server architecture in which presentation, application processing and data management functions are physically separated. The most wide ...
, physically separating different functional aspects of the software into different ''tiers'' (e.g., the client, the server and the database in a Web application). Multitier programming allows functionalities that span multiple of such tiers to be developed in a single compilation unit using a single
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming l ...
. Without multitier programming, tiers are developed using different languages, e.g.,
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
for the Web client,
PHP PHP is a General-purpose programming language, general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementati ...
for the Web server and SQL for the database. Multitier programming is often integrated into
general-purpose language A general-purpose language is a computer language that is broadly applicable across application domains, and lacks specialized features for a particular domain. This is in contrast to a domain-specific language (DSL), which is specialized to a pa ...
s by extending them with support for distribution. Concepts from multitier programming were pioneered by the Hop and Links languages and have found industrial adoption in solutions such as Ocsigen, Opa,Rajchenbach-Teller, D., & Sinot, Franois-Régis. (2010). Opa: Language support for a sane, safe and secure web. ''Proceedings of the OWASP AppSec Research'', ''2010''(1).
WebSharper WebSharper is an open-source and commercial web-programming framework that allows web developers to create and maintain complex JavaScript and HTML5 front-end applications in the F# programming language. Other than a few native libraries, every ...
,
Meteor A meteoroid () is a small rocky or metallic body in outer space. Meteoroids are defined as objects significantly smaller than asteroids, ranging in size from grains to objects up to a meter wide. Objects smaller than this are classified as mic ...
or GWT. Multitier programming provides a ''global view'' on the distributed system. This aspect has been shown similar to other programming paradigms such as
choreographic programming In computer science, choreographic programming is a programming paradigm where programs are compositions of interactions among multiple concurrent participants. Overview Choreographies In choreographic programming, developers use a choreogr ...
,
macroprogramming In computer science, macroprogramming is a programming paradigm aimed at expressing the macroscopic, global behaviour of an entire system of agents or computing devices. In macroprogramming, the local programs for the individual components of a d ...
, and
aggregate computing Aggregate or aggregates may refer to: Computing and mathematics * collection of objects that are bound together by a root entity, otherwise known as an aggregate root. The aggregate root guarantees the consistency of changes being made within the ...
.


Context

The code of the different tiers can be executed in a distributed manner on different networked computers. For instance, in a
three-tier architecture In software engineering, multitier architecture (often referred to as ''n''-tier architecture) is a client–server architecture in which presentation, application processing and data management functions are physically separated. The most wide ...
, a system is divided into three main layers – typically the presentation, business, and data tiers. This approach has the benefit that by dividing a system into layers, the functionality implemented in one of the layers can be changed independently of the other layers. On the other hand, this architectural decision scatters a cross-cutting functionality belonging to several tiers over several compilation units. In multitier programming, the different tiers are implemented using a single programming language. Different compilation backends take into account the destination tier (e.g., Java for a server and JavaScript for a web browser). Consequently, a functionality that is spread over tiers can be implemented in a single compilation unit of a multitier program.


Example

At their core, multitier languages allow developers to define for different pieces of code the tiers to which the code belongs. The language features that enable this definition are quite diverse between different multitier languages, ranging from
staging Staging may refer to: Computing * Staging (cloud computing), a process used to assemble, test, and review a new solution before it is moved into production and the existing solution is decommissioned * Staging (data), intermediately storing data b ...
to
annotations An annotation is extra information associated with a particular point in a document or other piece of information. It can be a note that includes a comment or explanation. Annotations are sometimes presented in the margin of book pages. For anno ...
to
types Type may refer to: Science and technology Computing * Typing, producing text via a keyboard, typewriter, etc. * Data type, collection of values used for computations. * File type * TYPE (DOS command), a command to display contents of a file. * Ty ...
. The following example shows an Echo client–server application that illustrates different approaches. In the example, the client sends a message to the server and the server returns the same message to the client, where it is appended to a list of received messages.


Echo application in Hop.js

service echo() var wss = new WebSocketServer("ws") wss.onconnection = function(event) Hop uses staging to embed code that is to be run on the client into a server-side program: Using the ~ notation, the code for the onload (Line 4) and onclick (Line 10) handlers is not immediately executed but the server generates the code for later execution on the client. On the other hand, the $ notation escapes one level of program generation. The expressions hop.port (Line 5), event.data (Line 6) and input (Line 9 and 10) are evaluated by the outer server program and the values to which they evaluate are injected into the generated client program. Hop supports full stage programming, i.e., ~ expressions can be arbitrarily nested such that not only server-side programs can generate client-side programs but also client-side programs are able to generate other client-side programs. HTML can be embedded directly in Hop code. HTML generated on the server (Line 2–14) is passed to the client. HTML generated on the client can be added to the page using the standard DOM API (Line 6). Hop supports bidirectional communication between a running server and a running client instance through its standard library. The client connects to the WebSocket server through the standard HTML5 API (Line 5) and sends the current input value (Line 10). The server opens a WebSocket server (Line 17) that returns the value back to the client (Line 20). So-called services, which are executed on the server and produce a value that is returned to the client that invoked the service. For example, the echo service (Line 1) produces the HTML page served to the web client of the Echo application. Thus, the code in a service block is executed on the server.


Echo application in Links

fun echo(item) server fun main() server main() Links uses annotations on functions to specify whether they run on the client or on the server (Line 1 and 5). Upon request from the client, the server executes the main function (Line 18), which constructs the code that is sent to the client. Links allows embedding XML code (Line 7–15). XML attributes with the l: prefix are treated specially. The l:name attribute (Line 10) declares an identifier to which the value of the input field is bound. The identifier can be used elsewhere (Line 9). The code to be executed for the l:onsubmit handler (Line 9) is not immediately executed but compiled to JavaScript for client-side execution. Curly braces indicate Links code embedded into XML. The l:onsubmit handler sends the current input value item to the server by calling echo. The item is returned by the server and appended to the list of received items using standard DOM APIs. The call to the server (Line 9) does not block the client. Instead, the continuation on the client is invoked when the result of the call is available. Client–server interaction is based on resumption passing style: Using continuation passing style transformation and defunctionalization, remote calls are implemented by passing the name of a function for the continuation and the data needed to continue the computation.


Echo application in ScalaLoci

@multitier object Application ScalaLoci is a language that targets generic distributed systems rather than the Web only, i.e., it is not restricted to a client–server architecture. To this end, ScalaLoci supports peer types to encode the different tiers at the type level. Placement types are used to assign locations to data and computations. ScalaLoci supports multitier reactives – language abstractions for reactive programming that are placed on specific locations – for composing data flows cross different peers. The application first defines an input field (Line 11) using the ScalaTags library. The value of this field is used in the click event handler of a button (Line 15) to fire the message event with the current value of the input field. The value is then propagated to the server (Line 6) and back to the client (Line 9). On the client, the value of the event are accumulated using the list function and mapped to an HTML list (Line 10). This list is then used in the HTML (Line 16) to display the previous inputs.


List of multitier programming languages

* Hop/Hop.js * Links *Ur/Web *Eliom/Ocsigen *ScalaLoci *StiP.js *Scala Multi-Tier FRP *OpaRajchenbach-Teller, D., & Sinot, Franois-Régis. (2010). Opa: Language support for a sane, safe and secure web. ''Proceedings of the OWASP AppSec Research'', ''2010''(1). *AmbientTalk/R *ML5 *WebSharper *Haste *Fun *Koka *Multi-Tier Calculus *Swift *Volta *GWT *Meteor *J-Orchestra *Hiphop *Distributed Orc *Jif/split *Fission *SIF *WebDSL *Acute *Mobl *High-Level Abstractions for Web Programming


References

{{Programming paradigms navbox Programming paradigms