\chapter{Prelude}%
\label{chp:introduction}
\begin{chapterabstract}
- This chapter introduces the contents of the thesis and a reading guide.
- Furthermore, it provides background material on \glsxtrlong{IOT}, \glsxtrlongpl{DSL}, and \glsxtrlong{TOP}; and a detailed overview of the contributions.
- It also gives a brief introduction to two \gls{TOP} languages: \gls{ITASK} and \gls{MTASK}.
+ This chapter:
+ \begin{itemize}
+ \item introduces the topic and research ventures of this dissertation;
+ \item shows a reading guide;
+ \item provides background material on \glsxtrlong{IOT}, \glsxtrlongpl{DSL}, \glsxtrlong{TOP}, and the \gls{TOP} languages \gls{ITASK} and \gls{MTASK} in particular;
+ \item and concludes with a detailed overview of the contributions.
+ \end{itemize}
\end{chapterabstract}
There are at least 13.4 billion devices connected to the internet at the time of writing\footnote{\url{https://transformainsights.com/research/tam/market}, accessed on: \formatdate{13}{10}{2022}}.
-These devices sense, act, or otherwise interact with people, other computers, and the world surrounding us.
-Notwithstanding the substantial variety among these devices, they have one thing in common: they are all require software to operate.
+Each and every one of those devices senses, acts, or otherwise interacts with people, other computers, and the environment surrounding us.
+Even though there is a substantial variety among these devices, they have one thing in common: they all computers to some degree and for this reason require software to operate.
An increasing amount of these connected devices are so-called \emph{edge devices} that operate in the \gls{IOT}.
-Typically these edge devices are small microcontrollers containing sensors and actuators to interact with the physical world.
-Microcontrollers are integrated circuits containing a microprocessor designed for use in embedded applications.
-The edge devices come in many different types and they differ substantially from the other devices in the system.
-Consequently, programming \gls{IOT} systems is very complex and error prone.
-Hence, an \gls{IOT} programmer has to program each device and their interoperation using different programming paradigms, programming languages, and abstraction levels resulting in semantic friction.
-
-This thesis introduces research on the many aspects of orchestrating \gls{IOT} systems using \gls{TOP}.
-\Gls{TOP} is a innovative tierless programming paradigm for programming multi-tier interactive systems using a single declarative specification of the work that needs to be done.
-Using advanced compiler technologies, much of the internals and communication of multi-tier applications is automatically generated and the result of compilation is a ready-for-work application.
-Unfortunately, because the abstraction level is so high, the hardware requirements are too excessive to be suitable for the average edge device.
-
-This is where \glspl{DSL} come into play.
-\Glspl{DSL} are languages created with a specific domain in mind.
-Consequently, domain knowledge does not have to be expressed in the language itself but they can be built-in features, thus drastically reducing the hardware requirements even with high levels of abstraction.
+Typically, these edge devices are powered by microcontrollers
+Microcontrollers contain integrated circuits accommodating a microprocessor designed for use in embedded applications.
+Typical microprocessors therefore are tiny in size; have little memory; contain a slow, but energy efficient processor; and allow for a lot of connectivity to connect peripherals such as sensors and actuators to interact with their surroundings.
+%
+%\begin{figure}[ht]
+% \centering
+% \includegraphics[width=.4\linewidth]{esp}
+% \caption{A typical ESP32 microcontroller prototyping board.}%
+% \label{fig:esp_prototype}
+%\end{figure}
+
+Edge devices come in numerous types, differing substantially from the other devices in the system.
+An \gls{IOT} programmer has to program each device and their interoperation using different programming paradigms, programming languages, and abstraction levels resulting in semantic friction.
+Programming and maintaining \gls{IOT} systems is therefore a very complex and an error-prone process.
+
+This thesis introduces research on taming these complex \gls{IOT} systems using \gls{TOP}.
+\Gls{TOP} is an innovative tierless programming paradigm for programming multi-tier interactive systems using a single declarative specification of the work that needs to be done.
+By utilising advanced compiler technologies, much of the internals, communication, and interoperation of the multi-tier applications is automatically generated.
+The result of this compilation is a ready-for-work application.
+Unfortunately, because the abstraction level is so high, the hardware requirements are too excessive for a general purpose \gls{TOP} system to be suitable for the average edge device.
+
+This is where \glspl{DSL} are brought into play.
+\Glspl{DSL} are programming languages created with a specific domain in mind.
+Consequently, domain jargon does not have to be expressed in the language itself, but they can be built-in features.
+As a result, the hardware requirements can be drastically lower even with high levels of abstraction.
+
+Using \gls{MTASK}, a novel domain-specific \gls{TOP} \gls{DSL} fully integrated with \gls{ITASK}, all layers of the \gls{IOT} can be orchestrated from a single source.
\section{Reading guide}
+The thesis is presented as a purely functional rhapsody.
On Wikipedia, a musical rhapsody is defined as follows \citep{wikipedia_contributors_rhapsody_2022}:
\begin{quote}\emph{%
A \emph{rhapsody} in music is a one-movement work that is episodic yet integrated, free-flowing in structure, featuring a range of highly contrasted moods, colour, and tonality.}
\end{quote}
-This thesis is structured as a pure functional rhapsody containing three episodes barded by the introduction and conclusion (\cref{chp:introduction,chp:conclusion}).
-\Cref{prt:dsl} is a paper-based---otherwise known as cumulative---episode providing insight in advanced \gls{DSL} embedding techniques.
+The three episodes are barded by the introduction and conclusion (\cref{chp:introduction,chp:conclusion}).
+\Cref{prt:dsl} is a paper-based---otherwise known as cumulative---episode providing insight in advanced \gls{DSL} embedding techniques for \glspl{FP}.
The chapters are readable independently.
\Cref{prt:top} is a monograph showing \gls{MTASK}, a \gls{TOP} \gls{DSL} for the \gls{IOT}.
Hence, the chapters are best read in order.
The following sections provide background material on the \gls{IOT}, \glspl{DSL}, and \gls{TOP} after which a detailed overview of the contributions is presented.
Text typeset as \texttt{teletype} represents source code.
-Standalone source code listings are used are marked with the programming language used.
-For the \gls{FP} language \gls{CLEAN}, a guide tailored to \gls{HASKELL} programmers is available as in \cref{chp:clean_for_haskell_programmers}.
+Standalone source code listings are used are marked by the programming language used.
+Specifically for the \gls{FP} language \gls{CLEAN}, a guide tailored to \gls{HASKELL} programmers is available in \cref{chp:clean_for_haskell_programmers}.
-\section{Internet of things}\label{sec:back_iot}
+\section{\texorpdfstring{\Glsxtrlong{IOT}}{Internet of things}}\label{sec:back_iot}
The \gls{IOT} is growing rapidly and it is changing the way people and machines interact with the world.
While the term \gls{IOT} briefly gained interest around 1999 to describe the communication of \gls{RFID} devices \citep{ashton_internet_1999,ashton_that_2009}, it probably already popped up halfway the eighties in a speech by \citet{peter_t_lewis_speech_1985}:
The perception layer---also called edge layer---collects the data and interacts with the environment.
It consists of edge devices such as microcontrollers equipped with various sensors and actuators.
-In home automation this layer consists of all the devices hosting the sensors and actuators such as a smart lightbulb, an actuator to open a door or a temperature and humidity sensor.
+In home automation this layer consists of all the devices hosting the sensors and actuators such as a smart light bulb, an actuator to open a door or a temperature and humidity sensor.
All layers are connected using the network layer.
In many applications this is implemented using conventional networking techniques such as WiFi or Ethernet.
However, networks or layers on top of it---tailored to the needs of the specific interconnection between layers---have been increasingly popular.
-Examples of this are \gls{BLE}, LoRa, ZigBee, LTE-M, or \gls{MQTT} for connecting the perception layer to the application layer and techniques such as HTTP, AJAX, and WebSocket for connecting the presentation layer to the application layer.
+Examples of this are BLE, LoRa, ZigBee, LTE-M, or \gls{MQTT} for connecting the perception layer to the application layer and techniques such as HTTP, AJAX, and WebSocket for connecting the presentation layer to the application layer.
Across the layers, the devices are a large heterogeneous collection of different platforms, protocols, paradigms, and programming languages often resulting in impedance problems or semantic friction between layers when programming \citep{ireland_classification_2009}.
Even more so, perception layer itself often is a heterogeneous collections of microcontrollers in itself as well, each having their own peculiarities, language of choice, and hardware interfaces.
The dichotomous approach is embedding the \gls{DSL} in a host language, i.e.\ \glspl{EDSL} \citep{hudak_modular_1998}.
By defining the language as constructs in the host language, much of the machinery is inherited and the cost of creating embedded languages is very low.
-There is more linguistic reuse~\cite{krishnamurthi_linguistic_2001}.
-There are however two sides to the this coin.
+There is more linguistic reuse \citep{krishnamurthi_linguistic_2001}.
+However, there are two sides to this coin.
If the syntax of the host language is not very flexible, the syntax of the \gls{DSL} may become clumsy.
Furthermore, errors shown to the programmer may be larded with host language errors, making it difficult for a non-expert of the host language to work with the \gls{DSL}.
Pure \gls{FP} languages are especially suitable for hosting embedded \glspl{DSL} because they have strong and versatile type systems, minimal but flexible syntax and offer referential transparency.
Furthermore, a task is observable which means it is possible to observe a---partial---result during execution and act upon it by for example starting new tasks.
Examples of tasks are filling in a form, sending an email, reading a sensor or even doing a physical task.
\item[\Glsxtrshortpl{SDS} (resource access):]
- Tasks can communicate using task values but this imposes a problem in many collaboration patterns where tasks that are not necessarily related need to share data.
- Tasks can also share data using \glspl{SDS}, an abstraction over any data.
+ Tasks can communicate using task values, some collaboration require tasks that are not necessarily related need to share data.
+ Hence, tasks can also share data using \glspl{SDS}, an abstraction over any data.
An \gls{SDS} can represent typed data stored in a file, a chunk of memory, a database \etc.
\Glspl{SDS} can also represent external impure data such as the time, random numbers or sensory data.
Similar to tasks, transformation and combination of \glspl{SDS} is possible.
Special combinators (e.g.\ \cleaninline{@>>} at \cref{lst:task_ui}) are available to tweak the \gls{UI} afterwards.
\begin{figure}[ht]
- \includegraphics[width=.32\linewidth]{person0}
- \includegraphics[width=.32\linewidth]{person1}
- \includegraphics[width=.32\linewidth]{person2}
+ \includegraphics[width=.325\linewidth]{person0g}
+ \includegraphics[width=.325\linewidth]{person1g}
+ \includegraphics[width=.325\linewidth]{person2g}
\caption{The \gls{UI} for entering a person in \gls{ITASK}.}%
\label{fig:enter_person}
\end{figure}
\end{lstClean}
\subsection{\texorpdfstring{\Gls{MTASK}}{MTask}}
-This thesis uses \gls{ITASK} in conjunction with an innovative \gls{TOP} language designed for defining interactive systems for \gls{IOT} edge devices called \gls{MTASK} \citep{koopman_task-based_2018}.
+This thesis uses \gls{ITASK} in conjunction with \gls{MTASK}, an innovative \gls{TOP} language designed for defining interactive systems for \gls{IOT} edge devices \citep{koopman_task-based_2018}.
It is written in \gls{CLEAN} as a multi-view \gls{EDSL} and hence there are multiple interpretations of the language of which the byte code compiler is the most relevant for this thesis.
From the terms in the \gls{TOP} language, a very compact binary representation of the work that needs to be done is compiled.
This specification is then sent to a device that runs the \gls{MTASK} \gls{RTS}, a domain-specific \gls{TOP} engine implemented as a feather-light domain-specific \gls{OS}.
\Gls{MTASK} is seamlessly integrated with \gls{ITASK}, it allows the programmer to define all layers of an \gls{IOT} system from a single declarative specification.
-\todo[inline]{Is this example useful? Add more detailed explanation with line numbers?}
-\Cref{lst:intro_blink} shows an \gls{MTASK}\slash{}\gls{ITASK} application for an interactive application where the \gls{LED} on the microcontroller blinks every user-specified interval.
-Using a \glspl{SDS} defined in \gls{ITASK}, the blinking frequency of an \gls{LED} connected to \gls{GPIO} pin 13 can be changed on the fly.
+\todo[inline]{Is this example useful? I think it's too technical}
+\Cref{lst:intro_blink} shows an interactive \gls{MTASK}\slash{}\gls{ITASK} application for blinking \pgls{LED} on the microcontroller every user-specified interval.
+\Crefrange{lst:intro:itask_fro}{lst:intro:itask_to} show the \gls{ITASK} part.
+First a \gls{SDS} is defined to communicate the blinking interval, then the \gls{MTASK} is connected using \cleaninline{withDevice}.
+Once connected, the \cleaninline{intBlink} task is sent to the device (\cref{lst:intro_liftmtask}) and in parallel, the value of the interval \gls{SDS} can be updated using an editor (\cref{lst:intro_editor}).
+The \cleaninline{intBlink} task (\crefrange{lst:intro:mtask_fro}{lst:intro:mtask_to}) is the \gls{MTASK} part of the application that has its own tasks, \glspl{SDS}, and \gls{UOD}.
+This task first defines \gls{GPIO} pin 13 to be of the output type (\cref{lst:intro:declarePin}) followed by lifting the \gls{ITASK} \gls{SDS} to an \gls{MTASK} \gls{SDS} (\cref{lst:intro:liftsds}).
+The main expression of the program calls the \cleaninline{blink} function with the initial state.
+This function on \crefrange{lst:intro:blink_fro}{lst:intro:blink_to} first reads the interval \gls{SDS}, waits the specified delay, writes the state to the \gls{GPIO} pin and calls itself recursively using the inverse of the state.
\begin{lstClean}[numbers=left,caption={\Gls{MTASK}\slash{}\gls{ITASK} interactive blinking.},label={lst:intro_blink}]
-interactiveBlink :: Task Int
+interactiveBlink :: Task Int[+\label{lst:intro:itask_fro}+]
interactiveBlink =
- withShared 500 \iInterval->
+ withShared 500 \iInterval->[+\label{lst:intro_withshared}+]
withDevice {TCPSettings | host = ..., port = ...} \dev->
- liftmTask (intBlink iInterval) dev
- -|| Hint "Interval (ms)" @>> updateSharedInformation [] iInterval
+ liftmTask (intBlink iInterval) dev[+\label{lst:intro_liftmtask}+]
+ -|| Hint "Interval (ms)" @>> updateSharedInformation [] iInterval[+\label{lst:intro_editor}+][+\label{lst:intro:itask_to}+]
-intBlink :: Shared sds Int -> MTask v Int | mtask, liftsds v & RWShared sds
+intBlink :: Shared sds Int -> MTask v Int | mtask, liftsds v & RWShared sds[+\label{lst:intro:mtask_fro}+]
intBlink iInterval =
- declarePin D13 PMOutput \d13->
- liftsds \mInterval=iInterval
- In fun \blink=(\st->
- writeD d13 st
- >>|. getSds mInterval
- >>=. \i->delay i
- >>|. blink (Not st))
- In {main = blink true}
+ declarePin D13 PMOutput \d13->[+\label{lst:intro:declarePin}+]
+ liftsds \mInterval=iInterval[+\label{lst:intro:liftsds}+]
+ In fun \blink=(\st->[+\label{lst:intro:blink_fro}+]
+ getSds mInterval >>=. \i->delay i
+ >>|. writeD d13 st >>|. blink (Not st))[+\label{lst:intro:blink_to}+]
+ In {main = blink true}[+\label{lst:intro:mtask_to}+]
\end{lstClean}
\subsection{Other \texorpdfstring{\glsxtrshort{TOP}}{TOP} languages}
This paper was an extension of my Master's thesis \citep{lubbers_task_2017}.
It shows how a simple imperative variant of \gls{MTASK} was integrated with \gls{ITASK}.
- While the language was a lot different than later versions, the integration mechanism is still used in \gls{MTASK} today.
+ While the language was a lot different from later versions, the integration mechanism is still used in \gls{MTASK} today.
% \paragraph{Contribution}
% The research in this paper and writing the paper was performed by me, though there were weekly meetings with Pieter Koopman and Rinus Plasmeijer in which we discussed and refined the ideas.
\item \emph{Multitasking on Microcontrollers using Task Oriented Programming} \citep{lubbers_multitasking_2019}\footnote{%
\chapter{Edge device programming}%
\label{chp:top4iot}
-\todo{betere chapter naam}
\begin{chapterabstract}
- This chapter introduces \gls{MTASK} and puts it into perspective compared to traditional microcontroller programming.
- It does so by showing how to program microcontrollers using \gls{ARDUINO}, a popular microcontroller framework, and the equivalent \gls{MTASK} programs.
+ This chapter:
+ \begin{itemize}
+ \item shows how to create the \emph{Hello World!} application for microcontrollers using \gls{ARDUINO};
+ \item extends this idea with multithreading, demonstrating the difficulty programming multi-tasking applications;
+ \item describes a comparative variant in \gls{MTASK} and shows that upgrading to a multi-tasking variant is straightforward
+ \item demonstrates that the complexity of running multiple tasks;
+ \item and concludes with a short history of \gls{MTASK}'s development.
+ \end{itemize}
\end{chapterabstract}
-The edge layer of \gls{IOT} system mostly consists of microcontrollers that require a different method of programming.
+The edge layer of \gls{IOT} system mostly consists of microcontrollers.
+Microcontrollers are tiny computers designed specifically for embedded applications.
+They therefore only have a soup\c{c}on of memory, have a slow processor, come with many energy efficient sleep modes and have a lot of peripheral support such as \gls{GPIO} pins.
Usually, programming microcontrollers requires an elaborate multi-step toolchain of compilation, linkage, binary image creation, and burning this image onto the flash memory of the microcontroller in order to compile and run a program.
The programs are usually cyclic executives instead of tasks running in an operating system, i.e.\ there is only a single task that continuously runs on the bare metal.
+\Cref{tbl:mcu_laptop} compares the hardware properties of a typical laptop with two very popular microcontrollers.
+
+\begin{table}
+ \begin{tabular}{llll}
+ \toprule
+ & Laptop & Atmega328P & ESP8266\\
+ \midrule
+ CPU speed & \qtyrange{2}{4}{\giga\hertz} & \qty{16}{\mega\hertz} & \qty{80}{\mega\hertz} or \qty{160}{\mega\hertz}\\
+ \textnumero{} cores & \numrange{4}{8} & 1 & 1\\
+ Storage & \qty{1}{\tebi\byte} & \qty{32}{\kibi\byte} & \qtyrange{0.5}{4}{\mebi\byte}\\
+ \gls{RAM} & \qtyrange{4}{16}{\gibi\byte} & \qty{2}{\kibi\byte} & \qty{160}{\kibi\byte}\\
+ Power & \qtyrange{50}{100}{\watt} & \qtyrange{0.13}{250}{\milli\watt} & \qtyrange{0.1}{350}{\milli\watt}\\
+ \bottomrule
+ \end{tabular}
+ \caption{Hardware characteristics of typical microcontrollers and laptops.}%
+ \label{tbl:mcu_laptop}
+\end{table}
+
Each type of microcontrollers comes with vendor-provided drivers, compilers and \glspl{RTS} but there are many platform that abstract away from this such as \gls{MBED} and \gls{ARDUINO} of which \gls{ARDUINO} is specifically designed for education and prototyping and hence used here.
The popular \gls{ARDUINO} \gls{C}\slash\gls{CPP} dialect and accompanying libraries provide an abstraction layer for common microcontroller behaviour allowing the programmer to program multiple types of microcontrollers using a single language.
Originally it was designed for the in-house developed open-source hardware with the same name but the setup allows porting to many architectures.
Traditionally, the first program that one writes when trying a new language is the so called \emph{Hello World!} program.
This program has the single task of printing the text \emph{Hello World!} to the screen and exiting again, useful to become familiarised with the syntax and verify that the toolchain and runtime environment is working.
On microcontrollers, there usually is no screen for displaying text.
-Nevertheless, almost always there is a built-in monochrome $1\times1$ pixel screen, namely an \gls{LED}.
+Nevertheless, almost always there is a built-in monochrome $1\times1$ pixel screen, namely \pgls{LED}.
The \emph{Hello World!} equivalent on microcontrollers blinks this \gls{LED}.
\Cref{lst:arduinoBlink} shows how the logic of a blink program might look when using \gls{ARDUINO}'s \gls{C}\slash\gls{CPP} dialect.
Similar to peripherals (see \cref{sssec:peripherals}), they are constructed at the top level and are accessed through interaction tasks.
The \cleaninline{getSds} task yields the current value of the \gls{SDS} as an unstable value.
This behaviour is similar to the \cleaninline{watch} task in \gls{ITASK}.
-Writing a new value to an \gls{SDS} is done using \cleaninline{setSds}.
+Writing a new value to \pgls{SDS} is done using \cleaninline{setSds}.
This task yields the written value as a stable result after it is done writing.
-Getting and immediately after setting an \gls{SDS} is not necessarily an \emph{atomic} operation in \gls{MTASK} because it is possible that another task accesses the \gls{SDS} in between.
+Getting and immediately after setting \pgls{SDS} is not necessarily an \emph{atomic} operation in \gls{MTASK} because it is possible that another task accesses the \gls{SDS} in between.
To circumvent this issue, \cleaninline{updSds} is created, this task atomically updates the value of the \gls{SDS}.
The \cleaninline{updSds} task only guarantees atomicity within \gls{MTASK}.
Tasks can exchange information via \glspl{SDS} \citep{ParametricLenses}.
All tasks involved can atomically observe and change the value of a typed \gls{SDS}, allowing more flexible communication than with task combinators.
\Glspl{SDS} offer a general abstraction of data shared by different tasks, analogous to variables, persistent values, files, databases and peripherals like sensors. Combinators compose \glspl{SDS} into a larger \gls{SDS}, and
-parametric lenses define a specific view on an \gls{SDS}.
+parametric lenses define a specific view on \pgls{SDS}.
\subsection{The \texorpdfstring{\glsentrytext{ITASK}}{iTask} \texorpdfstring{\glsxtrlong{EDSL}}{eDSL}}%
\label{sec_t4t:itasks}
A typical \gls{IOT} system goes beyond a web application by incorporating a distributed set of sensor nodes each with a collection of sensors or actuators. That is, they add the perception and network layers in \cref{fig_t4t:iot_arch}. If the sensor nodes have the computational resources to support an \gls{ITASK} server, as a Raspberry Pi does, then \gls{ITASK} can also be used to implement these layers, and integrate them with the application and presentation layers tierlessly.
As an example of tierless \gls{IOT} programming in \gls{CLEAN}\slash\gls{ITASK} \cref{lst_t4t:itaskTempFull} shows a complete temperature sensing system with a server and a single sensor node (\gls{CRTS}), omitting only the module name and imports.
-It is similar to the SimpleTempSensor and TempHistory programs above, for example \cleaninline{devTask} repeatedly sleeps and records temperatures and times, and \cleaninline{mainTask} displays the temperatures on the web page in \cref{fig_t4t:cwtsweb}. There are some important differences, however. The \cleaninline{devTask} (\crefrange{lst_t4t:itaskTempFull:sensorfro}{lst_t4t:itaskTempFull:sensorto}) executes on the sensor node and records the temperatures in a standard timestamped (lens on) an \gls{SDS}: \cleaninline{dateTimeStampedShare} \cleaninline{latestTemp}.
+It is similar to the SimpleTempSensor and TempHistory programs above, for example \cleaninline{devTask} repeatedly sleeps and records temperatures and times, and \cleaninline{mainTask} displays the temperatures on the web page in \cref{fig_t4t:cwtsweb}. There are some important differences, however. The \cleaninline{devTask} (\crefrange{lst_t4t:itaskTempFull:sensorfro}{lst_t4t:itaskTempFull:sensorto}) executes on the sensor node and records the temperatures in a standard timestamped (lens on) \pgls{SDS}: \cleaninline{dateTimeStampedShare} \cleaninline{latestTemp}.
The \cleaninline{mainTask} (\cref{lst_t4t:itaskTempFull:main}) executes on the server: it starts \cleaninline{devTask} as an asynchronous task on the specified sensor node (\cref{lst_t4t:itaskTempFull:startdevtask}) and then generates a web page to display the latest temperature and time (\cref{lst_t4t:itaskTempFull:displaystart,lst_t4t:itaskTempFull:displayend}).
The \cleaninline{tempSDS} is very similar to the \cleaninline{measurementsSDS} from the previous listings.
The program uses the same shares \cleaninline{tempSDS} and~\cleaninline{latestTemp} as \gls{CRTS}, and for completeness we repeat those definitions.
The body of \cleaninline{devTask} is the \gls{MTASK} slice of the program (\crefrange{lst_t4t:mtasktemp:DHT}{lst_t4t:mtasktemp:setSds}).
With \cleaninline{DHT} we again create a temperature sensor object \cleaninline{dht}.
-The \gls{ITASK} \gls{SDS} \cleaninline{latestTemp} is first transformed to a \gls{SDS} that accepts only temperature values,
+The \gls{ITASK} \gls{SDS} \cleaninline{latestTemp} is first transformed to \pgls{SDS} that accepts only temperature values,
the \cleaninline{dateTimeStampedShare} adds the data via a lens.
The \cleaninline{mapRead} adjusts the read type.
This new \gls{SDS} of type \cleaninline{Real} is lifted to the \gls{MTASK} program with \cleaninline{liftsds}.
In \gls{PRS} the sensor node program is written in \gls{PYTHON}, a language far less focused on minimising memory usage than \gls{MICROPYTHON}. For example an object like a string is larger in \gls{PYTHON} than in \gls{MICROPYTHON} and consequently does not support all features such as \emph{f-strings}.
Furthermore, not all advanced \gls{PYTHON} feature regarding classes are available in \gls{MICROPYTHON}, i.e.\ only a subset of the \gls{PYTHON} specification is supported \citep{diffmicro}.
-In summary the sensor node code generated by both tierless languages, \gls{ITASK} and \gls{MTASK}, is sufficiently memory efficient for the target sensor node hardware. Indeed, the maximum residencies of the \gls{CLEAN} sensor node code is less than the corresponding hand-written (Micro)\gls{PYTHON} code. Of course in a tiered stack the hand-written code can be more easily optimised to minimise residency, and this could even entail using a memory efficienthat thet language like \gls{C}\slash\gls{CPP}. However, such optimisation requires additional developer effort, and a new language would introduce additional semantic friction.
+In summary the sensor node code generated by both tierless languages, \gls{ITASK} and \gls{MTASK}, is sufficiently memory efficient for the target sensor node hardware. Indeed, the maximum residencies of the \gls{CLEAN} sensor node code is less than the corresponding hand-written (Micro)\gls{PYTHON} code. Of course in a tiered stack the hand-written code can be more easily optimised to minimise residency, and this could even entail using a memory efficient language like \gls{C}\slash\gls{CPP}. However, such optimisation requires additional developer effort, and a new language would introduce additional semantic friction.
\paragraph{Power} Sensor nodes and sensors are designed to have low power demands, and this is particularly important if they are operating on batteries. The grey literature consensus is that with all sensors enabled a sensor node should typically have sub-\qty{1}{\watt} peak power draw.
The \gls{WEMOS} sensor nodes used in \gls{CWS} and \gls{PWS} have the low power consumption of a typical embedded device: with all sensors enabled, they consume around \qty{0.2}{\watt}.
\end{table}
\paragraph{Code proportions.}
-Comparing the percentages of code required to implement the smart campus functionalities normalises the data and avoids some issues when comparing \gls{SLOC} for different programming languages, and especially for languages with different paradigms like object-oriented \gls{PYTHON} and functional \gls{CLEAN}. \Cref{fig_t4t:multipercentage} shows the percentage of the total \gls{SLOC} required to implement the smart campus functionalities in each of the four implementations, and is computed from the data in \cref{table_t4t:multi}. It shows that there are significant differences between the percentage of code for each functionality between the tiered and tierless implementations. For example 17\% of the tiered implementations specifies communication, whereas this requires only 3\% of the tierless implementations, i.e.\ 6$\times$ less. We explore the reasons for this in \cref{sec_t4t:Communication}. The other major difference is the massive percentage of Database Interface code in the tierless implementations: at least 47\%. The smart campus specification required a standard DBMS, and the \gls{CLEAN}\slash\gls{ITASK} SQL interface occupies some 78 \gls{SLOC}. While this is a little less than the 106 \gls{SLOC} used in \gls{PYTHON} (\cref{table_t4t:multi}), it is a far higher percentage of systems with total codebases of only around 160 \gls{SLOC}. Idiomatic \gls{CLEAN}/\gls{ITASK} would use high level abstractions to store persistent data in an \gls{SDS}, requiring just a few \gls{SLOC}.
+Comparing the percentages of code required to implement the smart campus functionalities normalises the data and avoids some issues when comparing \gls{SLOC} for different programming languages, and especially for languages with different paradigms like object-oriented \gls{PYTHON} and functional \gls{CLEAN}. \Cref{fig_t4t:multipercentage} shows the percentage of the total \gls{SLOC} required to implement the smart campus functionalities in each of the four implementations, and is computed from the data in \cref{table_t4t:multi}. It shows that there are significant differences between the percentage of code for each functionality between the tiered and tierless implementations. For example 17\% of the tiered implementations specifies communication, whereas this requires only 3\% of the tierless implementations, i.e.\ 6$\times$ less. We explore the reasons for this in \cref{sec_t4t:Communication}. The other major difference is the massive percentage of Database Interface code in the tierless implementations: at least 47\%. The smart campus specification required a standard DBMS, and the \gls{CLEAN}\slash\gls{ITASK} SQL interface occupies some 78 \gls{SLOC}. While this is a little less than the 106 \gls{SLOC} used in \gls{PYTHON} (\cref{table_t4t:multi}), it is a far higher percentage of systems with total codebases of only around 160 \gls{SLOC}. Idiomatic \gls{CLEAN}/\gls{ITASK} would use high level abstractions to store persistent data in \pgls{SDS}, requiring just a few \gls{SLOC}.
The total size of \gls{CWS} and \gls{CRS} would be reduced by a factor of two and the percentage of Database Interface code would be even less than in the tiered \gls{PYTHON} implementations.