Collective adaptive systems (CAS) 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. Understanding and designing CAS and, most of all, modelling the interactions of their components, is a difficult but important endeavour. We propose a language-based approach for programming the interactions in CAS by relying on attribute-based communication and on a calculus we call AbC. An AbC system consists of a set of parallel components each of which is equipped with a set of attributes. Communication among components takes place in an implicit multicast fashion, and links are dynamically established by taking into account “connections” as determined by predicates over their attributes. We introduce syntax and semantics of AbC, and show how its linguistic primitives can be used to program complex and sophisticated variant of the well-known problems. We also illustrate the expressive power of attribute-based communication by showing how classical communication paradigms such as group-based, publish/subscribe-based and channel-based communication can be naturally modelled with AbC and argue that the general concept of attribute-based communication can be exploited to provide a unifying framework to encompass different communication models and interaction patterns.