The development of reliable software for the internet of things (IoT) is difficult because IoT systems are dynamic, interactive, distributed, collaborative, multi-tiered, and multitasking in nature. The complexity is increased further by semantic friction that arises through different hardware and software characteristics between tiers. Many computers that operate in IoT systems are edge devices that interact with the environment using sensors and actuators. Edge devices are often powered by low-cost microcontrollers designed for embedded applications. They have little memory, unhurried processors, and are slow in communication but are also small and energy efficient. Task-oriented programming (TOP) can cope with the challenges of IoT programming. In TOP, the main building blocks are tasks, an abstract representation of work. During execution, the current value of the task is observable, and other tasks can act upon it. Collaboration patterns can be modelled by combining and transforming tasks into compound tasks. Programming edge devices benefits from TOP as well, but running such a system within the limitations of resource-constrained microcontrollers is not straightforward. This dissertation demonstrates how to include edge devices in TOP systems using domain-specific languages (DSLs). With these techniques, all tiers and their interoperation of an IoT system are specified in a single high-level source, language, paradigm, high abstraction level, and type system. First, I present advanced DSL embedding techniques. Then mTask is shown, a TOP DSL for IoT edge devices, embedded in iTask. Tasks are constructed and compiled at run time in order to allow tasks to be tailored to the current work requirements. The task is then sent to the device for interpretation. A device is programmed once with a lightweight domain-specific OS to be used in an mTask system. This OS executes tasks in an energy-efficient way and automates all communications and data sharing. All aspects of the mTask system are shown: example applications, language design, implementation details, integration with iTask, and green computing facilities such as automatic sleeping. Finally, tierless IoT programming is compared to traditional tiered programming. In tierless programming frameworks, the size of the code and the number of required programming languages is reduced significantly. By using a single paradigm and a system-wide type system, tierless programming reduces problems such as semantic friction; maintainability and robustness issues; and interoperation safety.