As a major approach for controlling electromagnetic (EM) waves, metamaterials have experienced an abundant and rapid development in the 21st century. They have provided flexible and powerful techniques for controlling EM waves and brought many unique applications that are difficult to realise with natural materials. With increasing demands on dynamic controls of the EM waves, many innovations have been conducted in both three-dimensional metamaterials and two-dimensional metasurfaces, in which the meta-atom has been gradually evolved from passive to active. In 2014, coding and digital mechanisms were initially introduced to the metamaterials, further advancing the appearance of digitally programmable metamaterials. The programmable metamaterials have shown great potentials in not only real-time manipulations of the EM waves, but also direct information processing on the EM wave level. In this article, we present an in-depth review of the programmable EM metamaterials and metasurfaces, focusing on the programmable features including theoretical concepts, implementing methods and applications in EM controls. We first give a short retrospect of traditional metamaterials and metasurfaces, followed by the concepts and detailed discussions of digital coding and field-programmable metamaterials. Then, we introduce space-domain, time-domain and space–time-domain programmable metamaterials and metasurfaces, mainly focusing on their theories, functionalities, experimental implementations, and system-level applications. Finally, we conclude the current advances of the programmable metamaterials and metasurfaces, and give a prospect for the future developments.