Content deleted Content added
Robyonrails (talk | contribs) Context and motivation of macroprogramming |
Fixed grammar Tags: canned edit summary Mobile edit Mobile app edit iOS app edit App section source |
||
(21 intermediate revisions by 12 users not shown) | |||
Line 1:
{{Short description|Programming paradigm to program distributed systems with a single program by a global perspective.}}
{{distinguish|Macro (programming)}}
In [[computer science]], '''macroprogramming''' is a [[programming paradigm]]
In macroprogramming, the local programs for the individual components of a [[distributed system]] are compiled or interpreted from a ''macro-program'' typically expressed by a system-level perspective or in terms of the intended global goal.<ref name="Casadei 2023" />
The aim of macroprogramming approaches is to support expressing the macroscopic interactive behaviour of a whole distributed system of computing devices or [[software agent|agents]] in a single program, or, similarly, to promote their [[collective intelligence]].<ref name="CI 2023">{{cite journal | last=Casadei | first=Roberto | title=Artificial Collective Intelligence Engineering: A Survey of Concepts and Perspectives | journal=Artificial Life | publisher=MIT Press | date=2023-11-01 | volume=29 | issue=4 | pages=433–467 | issn=0360-0300 | doi=10.1162/artl_a_00408 | arxiv=2304.05147 }}</ref>
It
Macroprogramming originated in the context of [[wireless sensor network]] programming<ref name="Newton Welsh 2004 p. ">{{cite conference |
{{Programming paradigms}}▼
and found renewed interest in the context of the [[Internet of Things]]
▲In [[computer science]], '''macroprogramming''' is a [[programming paradigm]] where programs for the individual components of a [[distributed system]] are compiled or interpreted from a ''macro-program'' expressed by a system-level perspective or in terms of the intended global goal.<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 | issn=0360-0300 | doi=10.1145/3579353 | page=}}</ref>
▲It has not to be confused with [[Macro (computer science)|macros]], the mechanism often found in programming languages (like [[C (programming language)|C]] or [[Scala (programming language)|Scala]]) to express substitution rules for program pieces.
▲Macroprogramming originated in the context of [[wireless sensor network]] programming<ref name="Newton Welsh 2004 p. ">{{cite conference | last=Newton | first=Ryan | last2=Welsh | first2=Matt | title=Region streams | publisher=ACM Press | publication-place=New York, New York, USA | year=2004 | doi=10.1145/1052199.1052213 | page=}}</ref> <ref name="Newton Morrisett Welsh 2007 p. ">{{cite conference | last=Newton | first=Ryan | last2=Morrisett | first2=Greg | last3=Welsh | first3=Matt | title=The regiment macroprogramming system | publisher=ACM Press | publication-place=New York, New York, USA | year=2007 | doi=10.1145/1236360.1236422 | page=}}</ref> <ref name="Gummadi Gnawali Govindan 2005 pp. 126–140">{{cite book | last=Gummadi | first=Ramakrishna | last2=Gnawali | first2=Omprakash | last3=Govindan | first3=Ramesh | title=Distributed Computing in Sensor Systems | chapter=Macro-programming Wireless Sensor Networks Using Kairos | publisher=Springer Berlin Heidelberg | publication-place=Berlin, Heidelberg | year=2005 | isbn=978-3-540-26422-4 | issn=0302-9743 | doi=10.1007/11502593_12 | pages=126–140}}</ref>
▲and found renewed interest in the context of the [[Internet of Things]] <ref name="Júnior Santana Bulcão-Neto Porter 2022 pp. 54–65">{{cite journal | last=Júnior | first=Iwens G. S. | last2=Santana | first2=Thalia S. de | last3=Bulcão-Neto | first3=Renato de F. | last4=Porter | first4=Barry F. | title=The state of the art of macroprogramming in IoT: An update | journal=Journal of Internet Services and Applications | publisher=Sociedade Brasileira de Computacao - SB | volume=13 | issue=1 | date=2022-11-18 | issn=1869-0238 | doi=10.5753/jisa.2022.2372 | pages=54–65}}</ref> and [[swarm robotics]] <ref name="Mottola Picco 2011 pp. 1–51">{{cite journal | last=Mottola | first=Luca | last2=Picco | first2=Gian Pietro | title=Programming wireless sensor networks | journal=ACM Computing Surveys | publisher=Association for Computing Machinery (ACM) | volume=43 | issue=3 | year=2011 | issn=0360-0300 | doi=10.1145/1922649.1922656 | pages=1–51}}</ref> <ref name="Casadei 2023" />.
Macroprogramming shares similar goals (related to programming a system by a global perspective) with [[multitier programming]], [[choreographic programming]], and [[aggregate computing]].
Line 14:
== Context and motivation ==
Programming [[distributed systems]], [[multi-agent systems]], and [[collectives]] of software agents (e.g., [[swarm robotics|robotic swarms]]) is difficult, for many issues (like communication, concurrency, and failure) have to be properly considered. In particular, a general recurrent problem is how to induce the intended global behaviour by defining the behaviour of the individual components or agents involved. The problem can be addressed through learning approaches, such as [[multi-agent reinforcement learning]], or by manually defining the control program driving each component. However, addressing the problem by a fully individual (or
== Examples ==
Line 20:
=== ScaFi ===
The following program in the ScaFi aggregate programming language <ref name="Casadei Viroli Aguzzi Pianini 2022 p=101248">{{cite journal |
<syntaxhighlight lang="scala" line="1">
Line 32:
def channel(src: Boolean, dest: Boolean, width: Double): Boolean =
dilate(
type OB[T] = Builtins.Bounded[T]
Line 43:
} } }._2
def
G[Double](source, 0, _ + nbrRange(), nbrRange())
Line 49:
G[V](source, field, x=>x, nbrRange())
def
broadcast(source, gradient(target))
Line 56:
}
</syntaxhighlight>
What is interesting to note is that the <code>channel</code> function, as well as the functions that are used to implement it, namely <code>distanceTo</code>, <code>distanceBetween</code>, <code>dilate</code>, <code>broadcast</code> etc.
can be interpreted not just in terms of the individual behaviour of a device, but rather ''by a macroscopic perspective''.
In fact, for instance, <code>distanceTo(s)</code> is used to compute the field of minimum distances from the closest device for which expression <code>s</code> yields <code>true</code>: this is effectively a ''distributed data structure'' that is sustained through processing ''and'' communication with neighbours, in a self-organising way.
Semantically, such functions define a macro-level (or collective) behaviour that yields a macro-level (or collective) data structure. Such macro-level functions/behaviours can be ''composed'' together to obtain another more complex macro-level function/behaviours.
=== Regiment ===
The following program in the Regiment language <ref name="Newton Morrisett Welsh 2007 p. "
<syntaxhighlight lang="prolog" line="1">
Line 73 ⟶ 78:
BASE <- avgSignal % move such information to the base station
</syntaxhighlight>
=== PyoT ===
The following program in PyoT <ref name="Azzara Alessandrelli Bocchino Petracca 2014 p. ">{{cite conference |
<syntaxhighlight lang="python" line="1">
temperatures = Resource.objects.filter(title=
results = [temp.GET() for temp in temperatures]
avg = sum
TEMP_THRESHOLD = 24
if avg > TEMP_THRESHOLD:
Resource.objects.get(title=
</syntaxhighlight>
=== TinyDB ===
In TinyDB
<syntaxhighlight lang="sql" line="1">
SELECT nodeId , temperature WHERE temperature > k FROM sensors SAMPLE PERIOD 5 minutes
</syntaxhighlight>
== See also ==
Line 108 ⟶ 110:
{{reflist}}
▲{{Programming paradigms navbox}}
[[Category:Programming paradigms]]
[[Category:Programming languages]]
[[Category:Distributed computing]]
[[Category:Articles with example Python (programming language) code]]
[[Category:Articles with example Scala code]]
|