What is Aggregate Computing[1]?
A macro-programming approach that defines the collective behavior of a heterogeneous set of devices in a self-organizing system.
Devices self-organize exchanging messages, abstracting from the communication approach thanks to alignment.
Based on the Field Calculus[2], operates by manipulating distributed data structures called fields.
[1] Beal, J., Pianini, D., Viroli, M. "Aggregate Programming for the Internet of Things." 2015.
[2] Audrito, G., Viroli, M., Damiani, F., Pianini, D., Beal, J. "A Higher-Order Calculus of Computational Fields." 2019.
Alignment[3]
Devices within the system that execute the same part of the Abstract Syntax Tree are aligned and capable of communication.
[3] G. Audrito, M. Viroli, F. Damiani, D. Pianini and J. Beal, “A Higher-Order Calculus of Computational Fields”
Simulating Aggregate Computing systems
Simulations are part of the development cycle.
Scalability limitation:
challenges in scaling simulations to thousands or more devices simultaneously.
Performance is paramount.
Low level language: FCPP [4]
Made for low-consumption devices.
Expected to be fast in simulations.
FCPP limitations:
- Non-friendly language;
- Aggregate base-mechanism not hidden.
For example

[4] G. Audrito, and G. Torta, "FCPP to aggregate them all."
Alternatives?
Build a custom language!
Domain Specific Language (DSL)
External DSL
- Self-contained language with custom syntax and semantics;
- Can be tailored to specific performance or scalability requirements;
- Harder to integrate with existing systems (needs custom tooling);
- Tougher learning curve.
or
Internal DSL
- Built on top of a host language;
- Takes advantage of its features, tools, and ecosystem.
- Reduced learning curve.
- Performances tied to the host language.
External DSL: Protelis [5]
Java-like standalone language.
Hides main aggregate computing mechanisms, such as alignment.
But
slower in complex programs, due to its compiler.
This limit can be overcome by leveraging on an internal DSL.
[5] D. Pianini, M. Viroli, and J. Beal, “Protelis: practical aggregate programming”
Internal DSL: ScaFi [6]
Scala-based internal DSL.
Alignment hidden at runtime doing stack investigation.
ScaFi limitations:
- base aggregate operations must be done inside specific contexts;
- not very performant, due to runtime alignment via stack inspection.
For example

[6] R. Casadei, M. Viroli, G. Aguzzi, and D. Pianini, “Scafi: A scala DSL and toolkit for aggregate programming”
Idea: use a Compiler Plugin
Annotates the aggregate program on a stack at compile time.
Devices with the same annotations in the stack are “aligned” and can communicate.
Pros:
- Expressivity untouched;
- No overhead of the classic approaches.
Meet Collektive
- Internal DSL in Kotlin Multiplatform;
- Alignment made automatically behind the scene through compiler plugin.
- Linked to the general purpose Alchemist [7] simulator, which can execute also Protelis and ScaFi programs.
First implementation of the prototype DSL used to develop experiments related to the morphogenesis of plants[8].
[7] D. Pianini, S. Montagna, and M. Viroli, “Chemical-oriented simulation of computational systems with ALCHEMIST”;
[8] A. Cortecchia, D. Pianini, G. Ciatto, and R. Casadei, "An Aggregate Vascular Morphogenesis Controller for Engingeered Self-Organising Spatial Structures".
Reference scenario
Channel with obstacles [8]:
an algorithm to build a redundant channel between two points in a meshed network,
avoiding obstacles and adapting to topology changes.
Results
- External DSLs (Protelis) has performance disadvantages in complex programs, respect to internal DSLs (Collektive & ScaFi);
- Compiler plugin optimizes performance between internal DSLs, thanks to the management of the alignment.
[8] R. Casadei, G. Fortino, D. Pianini, A. Placuzzi, C. Savaglio, and M. Viroli, “A methodology and simulation-based toolchain for estimating deployment performance of smart collective services at the edge"
Conclusion
This work demonstrates that the technology used within a tool affects program execution time.
Future works
- Further enhancing for efficient and faster execution across various platforms;
- Create a standard library of aggregate building blocks;
- Exploit the tool to the concept of "collective operating systems".