Content deleted Content added
No edit summary |
Citation bot (talk | contribs) Removed URL that duplicated identifier. | Use this bot. Report bugs. | #UCB_CommandLine |
||
(44 intermediate revisions by 24 users not shown) | |||
Line 1:
{{Short description|Programming paradigm that unifies the development of different tiers in a single compilation unit}}
'''Multitier programming''' (or '''tierless programming''') is a [[programming paradigm]] for [[distributed computing|distributed software]], which typically follows a [[multitier architecture]], physically separating different functional aspects of the software into different ''tiers'' (e.g., the client, the server and the database in a Web application<ref>{{Cite journal|last1=Hull|first1=Richard|last2=Thiemann|first2=Peter|last3=Wadler|first3=Philip|date=2007|title=07051 Working Group Outcomes – Programming Paradigms for the Web: Web Programming and Web Services|url=http://drops.dagstuhl.de/opus/volltexte/2007/1127|journal=Programming Paradigms for the Web: Web Programming and Web Services|series=Dagstuhl Seminar Proceedings|___location=Dagstuhl, Germany|publisher=Internationales Begegnungs- und Forschungszentrum für Informatik (IBFI)|volume=07051}}</ref>). Multitier programming allows
Concepts from multitier programming were pioneered by the [[Hop (software)|Hop]]<ref name=":0">{{Cite journal|last=Serrano|first=Manuel|date=2012|title=Multitier programming in Hop.|url=https://dblp.org/rec/journals/cacm/SerranoB12.html|journal=Commun. ACM|volume=55|issue=8|pages=53–59|doi=10.1145/2240236.2240253|s2cid=2152326|url-access=subscription}}</ref> and [[Links (programming language)|Links]]<ref name=":1">{{Cite book|last=Cooper|first=Ezra|
and have found industrial adoption in solutions such as
Multitier programming provides a ''global view'' on the distributed system. This aspect has been shown similar to other programming paradigms such as [[choreographic programming]],<ref>{{Cite journal |last1=Giallorenzo |first1=Saverio |last2=Montesi |first2=Fabrizio |last3=Peressotti |first3=Marco |last4=Richter |first4=David |last5=Salvaneschi |first5=Guido |last6=Weisenburger |first6=Pascal |date=2021 |editor-last=Møller |editor-first=Anders |editor2-last=Sridharan |editor2-first=Manu |title=Multiparty Languages: The Choreographic and Multitier Cases |url=https://drops.dagstuhl.de/opus/volltexte/2021/14065 |journal=35th European Conference on Object-Oriented Programming (ECOOP 2021) |series=Leibniz International Proceedings in Informatics (LIPIcs) |___location=Dagstuhl, Germany |publisher=Schloss Dagstuhl – Leibniz-Zentrum für Informatik |volume=194 |pages=22:1–22:27 |doi=10.4230/LIPIcs.ECOOP.2021.22 |doi-access=free |isbn=978-3-95977-190-0|s2cid=235748561 }}</ref> [[macroprogramming]],<ref name="Casadei 2023">{{cite journal | last=Casadei | first=Roberto | title=Macroprogramming: Concepts, State of the Art, and Opportunities of Macroscopic Behaviour Modelling | journal=ACM Computing Surveys | publisher=Association for Computing Machinery (ACM) | date=2023-01-11 | volume=55 | issue=13s | pages=1–37 | issn=0360-0300 | doi=10.1145/3579353 | s2cid=245837830 | doi-access=free | arxiv=2201.03473 }}</ref> and [[aggregate computing]].<ref name="Beal Pianini Viroli 2015 pp. 22–30">{{cite journal | last1=Beal | first1=Jacob | last2=Pianini | first2=Danilo | last3=Viroli | first3=Mirko | title=Aggregate Programming for the Internet of Things | journal=Computer | publisher=Institute of Electrical and Electronics Engineers (IEEE) | volume=48 | issue=9 | year=2015 | issn=0018-9162 | doi=10.1109/mc.2015.261 | pages=22–30| hdl=11585/520779 | s2cid=26413 | hdl-access=free }}</ref><ref>{{Cite journal |last1=Audrito |first1=Giorgio |last2=Casadei |first2=Roberto |last3=Damiani |first3=Ferruccio |last4=Salvaneschi |first4=Guido |last5=Viroli |first5=Mirko |date=2022 |editor-last=Ali |editor-first=Karim |editor2-last=Vitek |editor2-first=Jan |title=Functional Programming for Distributed Systems with XC |url=https://drops.dagstuhl.de/opus/volltexte/2022/16248 |journal=36th European Conference on Object-Oriented Programming (ECOOP 2022) |series=Leibniz International Proceedings in Informatics (LIPIcs) |___location=Dagstuhl, Germany |publisher=Schloss Dagstuhl – Leibniz-Zentrum für Informatik |volume=222 |pages=20:1–20:28 |doi=10.4230/LIPIcs.ECOOP.2022.20 |doi-access=free |isbn=978-3-95977-225-9|s2cid=249961384 }}</ref>
== Context ==
The code of the different tiers can be executed in a distributed manner on different [[Computer network|networked computers]]. For instance, in a [[Multitier architecture#Three-tier architecture|three-tier architecture]], 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 [[Compiler|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 [[Multi-stage programming|staging]] to [[Annotation#Software and engineering|annotations]] to [[Type system|types]]. 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.
===
<syntaxhighlight lang="lisp" line="1">
service echo() {
}
var wss = new WebSocketServer("ws")
wss.onconnection = function(event){
}
</syntaxhighlight>
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 [[Multi-stage programming|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
=== Echo application in Links ===
<syntaxhighlight lang="java" line="1">
fun echo(item) server {
}
fun main() server {
}
main()
</syntaxhighlight>
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 ===
<syntaxhighlight lang="scala" line="1">
@multitier object Application {
@peer type Server <: { type Tie <:
@peer type Client <: { type Tie <: Single[Server] }
val message = on[Client] { Event[String]() }
val echoMessage = on[Server] { message.asLocal }
def main() = on[Client] {
val items = echoMessage.asLocal.list
val list = Signal { ol(items() map { message => li(message) }) }
val inp = input.render
dom.document.body = body(
div(
inp,
button(onclick := { () => message.fire(inp.value) })("Echo!")),
list.asFrag).render
}
}
</syntaxhighlight>
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 system|type level]]. Placement types are used to assign locations to data and computations. ScalaLoci supports multitier [[Functional reactive programming|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.<ref>{{Cite web|title=ScalaTags|url=https://com-lihaoyi.github.io/scalatags/|website=www.lihaoyi.com|access-date=2021-10-11}}</ref> 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<ref name=":0">{{Cite journal|last=Serrano|first=Manuel|date=2012|title=Multitier programming in Hop.|url=https://dblp.org/rec/journals/cacm/SerranoB12.html|journal=Commun. ACM|volume=55|issue=8|pages=53–59|doi=10.1145/2240236.2240253|s2cid=2152326|url-access=subscription}}</ref><ref>{{Cite journal|last=Serrano|first=Manuel|date=2006|title=Hop: a language for programming the web 2.0.|url=https://dblp.org/rec/conf/oopsla/SerranoGL06.html|pages=975–985|doi=10.1145/1176617.1176756|s2cid=14306230|url-access=subscription}}</ref><ref>{{Cite book|last=Serrano|first=Manuel|
* Links<ref name=":1">{{Cite book|last=Cooper|first=Ezra|
*Ur/Web<ref>{{Cite journal|last=Chlipala|first=Adam|date=2015|title=Ur/Web: A Simple Model for Programming the Web.|url=https://dblp.org/rec/conf/popl/Chlipala15.html|pages=153–165|doi=10.1145/2676726.2677004|s2cid=9440677|url-access=subscription}}</ref>
*Eliom/Ocsigen<ref name=":2">{{Cite journal|last=Balat|first=Vincent|date=2006|title=Ocsigen: typing web interaction with objective Caml.|url=https://dblp.org/rec/conf/ml/Balat06.html|pages=84–94|doi=10.1145/1159876.1159889|s2cid=6131454|url-access=subscription}}</ref><ref>{{Cite book|last=Radanne|first=Gabriel|
*ScalaLoci<ref>{{Cite journal|last=Weisenburger|first=Pascal|date=2018|title=Distributed system development with ScalaLoci.|url=https://dblp.org/rec/journals/pacmpl/WeisenburgerKS18.html|journal=Proc. ACM Program. Lang.|volume=2|issue=OOPSLA|pages=129:1–129:30|doi=10.1145/3276499|s2cid=53090153|doi-access=free}}</ref>
*StiP.js<ref>{{Cite book|last=Philips|first=Laure|
*Scala Multi-Tier FRP<ref>{{Cite book|last=Reynders|first=Bob|
*Opa<ref name=":3">Rajchenbach-Teller, D., & Sinot, Franois-
*AmbientTalk/R<ref>{{Cite book|last=Carreton|first=Andoni Lombide|
*ML5<ref>{{Cite book|last=VII|first=Tom Murphy|
*WebSharper<ref name=":4">{{Cite
*Haste<ref>{{Cite journal|last1=Ekblad|first1=Anton|last2=Claessen|first2=Koen|date=2015-05-11|title=A seamless, client-centric programming model for type safe web applications|url=http://dx.doi.org/10.1145/2775050.2633367|journal=ACM SIGPLAN Notices|volume=49|issue=12|pages=79–89|doi=10.1145/2775050.2633367|issn=0362-1340|url-access=subscription}}</ref>
*Fun<ref>{{Cite web|title=Fun (a programming language for the realtime web)|url=http://marcuswest.in/essays/fun-intro/|website=marcuswest.in|access-date=2020-05-04}}</ref>
*Koka<ref>{{Cite journal|last=Leijen|first=Daan|date=2014|title=Koka: Programming with Row Polymorphic Effect Types.|journal=Electronic Proceedings in Theoretical Computer Science|volume=153|url=https://dblp.org/rec/journals/corr/Leijen14.html|pages=100–126|doi=10.4204/EPTCS.153.8|arxiv=1406.2061|s2cid=14902937}}</ref>
*Multi-Tier Calculus<ref>{{Cite book|last=Neubauer|first=Matthias|
*Swift<ref>{{Cite journal|last1=ChongStephen|last2=LiuJed|last3=C|first3=MyersAndrew|last4=QiXin|last5=VikramK|last6=ZhengLantian|last7=ZhengXin|date=2007-10-14|title=Secure web applications via automatic partitioning|url=https://dl.acm.org/doi/abs/10.1145/1323293.1294265|journal=ACM SIGOPS Operating Systems Review|volume=41|issue=6|pages=31–44|language=EN|doi=10.1145/1323293.1294265|hdl=1813/5769 |hdl-access=free}}</ref>
*Volta<ref>{{Cite journal|last=Manolescu|first=Dragos|date=2008|title=Volta: Developing Distributed Applications by Recompiling.|url=https://dblp.org/rec/journals/software/ManolescuBL08.html|journal=IEEE Software|volume=25|issue=5|pages=53–59|doi=10.1109/MS.2008.131|s2cid=24360031|url-access=subscription}}</ref>
*GWT<ref name=":6">{{Cite book|last=Kereki, Federico, 1960-
*Meteor<ref name=":5">{{Cite book|last=Strack, Isaac
*J-Orchestra<ref>{{Cite book|last=Tilevich|first=Eli|
*Hiphop<ref>{{Cite
*Distributed Orc<ref>{{Cite journal|last=Thywissen|first=John A.|date=2016|title=Implicitly Distributing Pervasively Concurrent Programs: Extended abstract.|url=https://dblp.org/rec/conf/ecoop/ThywissenPC16.html|pages=1|doi=10.1145/2957319.2957370|s2cid=6124391|url-access=subscription}}</ref>
*Jif/split<ref>{{Cite journal|last=Zdancewic|first=Steve|date=2002|title=Secure program partitioning.|url=https://dblp.org/rec/journals/tocs/ZdancewicZNM02.html|journal=ACM Trans. Comput. Syst.|volume=20|issue=3|pages=283–328|doi=10.1145/566340.566343|s2cid=1776939|url-access=subscription}}</ref>
*Fission<ref>{{Cite journal|last1=Guha|first1=Arjun|last2=Jeannin|first2=Jean-Baptiste|last3=Nigam|first3=Rachit|last4=Tangen|first4=Jane|last5=Shambaugh|first5=Rian|date=2017|editor-last=Lerner|editor-first=Benjamin S.|editor2-last=Bodík|editor2-first=Rastislav|editor3-last=Krishnamurthi|editor3-first=Shriram|title=Fission: Secure Dynamic Code-Splitting for JavaScript|url=http://drops.dagstuhl.de/opus/volltexte/2017/7124|journal=2nd Summit on Advances in Programming Languages (SNAPL 2017)|series=Leibniz International Proceedings in Informatics (LIPIcs)|___location=Dagstuhl, Germany|publisher=Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik|volume=71|pages=5:1–5:13|doi=10.4230/LIPIcs.SNAPL.2017.5|doi-access=free |isbn=978-3-95977-032-3}}</ref>
*SIF<ref>{{Cite journal|last=Chong|first=Stephen|date=2007|title=SIF: Enforcing Confidentiality and Integrity in Web Applications.|url=https://www.usenix.org/conference/16th-usenix-security-symposium/sif-enforcing-confidentiality-and-integrity-web}}</ref>
*WebDSL<ref>{{Cite journal|last=Groenewegen|first=Danny M.|date=2008|title=WebDSL: a ___domain-specific language for dynamic web applications.|url=https://dblp.org/rec/conf/oopsla/GroenewegenHKV08.html|pages=779–780|doi=10.1145/1449814.1449858|s2cid=8073129|url-access=subscription}}</ref>
*Acute<ref>{{Cite journal|last=Sewell|first=Peter|date=2005|title=Acute: high-level programming language design for distributed computation.|url=https://dblp.org/rec/conf/icfp/SewellLWNAHV05.html|pages=15–26|doi=10.1145/1086365.1086370|s2cid=1308126|url-access=subscription}}</ref>
*Mobl<ref>{{Cite book|last=Hemel|first=Zef|
*High-Level Abstractions for Web Programming<ref>{{Cite book|last=Richard-Foy|first=Julien|
== References ==
{{reflist}}
{{Programming paradigms navbox}}
[[Category:Programming paradigms]]
|