  Collective adaptive systems are new emerging computational systems consisting
of a large number of interacting components and featuring complex behaviour.
These systems are usually distributed, heterogeneous, decentralised and
interdependent, and are operating in dynamic and possibly unpredictable
environments. Finding ways to understand and design these systems and, most of
all, to model the interactions of their components, is a difficult but
important endeavour. In this article we propose a language-based approach for
programming the interactions of collective-adaptive systems by relying on
attribute-based communication; a paradigm that permits a group of partners to
communicate by considering their run-time properties and capabilities. We
introduce AbC, a foundational calculus for attribute-based communication and
show how its linguistic primitives can be used to program a complex and
sophisticated variant of the well-known problem of Stable Allocation in Content
Delivery Networks. Also other interesting case studies, from the realm of
collective-adaptive systems, are considered. We also illustrate the expressive
power of attribute-based communication by showing the natural encoding of other
existing communication paradigms into AbC.
