.
authorMart Lubbers <mart@martlubbers.net>
Mon, 9 Jan 2023 13:45:10 +0000 (14:45 +0100)
committerMart Lubbers <mart@martlubbers.net>
Mon, 9 Jan 2023 13:45:24 +0000 (14:45 +0100)
23 files changed:
asbook.tex
back/acknowledgements.tex
back/research_data_management.tex
back/samenvatting.tex
back/summary.tex
concl/concl.tex
dsl/class.tex
dsl/first.tex
intro/intro.tex
intro/lst/blink.icl
intro/lst/sharedlist.icl
intro/taskvalue.tex
other.bib
preamble.tex
self.bib
thesis.tex
top/4iot.tex
top/finale.tex
top/green.tex
top/img/sim.png [new file with mode: 0644]
top/imp.tex
top/lang.tex
tvt/tvt.tex

index f7228ca..a4a1cd7 100644 (file)
@@ -4,5 +4,6 @@
 \usepackage{pdfpages}
 
 \begin{document}
-\includepdf[landscape,booklet,pages={1-18}]{thesis.pdf}%chktex 29 chktex 8
+%\includepdf[landscape,booklet,pages={1-18}]{thesis.pdf}%chktex 29 chktex 8
+\includepdf[landscape,booklet,pages={1-}]{top/4iot.pdf}%chktex 29 chktex 8
 \end{document}
index d2e862e..60fd5a1 100644 (file)
@@ -7,31 +7,69 @@
 \chapter{Acknowledgements}%
 \label{chp:acknowledgements}
 %\begin{center}
-\noindent
-Funding: Teun de Groot, Ton van Heusden
+\noindent%
+While the research and writing carried out for this thesis was mostly done by me, it could not have been done without the support of many others.
 
-Supervisors: Pieter Koopman, Rinus Plasmeijer, Jan-Martin Jansen
+First of all I would like to thank Rinus Plasmeijer, Pieter Koopman, and Jan Martin Jansen for the supervision, I learned a lot from you, not only regarding academia but in many other aspects of life as well.
+The BEST people, Adrian Ramsingh, Jeremy Singer, and Phil Trinder for the fruitful collaboration, and the memorable trip to Glasgow.
+The CEFP/SusTrainable group, for offering a platform for the various summer schools I had the opportunity to teach; and not to mention the countless meetings, dinners, and drinks we had.
+The Royal Dutch Navy, in particular Teun de Groot and Ton van Heusden, for trusting me by funding the project.
+All the colleagues and others that I had the privilege of sharing an office with, meeting in conferences, interact with in the department, or work with in some other way:
+Arjan Oortgiese,
+Bas Lijnse,
+Ellie Kimenai,
+Fok Bolderheij,
+Hans-Nikolai Vie\ss{}mann,
+Ingrid Berenbroek,
+John van Groningen,
+Jurri\"en Stutterheim,
+László Domoslai,
+Marie-José van Diem,
+Markus Klinik,
+Peter Achten,
+Ralf Hinze,
+Simone Meeuwsen,
+Sjaak Smetsers,
+Steffen Michels,
+Sven-Bodo Scholz,
+Tim Steenvoorden.
+%
+The many students that allowed me to (co) supervise them in their theses:
+Arjen Nederveen,
+Colin de Roos,
+Dave Artz,
+Elina Antonova
+Erin van der Veen,
+Gijs Alberts,
+Haye B\"ohm,
+Matheus Amazonas Cabral de Andrade,
+Michel de Boer,
+Sjoerd Crooijmans,
+Willem de Vos.
 
-Co-authors: Jeremy Singer, Phil Trinder, Adrian Ramsingh, SusTrainable group
+I give special thanks to my mentors who never stopped having faith me:
+Jos Baack, Francisco Torreira, Franc Grootjen, Louis Vuurpijl, and Larry Caruthers.
 
-%Colleagues: Jurriën Stutterheim, Laszlo Domoslai, Arjan Oortgiese, Bas Lijnse, Steffen Michels, Markus Klinik, Tim Steenvoorden, Camil Staps, Hans-Nikolai Vie\ss{}mann, John van Groningen, Sven-Bodo Scholz, Sjaak Smetsers, Fok Bolderheij, Simone Meeuwsen, Peter Achten, Ingrid Berenbroek
-%
-%
-%\todo{Second assessor clients weglaten?: Willem, Dave, Gijs}
-%Students: Matheus Amazonas Cabral de Andrade, Haye B\"ohm, Erin van der Veen, Colin de Roos, Willem de Vos, Michel de Boer, Dave Artz, Sjoerd Crooijmans, Gijs Alberts, Arjen Nederveen, Elina Antonova
-%
-%Mentors: Jos Baack, Francisco Torreira, Franc Grootjen, the late Louis Vuurpijl, Ralf Hinze
-%
-%Friends: Pieter Wolfert (and Annerieke Wessels (and Anouk Neerincx)); Chris Kamphuis and Maudy Bijen; Koen Dercksen and Michelle Everard; George Gregoire; Larry Caruthers; Tim Hirschler; Emma Lindahl (nee Dahl); Truman Crandell;
-%\selectlanguage{russian}
-%Александер Барков;
-%\selectlanguage{british}
-%
-%Family: Parents (in law), brothers (in law), oma,
-%
-%Marie-José van Diem, Ellie Kimenai
+And of course my friends and acquaintances that supported me throughout the procses.
+Pieter Wolfert and Anouk Neerincx;
+Chris Kamphuis and Maudy Bijen;
+Koen Dercksen and Michelle Everard;
+Jules Kruijswijk en Nadia Klijn;
+George Gregoire;
+\selectlanguage{russian}Александер Барков\selectlanguage{british};
+Tim Hirschler;
+Emma Lindahl;
+Truman Crandell;
+Annerieke Wessels;
+Camil Staps.
+
+Finally I want to thank the ones closest to me.
+\selectlanguage{dutch}
+Elvira, Rosalie en Liselotte voor hun tomeloze geduld en ondersteuning wanneer dat nodig was.
+Mijn ouders in het bijzonder voor hun liefde en vertrouwen.
+Mijn Oma, broers, schoonfamilie en alle andere familieleden die op wat voor manier dan ook bijgedragen hebben.
+\selectlanguage{british}
 
-Finally I want to thank all anonymous reviewers for the indispensable comments, suggestions and remarks on all papers.
 %\end{center}
 \input{subfilepostamble}
 \end{document}
index e1ec602..db1d6d2 100644 (file)
@@ -7,7 +7,7 @@
 \chapter{Research Data Management}%
 \label{chp:research_data_management}
 
-This thesis research has been carried out under the research data management policy of the Institute for Computing and Information Science of Radboud University, the Netherlands.\footnote{\url{https://www.ru.nl/icis/research-data-management/}, last accessed \formatdate{20}{1}{2020}.}
+This thesis research has been carried out under the research data management policy of the Institute for Computing and Information Science of Radboud University, the Netherlands\footnote{\refurl{https://www.ru.nl/icis/research-data-management/}{\formatdate{20}{1}{2020}}}.
 
 The following research datasets have been produced during this PhD research:
 \begin{itemize}
@@ -19,7 +19,7 @@ The following research datasets have been produced during this PhD research:
                        \item \Fullref{sec:classy_reprise}:
                                \begin{itemize}
                                        \item \rdmentry{\mlubbers}{2022}
-                                               {\todo[inline]{replace with actual name}}
+                                               {Library and examples for enhanced classy deep embedding}
                                                {Zenodo}{10.5281/zenodo.7277498} %chktex 8
                                \end{itemize}
                \end{itemize}
@@ -29,7 +29,9 @@ The following research datasets have been produced during this PhD research:
                                {Code for the paper ``First-Class Data Types in Shallow Embedded Domain-Specific Languages using Metaprogramming'': IFL 2022}
                                {Zenodo}{10.5281/zenodo.6416747}
                \end{itemize}
-       \item \Fullref{prt:top}:
+       \item \Fullref{prt:top}:%
+                       \todo{add set for green?}%
+                       \todo{add set for sum\-mer school?}%
                \begin{itemize}
                        \item \rdmentry{\mlubbers; \pkoopman; \rplasmeijer}{2020}
                                {Source code for the mTask language}
index aa9d1cf..8606084 100644 (file)
@@ -7,13 +7,11 @@
 \chapter{Samenvatting}%
 \label{chp:samenvatting}
 \selectlanguage{dutch}
-\begin{center}
-
+%\begin{center}
 \noindent%
 Dit is een samenvatting van 350--400 woorden.
 
-\end{center}
-
+%\end{center}
 \input{subfilepostamble}
 \selectlanguage{british}
 \end{document}
index 08e0fd6..1f4a1a3 100644 (file)
@@ -6,12 +6,21 @@
 \input{subfileprefix}
 \chapter{Summary}%
 \label{chp:summary}
-\begin{center}
-
+%\begin{center}
 \noindent%
-This is a summary of 350--400 words.
+The amount of computers around us is growing exponentially.
+With it, the systems in which they operate are becoming more and more complex.
+Many of these computers are so called \emph{edge devices}.
+For a special class of systems, \glsxtrlong{IOT} systems, they perform the interaction with the world.
+Powered by microcontrollers, these specialised computers have little memory, slow processors, and support slow communication methods.
+On the other hand, they are also cheap, tiny, consume little energy, and can easily equipped with various sensors and actuators.
 
-\end{center}
+There is a great variety within edge devices but also between edge devices and more conventional computers.
+However, they do have to communicate with the conventional computers.
+This results in semantic friction, an impedance mismatch.
+Developing and maintaining such systems is expensive and error prone.
 
+This is a summary of 350--400 words.
+%\end{center}
 \input{subfilepostamble}
 \end{document}
index bc5cccf..57a0cd0 100644 (file)
@@ -6,78 +6,7 @@
 \input{subfileprefix}
 \chapter{Coda}%
 \label{chp:conclusion}
-\section{Conclusion}
-
-\section{Future work}
-
-\section{Related work}
-This section describes the related work.
-The novelties of the \gls{MTASK} system can be compared to existing systems in several categories.
-It is a tierless (\cref{sec:related_tierless}), interpreted (\cref{sec:related_int}) \gls{TOP} (\cref{sec:related_top}) \gls{DSL} (\cref{sec:related_dsl}) that may seem similar at first glance to \gls{FRP} (\cref{sec:related_frp}), it is implemented in a functional language (\cref{sec:related_fp}) and due to the execution semantics, multitasking is automatically supported (\cref{sec:related_multi}).
-\todo{uit\-brei\-den waar mo\-ge\-lijk}
-
-\subsection{Interpretation}\label{sec:related_int}
-There are a myriad of interpreted programming languages available for some of the bigger devices.
-For example, for the popular ESP8266 chip there are ports of \gls{MICROPYTHON}, LUA, Basic, JavaScript and Lisp.
-All of these languages, except the Lisp dialect uLisp (see \cref{ssec:related_fp}), are imperative and do not support multithreading out of the box.
-They lay pretty hefty constraints on the memory and as a result do not work on smaller microcontrollers.
-A interpretation solution for the tiniest devices is Firmata, a protocol for remotely controlling the microcontroller and using a server as the interpreter host \citep{steiner_firmata:_2009}.
-\citet{grebe_haskino:_2016} wrapped this in a remote monad for integration with \gls{HASKELL} that allowed imperative code to be interpreted on the microprocessors.
-Later this system was extended to support multithreading as well, stepping away from Firmata as the basis and using their own \gls{RTS} \citep{grebe_threading_2019}.
-It differs from our approach because continuation points need to be defined by hand there is no automatic safe data communication.
-
-\subsubsection{\texorpdfstring{\Glsxtrlongpl{DSL}}{DSLs} for microcontrollers}\label{sec:related_dsl}
-Many \glspl{DSL} provide higher-level programming abstractions for microcontrollers, for example providing strong typing or memory safety.
-For example Copilot \citep{hess_arduino-copilot_2020} and Ivory \citep{elliott_guilt_2015} are imperative \glspl{DSL} embedded in a functional language that compile to \ccpp{}.
-
-\subsection{\texorpdfstring{\Glsxtrlong{FP}}{Functional programming}}\label{sec:related_fp}
-\Citet{haenisch_case_2016} showed that there are major benefits to using functional languages for \gls{IOT} applications.
-They showed that using function languages increased the security and maintainability of the applications.
-Traditional implementations of general purpose functional languages have high memory requirements rendering them unusable for tiny computers.
-There have been many efforts to create a general purpose functional language that does fit in small memory environments, albeit with some concessions.
-For example, there has been a history of creating tiny Scheme implementations for specific microcontrollers.
-It started with BIT \citep{dube_bit:_2000} that only required \qty{64}{\kibi\byte} of memory, followed by {PICBIT} \citep{feeley_picbit:_2003} and {PICOBIT} \citep{st-amour_picobit:_2009} that lowered the memory requirements even more.
-More recently, \citep{suchocki_microscheme:_2015} created Microscheme, a functional language targeting \gls{ARDUINO} compatible microcontrollers.
-The {*BIT} languages all compile to assembly while Microscheme compiles to \gls{CPP}, heavily supported by \gls{CPP} lambdas available even on \gls{ARDUINO} AVR targets.
-An interpreted Lisp implementation called uLisp also exists that runs on microcontrollers with as small as the \gls{ARDUINO} {UNO} \citep{johnson-davies_lisp_2020}.
-
-\subsection{\texorpdfstring{\Glsxtrlong{FRP}}{Functional reactive programming}}\label{sec:related_frp}
-The \gls{TOP} paradigm is often compared to \gls{FRP} and while they appear to be similar---they both process events---, in fact they are very different.
-\Gls{FRP} was introduced by \citet{elliott_functional_1997}.
-The paradigm strives to make modelling systems safer, more efficient, composable.
-The core concepts are behaviours and events.
-A behaviour is a value that varies over time.
-Events are happenings in the real world and can trigger behaviours.
-Events and behaviours may be combined using combinators.
-\Gls{TOP} allows for more complex collaboration patterns than \gls{FRP} \citep{wang_maintaining_2018}, and in consequence is unable to provide the strong guarantees on memory usage available in a restricted variant of \gls{FRP} such as arrowized \gls{FRP} \citep{nilsson_functional_2002}.
-
-The way \gls{FRP}, and for that matter \gls{TOP}, systems are programmed stays close to the design when the domain matches suits the paradigm.
-The \gls{IOT} domain seems to suit this style of programming very well in just the device layer\footnote{While a bit out of scope, it deserves mention that for \gls{SN}, \gls{FRP} and stream based approaches are popular as well \citep{sugihara_programming_2008}.} but also for entire \gls{IOT} systems.
-
-For example, Potato is an \gls{FRP} language for building entire \gls{IOT} systems using powerful devices such as the Raspberry Pi leveraging the Erlang \gls{VM} \citep{troyer_building_2018}.
-It requires client devices to be able to run the Erlang \gls{VM} which makes it unsuitable for low memory environments.
-
-The emfrp language compiles a \gls{FRP} specification for a microcontroller to \gls{C} code \citep{sawada_emfrp:_2016}.
-The \gls{IO} part, the bodies of some functions, still need to be implemented.
-These \gls{IO} functions can then be used as signals and combined as in any \gls{FRP} language.
-Due to the compilation to \gls{C} it is possible to run emfrp programs on tiny computers.
-However, the tasks are not interpreted and there is no communication with a server.
-
-Other examples are mfrp \citep{sawada_emfrp:_2016}, CFRP \citep{suzuki_cfrp_2017}, XFRP \citep{10.1145/3281366.3281370}, Juniper \citep{helbling_juniper:_2016}, Hailstorm \citep{sarkar_hailstorm_2020}, Haski \citep{valliappan_towards_2020}, arduino-copilot~\cite{hess_arduino-copilot_2020}.
-
-\subsection{\texorpdfstring{\Glsxtrlong{TOP}}{Task-oriented programming}}\label{sec:related_top}
-\Gls{TOP} as a paradigm with has been proven to be effective for implementing distributed, multi-user applications in many domains.
-Examples are conference management \citep{plasmeijer_conference_2006}, coastal protection \citep{lijnse_capturing_2011}, incident coordination \citep{lijnse_incidone:_2012}, crisis management \citep{jansen_towards_2010} and telemedicine \citep{van_der_heijden_managing_2011}.
-In general, \gls{TOP} results in a higher maintainability, a high separation of concerns and more effective handling of interruptions of workflow.
-\Gls{IOT} applications contain a distributed and multi-user component, but the software on the device is mostly follows multiple loosely dependent workflows.
-The only other \gls{TOP} language for embedded systems is $\mu$Tasks \citep{piers_task-oriented_2016}.
-It is a non-distributed \gls{TOP} \gls{EDSL} hosted in \gls{HASKELL} designed for embedded systems such as payment terminals.
-They showed that applications tend to be able to cope well with interruptions and be more maintainable.
-However, the hardware requirements for running the standard \gls{HASKELL} system are high.
-
-\subsection{Multi tasking}\label{sec:related_multi}
-
-\subsection{Tierless programming on microcontrollers}\label{sec:related_tierless}
+\section{Reflection}
 
 \input{subfilepostamble}
 \end{document}
index 41d0f75..d5d3467 100644 (file)
@@ -8,7 +8,6 @@
 \input{subfileprefix}
 \chapter{Deep embedding with class}%
 \label{chp:classy_deep_embedding}
-
 \begin{chapterabstract}
        The two flavours of \gls{DSL} embedding are shallow and deep embedding.
        In functional languages, shallow embedding models the language constructs as functions in which the semantics are embedded.
@@ -877,7 +876,8 @@ instance ( UsingExt  '[e_1, e_2, ...] s, DependsOn '[i_1, i_2, ...] s)
 
 With these enhancements, there is hardly any boilerplate required to use classy deep embedding.
 The \haskelllhstexinline{Record} data type; the \haskelllhstexinline{CreateRecord} type class; and the \haskelllhstexinline{UsingExt} and \haskelllhstexinline{DependsOn} type families can be provided as a library only requiring the programmer to create the extension constructors with their respective implementations and smart constructors for language construct extensions.
-The source code for this extension can be found here: \url{https://gitlab.com/mlubbers/classydeepembedding}.
+The source code for this extension can be found here: \url{https://gitlab.com/mlubbers/classydeepembedding}.\footnote{Lubbers, M. (2022): Library and examples for enhanced classy deep embedding.\ Zenodo.\ \href{https://doi.org/10.5281/zenodo.7277498}{10.5281/zenodo.7277498}.}
+It contains examples for expressions, expressions using \glspl{GADT}, detection of sharing in expressions (modelled after \citet{kiselyov_implementing_2011}), a \gls{GADT} version of sharing detection, and a region \gls{DSL} (modelled after \citet{sun_compositional_2022}).
 
 \section{Data types and definitions}%
 \label{sec:cde:appendix}
index 67ca323..ad70ed3 100644 (file)
@@ -8,7 +8,6 @@
 \input{subfileprefix}
 \chapter{First-class data types in shallow \texorpdfstring{embedded domain-specific languages}{\glsxtrlongpl{EDSL}} using metaprogramming}%
 \label{chp:first-class_datatypes}%
-%\chaptermark{First-class data types in shallow eDSLs using metaprogramming}
 \begin{chapterabstract}
        \Gls{FP} languages are excellent for hosting \glspl{EDSL} because of their rich type systems, minimal syntax, and referential transparency.
        However, data types defined in the host language are not automatically available in the embedded language.
index 4e9d724..5e1453c 100644 (file)
@@ -8,7 +8,7 @@
 \chapter{Prelude}%
 \label{chp:introduction}
 \begin{chapterabstract}
-       This chapter introduces the dissertation and thesis by providing:
+       This chapter introduces the dissertation by providing:
        \begin{itemize}
                \item a general introduction to the topics and research venues;
                \item a reading guide;
        \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}}.
+There are at least 13.4 billion devices connected to the internet at the time of writing\footnote{\refurl{https://transformainsights.com/research/tam/market}{\formatdate{13}{10}{2022}}}.
 Each of these senses, acts, or otherwise interacts with people, other computers, and the environment surrounding us.
 Despite their immense diversity, they are all computers.
 And as computers, they require software to operate.
 
 An increasing amount of these connected devices are so-called \emph{edge devices} that operate in the \gls{IOT}.
-Edge devices are the leafs of the \gls{IOT} systems, they perform the interaction with the physical world.
+Edge devices are the leafs of the \gls{IOT} systems, they perform the interaction with the physical world and are physically embedded in the fabric.
+They usually reside in hard-to-reach places such as light bulbs, smart electricity meters, or even farm animals.
+Equipped with a lot of connectivity for integrating peripherals such as sensors and actuators, makes them very suitable to interact with their surroundings.
 Typically, these edge devices are powered by microcontrollers.
-These miniature computers contain integrated circuits that accomodates a microprocessor designed for use in embedded applications.
-Typically, microcontrollers are therefore tiny; have little memory; contain a slow, but energy-efficient processor; and allow for a lot of connectivity for integrating peripherals such as sensors and actuators in order to interact with their surroundings.
+These miniature computers contain integrated circuits that accommodate a microprocessor designed for use in embedded applications.
+Hence, microcontrollers are therefore cheap; tiny; have little memory; and contain a slow, but energy-efficient processor.
 
 Unlike the conductor in the orchestra waving their baton to instruct the ensemble of instruments, in the universe of software there is room for little error.
+Moreover, in dynamic \gls{IOT} applications, often there is not even a conductor or coordinator.
+Even though edge devices—the instruments—come and go, perform their own pieces, or are instructed to perform a certain piece, they operate without a central authority.
 In the traditional setting, an \gls{IOT} engineer has to program each device and their interoperation using different programming paradigms, programming languages, and abstraction levels.
 Thus resulting in semantic friction, making programming and maintaining \gls{IOT} systems is a complex and error-prone process.
 
-This thesis describes the research carried out around orchestrating these complex \gls{IOT} systems using \gls{TOP}.
+This dissertation describes the research carried out around orchestrating these complex \gls{IOT} systems using \gls{TOP}.
 \Gls{TOP} is an innovative tierless programming paradigm for interactive multi-layered systems.
-By utilising advanced compiler technologies, much of the internals, communications, and interoperations between the tiers\slash{}layers of the applications is automatically generated.
+By utilising advanced compiler technologies, much of the internals, communications, and interoperation between the tiers\slash{}layers of the applications is automatically generated.
 From a single declarative specification of the work required, the compiler makes a ready-for-work application consisting of interconnected components for all tiers.
 For example, the \gls{TOP} system \gls{ITASK} can be used to program all layers of a multi-user distributed web applications from a single source specification.
-It is implemented in \gls{CLEAN} and executes also in \gls{CLEAN}'s run time.
-The final executable is very low level and contains all these abstraction levels, this results in increased hardware requirements.
+It is implemented in \gls{CLEAN}, executes also in \gls{CLEAN}'s general-purpose run time, and requires relatively powerful hardware.
 The high hardware requirements are no problem for regular computers but impractical for the average edge device.
 
 This is where \glspl{DSL} must be brought into play.
+Using \glspl{DSL}, hardware requirements can be drastically lowered, even with high levels of abstraction for the specified domain.
 \Glspl{DSL} are programming languages created with a specific domain in mind.
 Consequently, jargon does not have to be expressed in the language itself, but they can be built-in features.
-As a result, hardware requirements can be drastically lowered, even with high levels of abstraction for the specified domain.
+Furthermore, the \gls{DSL} can eschew language or system features that are irrelevant for the domain.
 
-To incorporate the plethora of edge devices in the orchestra of an \gls{IOT} system, the \gls{MTASK} system is used.
+To incorporate the plethora of edge devices in the orchestra of a \gls{TOP} system, the \gls{MTASK} system is used.
 \Gls{MTASK} is a novel programming language for programming \gls{IOT} edge devices using \gls{TOP}.
 Where \gls{ITASK} abstracts away from the gritty details of multi-tier web applications, \gls{MTASK} has domain-specific abstractions for \gls{IOT} edge devices, maintaining the high abstraction level that \gls{TOP} generally offers.
 As it is integrated with \gls{ITASK}, it allows for all layers of an \gls{IOT} application to be programmed from a single source.
@@ -58,7 +62,7 @@ On Wikipedia, a musical rhapsody is defined as follows \citep{wikipedia_contribu
 \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}
-%The three episodes in this thesis are barded by the introduction and conclusion (\cref{chp:introduction,chp:conclusion}).
+This dissertation consists of three episodes.
 \Cref{prt:dsl} is a paper-based---otherwise known as cumulative---episode containing chapters that provide insight in advanced \gls{DSL} embedding techniques for \gls{FP} languages.
 The chapters are readable independently.
 \Cref{prt:top} is a monograph showing \gls{MTASK}, a \gls{TOP} \gls{DSL} for the \gls{IOT}.
@@ -115,20 +119,22 @@ Even more so, the perception layer itself is often a heterogeneous collection of
 As edge hardware needs to be cheap, small-scale, and energy efficient, the microcontrollers used to power them do not have a lot of computational power, only a soup\c{c}on of memory, and little communication bandwidth.
 Typically, these devices are unable to run a full-fledged general-purpose \gls{OS}.
 Rather they employ compiled firmware written in imperative languages that combines all tasks on the device in a single program.
-While devices are getting a bit faster, smaller, and cheaper, they keep these properties to an extent, greatly reducing the flexibility for dynamic systems when tasks are created on the fly, executed on demand, or require parallel execution.
-As program memory is mostly flash-based and only lasts a couple of thousands of writes before it wears out, it is not suitable for rapid reconfiguring and reprogramming.
+While devices are getting a bit faster, smaller, and cheaper, they keep these properties to an extent.
+For example, more powerful microcontrollers are capable of running \gls{RTOS}, but this still requires many resources and fixes the programs at compile time.
+As a consequence, the flexibility is greatly reduced for dynamic systems in which tasks are created on the fly, executed on demand, or require parallel execution.
+As program memory is mostly flash-based and only lasts a couple of thousands of writes before it wears out, it is not suitable for repeated reconfiguring and reprogramming.
 
 These problems can be mitigated by dynamically sending code to be interpreted to the microcontroller.
 With interpretation, a specialized interpreter is flashed in the program memory once it receives the program code to execute at run time.
 Therefore, as the programs are not stored in the flash memory, it does not wear out.
 It is challenging to create interpreters for small edge devices due to the severe hardware restrictions.
-However, the hardware requirements can be reduced by embedding domain-specific data into the langauge, so called \gls{DSL}; and the interpreter, a domain-specific \gls{OS}.
+This dissertation describes a \gls{DSL} that encompasses the high-level programming concepts of \gls{TOP}, while it can be executed on edge devices with very limited requirements.
+It does so by compiling the \gls{DSL} to byte code that is executed in a feather-light domain-specific \gls{OS}.
 
 \section{\texorpdfstring{\Glsxtrlongpl{DSL}}{Domain-specific languages}}%
 \label{sec:back_dsl}
 % General
-Programming languages can be divided up into two categories: \glspl{DSL}\footnotemark\ and \glspl{GPL} \citep{fowler_domain_2010}.
-\footnotetext{Historically \glsxtrshortpl{DSL} have been called DSELs as well.}
+Programming languages can be divided up into two categories: \glspl{DSL} and \glspl{GPL} \citep{fowler_domain_2010}.
 Where \glspl{GPL} are not made with a demarcated area in mind, \glspl{DSL} are tailor-made for a specific domain.
 Writing idiomatic domain-specific code in a \gls{DSL} is easier and requires less background knowledge about a \gls{GPL}.
 This does come at the cost of the \gls{DSL} being sometimes less expressive to an extent that it may not even be Turing complete.
@@ -136,7 +142,7 @@ This does come at the cost of the \gls{DSL} being sometimes less expressive to a
 Standalone languages are languages for which the complete toolchain has been developed, just as for any other \gls{GPL}.
 Embedded languages piggyback on an existing \gls{GPL}, they are defined in terms of their host language.
 \Glspl{EDSL} can further be classified into heterogeneous and homogeneous languages (\cref{sec:hetero_homo}).
-In homogeneous languages all components are integrated whereas in heterogeneous \glspl{DSL}, some parts are ignorant of the other systems, e.g.\ a \gls{DSL} that generates code that is compiled by an existing compiler.
+In homogeneous languages all components are integrated whereas in heterogeneous \glspl{DSL}, some parts are agnostic of the other systems, e.g.\ a \gls{DSL} that generates code for execution on a totally different system.
 This hyponymy is shown in \cref{fig:hyponymy_of_dsls}.
 
 \begin{figure}
@@ -151,11 +157,11 @@ This hyponymy is shown in \cref{fig:hyponymy_of_dsls}.
 \glspl{DSL} where historically created as standalone languages, meaning that all machinery is developed solely for the language.
 The advantage of this approach is that the language designer is free to define the syntax and type system of the language as they wish, not being restricted by any constraint.
 Unfortunately it also means that they need to develop a compiler or interpreter, and all the scaffolding for the language, making standalone \glspl{DSL} costly to create.
-Examples of standalone \glspl{DSL} are regular expressions, make, yacc, XML, SQL, \etc.
+Examples of standalone \glspl{DSL} are \TeX, \LaTeX, make, yacc, XML, SQL, \etc.
 
 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 \citep{krishnamurthi_linguistic_2001}.
-This greatly reduces the cost of creating embedded languages.
+This greatly reduces the cost of creating embedded languages and shields the user from having to learn a general-purpose language and toolchain.
 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, \gls{DSL} 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}.
@@ -179,16 +185,15 @@ Examples of homogeneous \glspl{EDSL} are libraries such as ones for sets, region
 On the other hand, heterogeneous \glspl{EDSL} are languages that are not executed in the host language.
 For example, \citet{elliott_compiling_2003} describe the language Pan, for which the final representation in the host language is a compiler that will, when executed, generate code for a completely different target platform.
 In fact, \gls{ITASK} and \gls{MTASK} are embedded \glspl{DSL}.
-\Gls{ITASK} runs in its host language as well, so it is a homogeneous \gls{DSL}.
-Tasks written using \gls{MTASK} are dynamically compiled to byte code for an edge device and is therefore a heterogeneous \gls{DSL}.
+Programs written in \gls{ITASK} run in the host language, and is a homogeneous \gls{DSL}.
+Tasks written using \gls{MTASK} are dynamically compiled to byte code for an edge device, making it a heterogeneous \gls{DSL}.
+The interpreter running on the edge device has no knowledge of the higher level task specification.
+It just interprets the byte code it was sent, rewrites the tasks and publishes task values and \gls{SDS} updates.
 
 \section{\texorpdfstring{\Glsxtrlong{TOP}}{Task-oriented programming}}%
 \label{sec:back_top}
 \Gls{TOP} is a recent declarative programming paradigm for modelling interactive systems \citep{plasmeijer_task-oriented_2012}.
-In \gls{TOP} languages, tasks are the basic building blocks.
-They represent the actual work.
-Instead of dividing problems into layers \gls{TOP} deals with separation of concerns in a novel way.
-From the data types, utilising various \emph{type-parametrised} concepts, all other aspects are handled automatically (see \cref{fig:tosd}).
+Instead of dividing problems into layers, \gls{TOP} deals with separation of concerns in a novel way.
 This approach to software development is called \gls{TOSD} \citep{wang_maintaining_2018}.
 
 \begin{figure}
@@ -199,30 +204,35 @@ This approach to software development is called \gls{TOSD} \citep{wang_maintaini
 \end{figure}
 
 \begin{description}
-       \item[\Gls{UI}:]
-               The \gls{UI} of the system is automatically generated from the structural representation of the type.
-               Though, practical \gls{TOP} systems allow tweaking afterwards to suit the specific needs of the application.
+       \item[Types:]
+               As can be seen from \cref{fig:tosd}, types are the pivotal component in \gls{TOP}.
+               From the data types, utilising various \emph{type-parametrised} concepts, all other aspects are handled automatically.
+               Hence, all other components arise from and depend on the types in the program.
        \item[Tasks:]
+               In \gls{TOP} languages, tasks are the basic building blocks.
                A task is an abstract representation of a piece of work that needs to be done.
                It provides an intuitive abstraction over work in the real world.
-               Tasks are observable during execution.
-               It is possible to observe a---partial---result and act upon it, e.g.\ by starting new tasks.
+               The nature of tasks makes them observable during execution.
+               It is possible to observe a---partial---typed result and act upon it, e.g.\ taking the partial result as good enough, or by starting new tasks.
                Examples of tasks are filling forms, sending emails, reading sensors or even doing physical tasks.
                Just as with real-life tasks, multiple tasks can be combined in various ways such as in parallel or in sequence to form workflows.
                Such combination operators are called task combinators.
        \item[\Glspl{SDS}:]
                Tasks mainly communicate using their observable task values.
-               However, some collaboration requires tasks that are not necessarily related to share data.
+               However, some collaboration patterns are more easily expressed by tasks that share common data.
                \Glspl{SDS} fill this gap, they offer a safe abstraction over any data.
-               An \gls{SDS} can represent typed data stored in a file, a chunk of memory, a database \etc.
+               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 sensor data.
-               In many \gls{TOP} langauges, combinators are available to filter, combine, transform, and focus \glspl{SDS}.
+               In many \gls{TOP} languages, combinators are available to filter, combine, transform, and focus \glspl{SDS}.
+       \item[\Gls{UI}:]
+               The \gls{UI} of the system is automatically generated from the structural representation of the type.
+               Though, practical \gls{TOP} systems allow tweaking afterwards to suit the specific needs of the application.
        \item[\Gls{UOD}:]
                The \gls{UOD} is explicitly and separately modelled by the relations that exist in the functions of the host language.
 \end{description}
 
 \Cref{fig:tosd} differs from the presented \gls{IOT} architecture because they represent separate concepts.
-The \gls{IOT} architecture from \cref{fig:iot-layers} describes an execution architecture wheras the \gls{TOSD} figure describes a softwared development model.
+The \gls{IOT} architecture from \cref{fig:iot-layers} describes an execution architecture whereas the \gls{TOSD} figure describes a software development model.
 E.g.\ from a software development perspective, a task is a task, whether it is executed on a microcontroller, a server or a client.
 Only once a task is executed, the location of the execution becomes important, but this is taken care of by the system.
 Some concepts from the \gls{TOSD} model can be mapped upon the \gls{IOT} architecture though.
@@ -230,22 +240,22 @@ Applying the concepts of \gls{TOSD} to \gls{IOT} systems can be done in two ways
 Firstly, edge devices can be seen as simple resources, thus accessed through \glspl{SDS}.
 The second view is that edge devices contain miniature \gls{TOP} systems in itself.
 The individual components in the miniature systems, the tasks, the \glspl{SDS}, are, in the eventual execution, connected to the main system.
-\todo{ik ben niet echt te\-vre\-den met deze \P}
 
 \subsection{\texorpdfstring{\Gls{ITASK}}{ITask}}
 The concept of \gls{TOP} originated from the \gls{ITASK} framework, a declarative language and \gls{TOP} engine for defining interactive multi-user distributed web applications.
 \Gls{ITASK} is implemented as an \gls{EDSL} in the lazy pure \gls{FP} language \gls{CLEAN} \citep{plasmeijer_itasks:_2007,plasmeijer_task-oriented_2012}.
-From the structural properties of the data types, the entire user interface is automatically generated.
+From the structural properties of the data types and the current status of the work to be done, the entire \gls{UI} is automatically generated.
 Browsers are powering \gls{ITASK}'s presentation layer.
 The framework is built on top of standard web techniques such as JavaScript, HTML, and {CSS}.
 \Gls{ITASK} code running in the browser relies on an interpreter that operates on \gls{CLEAN}'s intermediate language \gls{ABC} \citep{staps_lazy_2019}.
+
 Tasks in \gls{ITASK} have either \emph{no value}, an \emph{unstable} or a \emph{stable} task value.
 For example, an editor for filling in a form initially has no value.
 Once the user entered a complete value, its value becomes an unstable value, it can still be changed or even reverted to no value by emptying the editor again.
-Only when for example a continue button is pressed, a task becomes stable, fixing its value.
+Only when for example a continue button is pressed, a task value becomes stable, fixing its value.
 The allowed task value transitions are shown in \cref{fig:taskvalue}.
 
-\begin{figure}[ht]
+\begin{figure}
        \centering
        \includestandalone{taskvalue}
        \caption{Transition diagram for task values in \gls{ITASK}.}%
@@ -255,6 +265,8 @@ The allowed task value transitions are shown in \cref{fig:taskvalue}.
 As an example, \cref{lst:todo,fig:todo} show the code and \gls{UI} for an interactive to-do list application.
 The user can modify a shared to-do list through an editor directly or using some predefined actions.
 Furthermore, in parallel, the length of the list is shown to demonstrate \glspl{SDS}.
+Using \gls{ITASK}, complex collaborations of users and tasks can be described on a high level.
+
 From the data type definitions (\cref{lst:todo_dt}), using generic programming (\cref{lst:todo_derive}), the \glspl{UI} for the data types are automatically generated.
 Then, using the parallel task combinator (\cleaninline{-\|\|}) that uses the left-hand side's result the task for updating the to-dos (\cref{lst:todo_update}) and the task for viewing the length are combined (\cref{lst:todo_length}).
 Both tasks operate on the to-do \gls{SDS} (\cref{lst:todo_sds}).
@@ -262,6 +274,8 @@ The task for updating the to-do list is just an editor (\cref{lst:todo_editor})
 The actions either change the value, sorting or clearing it, or terminates the task by returning the current value of the \gls{SDS}.
 Special combinators (e.g.\ \cleaninline{@>>} at \cref{lst:todo_ui}) are used to tweak the \gls{UI} to display informative labels.
 
+\cleaninputlisting[float=,firstline=6,lastline=22,tabsize=3,numbers=left,caption={The code for the shared to-do list in \gls{ITASK}\footnotemark.},label={lst:todo}]{lst/sharedlist.icl}
+\footnotetext{\Cref{chp:clean_for_haskell_programmers} contains a guide for \gls{CLEAN} tailored to \gls{HASKELL} programmers.}
 \begin{figure}
        \centering
        \includegraphics[width=.75\linewidth]{todo0g}
@@ -269,28 +283,29 @@ Special combinators (e.g.\ \cleaninline{@>>} at \cref{lst:todo_ui}) are used to
        \label{fig:todo}
 \end{figure}
 
-\cleaninputlisting[float=,firstline=6,lastline=22,tabsize=3,numbers=left,caption={The code for the shared to-do list in \gls{ITASK}\footnotemark.},label={lst:todo}]{lst/sharedlist.icl}
-\footnotetext{\Cref{chp:clean_for_haskell_programmers} contains a guide for \gls{CLEAN} tailored to \gls{HASKELL} programmers.}
-
 \subsection{\texorpdfstring{\Gls{MTASK}}{MTask}}
-\Gls{ITASK} seems an obvious candidate at first glance for extending \gls{TOP} to \gls{IOT} edge devices.
-However, \gls{IOT} edge devices are in general not powerful enough to run or interpret \gls{CLEAN}\slash\gls{ABC} code, they just lack the processor speed and the memory.
-To bridge this gap, \gls{MTASK} was developed, a \gls{TOP} system for \gls{IOT} edge devices that is integrated in \gls{ITASK} \citep{koopman_task-based_2018}.
+The behaviour of \gls{IOT} edge devices can often be succinctly described by \gls{TOP} programs.
+Software on microcontrollers is usually composed of smaller basic tasks, are interactive, and share data with other components or the server.
+\Gls{ITASK} seems an obvious candidate at first glance for extending \gls{TOP} to \gls{IOT} edge device.
+An \gls{ITASK} application contains many features that are not needed on \emph{edge devices} such as first-order tasks, support for a distributed architecture, or a multi-user web server.
+Furthermore, \gls{IOT} edge devices are in general not powerful enough to run or interpret \gls{CLEAN}\slash\gls{ABC} code, they just lack the processor speed and the memory.
+To bridge this gap, \gls{MTASK} was developed, a domain-specific \gls{TOP} system for \gls{IOT} edge devices that is integrated in \gls{ITASK} \citep{koopman_task-based_2018}.
 \Gls{ITASK} abstracts away from details such as user interfaces, data storage, client-side platforms, and persistent workflows.
 On the other hand, \gls{MTASK} offers abstractions for edge layer-specific details such as the heterogeneity of architectures, platforms, and frameworks; peripheral access; (multi) task scheduling; and lowering energy consumption.
+
+\Gls{MTASK} is seamlessly integrated with \gls{ITASK}: \gls{MTASK} tasks are integrated in such a way that they function as \gls{ITASK} tasks, and \glspl{SDS} on the device can tether an \gls{ITASK} \gls{SDS}.
+Using \gls{MTASK}, the programmer can define all layers of an \gls{IOT} system as a single declarative specification.
 The \gls{MTASK} language is written in \gls{CLEAN} as a multi-view \gls{EDSL} and hence there are multiple interpretations possible.
 The byte code compiler is the most relevant for this thesis.
 From an \gls{MTASK} task constructed at run time, a compact binary representation of the work that needs to be done is compiled.
 This byte code is then sent to a device that running the \gls{MTASK} \gls{RTS}.
 This feather-light domain-specific \gls{OS} is written in portable \gls{C} with a minimal device specific interface and functions as a \gls{TOP} engine.
-\Gls{MTASK} is seamlessly integrated with \gls{ITASK}: \gls{MTASK} tasks are integrated in such a way that they function as \gls{ITASK} tasks, and \glspl{SDS} on the device can tether an \gls{ITASK} \gls{SDS}.
-Using \gls{MTASK}, the programmer can define all layers of an \gls{IOT} system as a single declarative specification.
 
 \Cref{lst:intro_blink,fig:intro_blink} shows the \gls{ITASK} part of the code and a screenshot of an interactive \imtask{} application for blinking \pgls{LED} on the microcontroller every dynamically changeable interval.
 Using \cleaninline{enterInformation}, the connection specification of the \gls{TCP} device is queried (\cref{lst:intro_enterDevice}).
-\Cref{lst:intro_withshared} defines \pgls{SDS} to communicate the blinking interval.
-Then the \gls{MTASK} is connected using \cleaninline{withDevice} at \cref{lst:intro_withdevice}.
-Once connected, the \cleaninline{intBlink} task is sent to the device (\cref{lst:intro_liftmtask}) and, in parallel, an editor is shown that updates the value of the interval \gls{SDS} (\cref{lst:intro_editor}).
+\Cref{lst:intro_withshared} defines \pgls{SDS} to communicate the blinking interval between the server and the edge device.
+The \gls{MTASK} is connected using \cleaninline{withDevice} at \cref{lst:intro_withdevice}.
+Once connected, the \cleaninline{intBlink} task is sent to the device (\cref{lst:intro_liftmtask}) and, in parallel, a web editor is shown that updates the value of the interval \gls{SDS} (\cref{lst:intro_editor}).
 To allow ending the task, the \gls{ITASK} task ends with a sequential operation that returns a constant value when the button is pressed, making the task stable.
 
 \cleaninputlisting[firstline=10,lastline=18,numbers=left,caption={The \gls{ITASK} code for the interactive blinking application.},label={lst:intro_blink}]{lst/blink.icl}
@@ -323,11 +338,11 @@ intBlink :: (Shared sds Int) -> Main (MTask v Int) | mtask v & ...\end{lstClean}
 
 \subsection{Other \texorpdfstring{\glsxtrshort{TOP}}{TOP} languages}
 While \gls{ITASK} conceived \gls{TOP}, it is not the only \gls{TOP} system.
-Some \gls{TOP} systems arose from Master's and Bachelor's thesis projects.
-For example, \textmu{}Task \citep{piers_task-oriented_2016}, a \gls{TOP} language for modelling non-interruptible embedded systems in \gls{HASKELL}, and LTasks \citep{van_gemert_task_2022}, a \gls{TOP} language written in the dynamically typed programming language {LUA}.
 Some \gls{TOP} languages were created to fill a gap encountered in practise.
 Toppyt \citep{lijnse_toppyt_2022} is a general purpose \gls{TOP} language written in \gls{PYTHON} used to host frameworks for modelling \emph{Command\&Control} systems, and hTask \citep{lubbers_htask_2022}, a vessel for experimenting with asynchronous \glspl{SDS}.
-Finally there are \gls{TOP} languages with strong academic foundations.
+Furthermore, some \gls{TOP} systems arose from Master's and Bachelor's thesis projects.
+For example, \textmu{}Task \citep{piers_task-oriented_2016}, a \gls{TOP} language for modelling non-interruptible embedded systems in \gls{HASKELL}, and LTasks \citep{van_gemert_task_2022}, a \gls{TOP} language written in the dynamically typed programming language {LUA}.
+Finally, there are \gls{TOP} languages with strong academic foundations.
 \Gls{TOPHAT} is a fully formally specified \gls{TOP} language designed to capture the essence of \gls{TOP} formally \citep{steenvoorden_tophat_2019}.
 Such a formal specification allows for symbolic execution, hint generation, but also the translation to \gls{ITASK} for actually performing the work \citep{steenvoorden_tophat_2022}.
 \Citeauthor{steenvoorden_tophat_2022} distinguishes two instruments for \gls{TOP}: \gls{TOP} languages and \gls{TOP} engines.
@@ -352,7 +367,7 @@ This paper-based episode contains the following papers:
 \end{enumerate}
 
 \paragraph{Other publications on \texorpdfstring{\glspl{EDSL}}{eDSLs}:}
-Furthermore, I co-authored another paper that is worth mentioning but is not part of the \gls{MTASK} system yet and hence not part of the dissertation.
+Furthermore, I co-authored another paper that is not part of the \gls{MTASK} system yet and hence not part of the dissertation.
 
 \begin{enumerate}[resume]
        \item \emph{Strongly-Typed Multi-View Stack-Based Computations} \citep{koopman_strongly-typed_2022}\label{enum:stack-based} shows how to create type-safe \glspl{EDSL} representing stack-based computations.
@@ -371,7 +386,7 @@ It is compiled from the following publications:
        \item \emph{A Task-Based \glsxtrshort{DSL} for Microcomputers} \citep{koopman_task-based_2018}
                is the initial \gls{TOP}\slash{}\gls{MTASK} paper.
                It provides an overview of the initial \gls{TOP} \gls{MTASK} language and shows first versions of some interpretations.
-       \item \emph{Task Oriented Programming for the Internet of Things} \citep{lubbers_task_2018}\footnotetext{This work is an extension of my Master's thesis \citep{lubbers_task_2017}.}
+       \item \emph{Task Oriented Programming for the Internet of Things} \citep{lubbers_task_2018}\footnotetext{This work is an extension of my Master's thesis \citeyearpar{lubbers_task_2017}.}
                shows how a simple imperative variant of \gls{MTASK} was integrated with \gls{ITASK}.
                While the language was a lot different from later versions, the integration mechanism is still used in \gls{MTASK} today.
 %              \paragraph{Contribution}
@@ -408,15 +423,15 @@ It is compiled from the following publications:
 \end{enumerate}
 
 \paragraph{Contribution:}
-The original imperative predecessors, the \gls{MTASK} language, and their initial interpretations were developed by Pieter Koopman and Rinus Plasmeijer.
-I continued with the language; developed the byte code interpreter, the precursor to the \gls{C} code generation interpretation; the integration with \gls{ITASK}; and the \gls{RTS}.
+The original \gls{MTASK} language, and their initial interpretations were developed by Pieter Koopman and Rinus Plasmeijer.
+I extended the language, developed the byte code interpreter, the integration with \gls{ITASK}, and the \gls{RTS}.
 The paper of which I am first author are solely written by me, there were weekly meetings with the co-authors in which we discussed and refined the ideas.
 
 \subsection{\nameref{prt:tvt}}
 \Cref{prt:tvt} is based on a journal paper that quantitatively and qualitatively compares traditional \gls{IOT} architectures with \gls{IOT} systems using \gls{TOP} and contains a single chapter.
 This chapter is based on the conference paper and a journal paper extending it:
 \begin{enumerate}[resume]
-       \item \emph{Tiered versus Tierless IoT Stacks: Comparing Smart Campus Software Architectures} \citep{lubbers_tiered_2020}\footnote{This work was partly funded by the 2019 Radboud-Glasgow Collaboration Fund.}\label{enum:iot20} compares traditional tiered programming to tierless architectures by comparing two implementations of a smart-campus application.
+       \item \emph{Tiered versus Tierless \glsxtrshort{IOT} Stacks: Comparing Smart Campus Software Architectures} \citep{lubbers_tiered_2020}\footnote{This work was partly funded by the 2019 Radboud-Glasgow Collaboration Fund.}\label{enum:iot20} compares traditional tiered programming to tierless architectures by comparing two implementations of a smart-campus application.
        \item \emph{Could Tierless Programming Reduce IoT Development Grief?} \citep{lubbers_could_2022}
                is an extended version of paper~\ref{enum:iot20}.
                It compares programming traditional tiered architectures to tierless architectures by illustrating a qualitative and a quantitative four-way comparison of a smart-campus application.
index 2be0cdc..cc7fc5c 100644 (file)
@@ -19,7 +19,7 @@ where enterDevice :: Task TCPSettings
 
 intBlink :: (Shared sds Int) -> Main (MTask v Int)
        | mtask, lowerSds v & RWShared sds & TC sds () Int Int
-intBlink iInterval = declarePin D13 PMOutput \ledPin-> /*\label{lst:intro:declarePin}*/
+intBlink iInterval = declarePin D2 PMOutput \ledPin-> /*\label{lst:intro:declarePin}*/
           lowerSds \mInterval=iInterval/*\label{lst:intro:liftsds}*/
        In fun \blink=(\st-> /*\label{lst:intro:blink_fro}*/
                     getSds mInterval
index 8b0e35c..b29e8be 100644 (file)
@@ -15,7 +15,7 @@ toDoTask = upToDos/*\label{lst:todo_update}*/
 
 upToDos :: Task [ToDo]
 upToDos = updateSharedInformation [] todos <<@ Title "My todo-list"/*\label{lst:todo_ui}\label{lst:todo_editor}*/
-       >>* [ OnAction (Action "Sort") (hasValue \_->upd sort todos >-| upToDos)/*\label{lst:todo_ui}\label{lst:todo_contfro}*/
+       >>* [ OnAction (Action "Sort") (hasValue \_->upd sort todos >-| upToDos)/*\label{lst:todo_contfro}*/
            , OnAction (Action "Clear") (always (set [] todos >-| upToDos))
            , OnAction (Action "Quit") (always (get todos))/*\label{lst:todo_ui}\label{lst:todo_contto}*/
            ]
index 039b0e7..05a3b50 100644 (file)
@@ -1,14 +1,14 @@
 \documentclass[tikz]{standalone}
 \usetikzlibrary{arrows.meta,shapes.symbols,matrix,positioning}
 \begin{document}
-       \begin{tikzpicture}[node distance=7em]
-               \node (1) {no value};
+       \begin{tikzpicture}[node distance=7em,nodes={draw,minimum width=5em}]
+               \node (1)              {no value};
                \node (2) [right of=1] {unstable};
                \node (3) [right of=2] {stable};
 
                \draw [->] (1) -- (2);
                \draw [->] (2) -- (1);
                \draw [->] (2) -- (3);
-               \draw [->] (1) to [out=20,in=160] (3);
+               \draw [->] (1.north east) to [out=25,in=155] (3.north west);
        \end{tikzpicture}
 \end{document}
index 64c17df..986ee40 100644 (file)
--- a/other.bib
+++ b/other.bib
@@ -1991,3 +1991,26 @@ Publisher: Association for Computing Machinery},
        keywords = {IoT, Energy, Environment, Smart city, SpliTech2020, Sustainability},
        pages = {122877},
 }
+
+@inproceedings{santanna_safe_2013,
+       title = {Safe system-level concurrency on resource-constrained nodes},
+       booktitle = {Proceedings of the 11th {ACM} {Conference} on {Embedded} {Networked} {Sensor} {Systems}},
+       publisher = {ACM},
+       author = {Sant'Anna, Francisco and Rodriguez, Noemi and Ierusalimschy, Roberto and Landsiedel, Olaf and Tsigas, Philippas},
+       year = {2013},
+       pages = {11},
+       file = {Sant'Anna et al. - 2013 - Safe system-level concurrency on resource-constrai.pdf:/home/mrl/.local/share/zotero/storage/4865FAU3/Sant'Anna et al. - 2013 - Safe system-level concurrency on resource-constrai.pdf:application/pdf},
+}
+
+@article{kiselyov_implementing_2011,
+       title = {Implementing {Explicit} and {Finding} {Implicit} {Sharing} in {Embedded} {DSLs}},
+       volume = {66},
+       url = {https://doi.org/10.4204/eptcs.66.11},
+       doi = {10.4204/eptcs.66.11},
+       journal = {Electronic Proceedings in Theoretical Computer Science},
+       author = {Kiselyov, Oleg},
+       month = sep,
+       year = {2011},
+       note = {Publisher: Open Publishing Association},
+       pages = {210--225},
+}
index 80bc930..afba2d2 100644 (file)
@@ -16,6 +16,7 @@
 \usepackage{siunitx}        % typeset units
 \usepackage{xcolor}         % colors
 \usepackage{fnpct}          % footnotekerning
+\usepackage[all]{nowidow}   % Kill widows and orphans
 \DeclareSIUnit\noop{\relax}
 \DeclareSIUnit\celcius{{}^{\circ}\kern-\scriptspace\mathsf{C}}
 \everymath{\it\/}
 \makeatother
 
 \usepackage{framed}
-%\newenvironment{chapterabstract}{\begin{quotation}\em\noindent}{\end{quotation}} %chktex 6
 \definecolor{lstbg}{gray}{.95}
 \definecolor{shadecolor}{named}{lstbg}
-\newenvironment{chapterabstract}{\begin{shaded}\em}{\end{shaded}} %chktex 6
+\newenvironment{chapterabstract}{\begin{shaded}\begin{quotation}}{\end{quotation}\end{shaded}} %chktex 6
 
 % Increase the depth for the table of contents
 \setcounter{secnumdepth}{3}
 \usepackage{bibentry} % Cite bib entry completely
 \nobibliography*
 \newcommand{\citeentry}[1]{\begin{NoHyper}\bibentry{#1}\end{NoHyper}. \citep{#1}}
+\newcommand{\refurl}[2]{\url{#1}, accessed on: #2}
 
 \makeatletter
 \newcommand{\citepage}[1]{p.~#1}
index a662e88..1fc541e 100644 (file)
--- a/self.bib
+++ b/self.bib
@@ -26,7 +26,7 @@
        publisher = {Springer International Publishing},
        author = {Lubbers, Mart and Koopman, Pieter and Plasmeijer, Rinus},
        year = {2019},
-       note = {in-press},
+       note = {in-press. preprint at: https://arxiv.org/abs/2212.04193},
        pages = {51},
        file = {cefp.pdf:/home/mrl/.local/share/zotero/storage/VEWFI5DG/cefp.pdf:application/pdf},
 }
        file = {Koopman et al. - 2022 - SusTrainable Promoting Sustainability as a Fundam.pdf:/home/mrl/.local/share/zotero/storage/5F9SRJQI/Koopman et al. - 2022 - SusTrainable Promoting Sustainability as a Fundam.pdf:application/pdf},
 }
 
-@inproceedings{lubbers_deep_2022,
-       address = {Berlin, Heidelberg},
-       title = {Deep {Embedding} with {Class}},
-       booktitle = {Revised {Selected} {Papers} from the 23rd {International} {Symposium} on {Trends} in {Functional} {Programming}, {TFP} 2022, {Online}, 17-18 {March} 2022},
-       publisher = {Springer Berlin Heidelberg},
-       author = {Lubbers, Mart},
-       year = {2022},
-       note = {in-press},
-       pages = {20},
-}
-
 @inproceedings{lubbers_first-class_2022,
        address = {New York, NY, USA},
        series = {{IFL} '22},
        keywords = {clean, distributed applications, functional programming, internet of things, task oriented programming},
 }
 
-@inproceedings{crooijmans_reducing_2022,
-       address = {Berlin, Heidelberg},
-       title = {Reducing the {Power} {Consumption} of {IoT} with {Task}-{Oriented} {Programming}},
-       booktitle = {Revised {Selected} {Papers} from the 23rd {International} {Symposium} on {Trends} in {Functional} {Programming}, {TFP} 2022, {Online}, 17-18 {March} 2022},
-       publisher = {Springer Berlin Heidelberg},
-       author = {Crooijmans, Sjoerd and Lubbers, Mart and Koopman, Pieter},
-       year = {2022},
-       note = {in-press},
-       pages = {20},
-}
-
 @book{lubbers_orchestrating_2023,
        address = {Nijmegen},
        title = {Orchestrating the {Internet} of {Things} using {Task}-{Oriented} {Programming}},
        year = {2022},
        note = {Place: New York, NY, USA
 Publisher: Association for Computing Machinery},
-       keywords = {access control, internet-of-things, IoT stacks, policy language, privilege escalation, Smart home system, Tierless languages},
+       keywords = {access control, internet-of-things, policy language, privilege escalation, Smart home system, IoT stacks, Tierless languages},
 }
 
 @inproceedings{koopman_strongly-typed_2022,
@@ -234,3 +212,29 @@ Publisher: Association for Computing Machinery},
        note = {event-place: Kopenhagen, Denmark. under-review},
        keywords = {clean, distributed applications, functional programming, internet of things, task oriented programming},
 }
+
+@inproceedings{lubbers_deep_2022,
+       address = {Cham},
+       title = {Deep {Embedding} with {Class}},
+       isbn = {978-3-031-21314-4},
+       abstract = {The two flavours of DSL embedding are shallow and deep embedding. In functional languages, shallow embedding models the language constructs as functions in which the semantics are embedded. Adding semantics is therefore cumbersome while adding constructs is a breeze. Upgrading the functions to type classes lifts this limitation to a certain extent.},
+       booktitle = {Trends in {Functional} {Programming}},
+       publisher = {Springer International Publishing},
+       author = {Lubbers, Mart},
+       editor = {Swierstra, Wouter and Wu, Nicolas},
+       year = {2022},
+       pages = {39--58},
+}
+
+@inproceedings{crooijmans_reducing_2022,
+       address = {Cham},
+       title = {Reducing the {Power} {Consumption} of {IoT} with {Task}-{Oriented} {Programming}},
+       isbn = {978-3-031-21314-4},
+       abstract = {Limiting the energy consumption of IoT nodes is a hot topic in green computing. For battery-powered devices this necessity is obvious, but the enormous growth of the number of IoT nodes makes energy efficiency important for every node in the IoT. In this paper, we show how we can automatically compute execution intervals for our task-oriented programs for the IoT. These intervals offer the possibility to save energy by bringing the microprocessor driving the IoT node into a low-power sleep mode until the task need to be executed. Furthermore, they offer an elegant way to add interrupts to the system. We do allow an arbitrary number of tasks on the IoT nodes and achieve significant reductions of the energy consumption by bringing the microprocessor in sleep mode as much as possible. We have seen energy reductions of an order of magnitude without imposing any constraints on the tasks to be executed on the IoT nodes.},
+       booktitle = {Trends in {Functional} {Programming}},
+       publisher = {Springer International Publishing},
+       author = {Crooijmans, Sjoerd and Lubbers, Mart and Koopman, Pieter},
+       editor = {Swierstra, Wouter and Wu, Nicolas},
+       year = {2022},
+       pages = {80--99},
+}
index b947f00..0759d45 100644 (file)
@@ -68,7 +68,7 @@
 \subfile{dsl/class}    % Deep embedding with class
 \subfile{dsl/first}    % First-class data types
 
-\part{Orchestrating the Internet of Things using Task-Oriented Programming}%
+\part[\hspace{-9pt}Orchestrating the Internet of Things using Task-Oriented Programming]{\\[2ex]\smaller{}Orchestrating the Internet of Things using Task-Oriented Programming}%
 \label{prt:top}
 \subfile{top/4iot}  % TOP for the IoT
 \subfile{top/lang}  % mTask DSL
@@ -77,7 +77,7 @@
 \subfile{top/green} % Green computing
 \subfile{top/finale} % Conclusion
 
-\part{Tiered vs.\ Tierless Programming}%
+\part[Tiered versus Tierless Programming]{\\[2ex]\smaller{}Tiered versus Tierless Programming}%
 \label{prt:tvt}
 \subfile{tvt/tvt}   % Could Tierless Languages Reduce IoT Development Grief?
 
index 429b8c9..fe9b520 100644 (file)
@@ -9,17 +9,19 @@
 \chapter{\texorpdfstring{\Glsxtrlong{TOP} for the \glsxtrlong{IOT}}{Task-oriented programming for the internet of things}}%
 \label{chp:top4iot}
 \begin{chapterabstract}
-       This chapter compares traditional edge device programming to \gls{TOP} by:
+       \noindent This chapter introduces the monograph. It compares traditional edge device programming to \gls{TOP} by:
        \begin{itemize}
                \item introducing edge device programming;
                \item showing how to create the \emph{Hello World!} application for microcontrollers using \gls{ARDUINO} and \gls{MTASK};
-               \item extending the idea to multithreading, uncovering problems using \gls{ARDUINO};
-               \item and demonstrating that upgrading to a multi-tasking variant is straightforward using \gls{MTASK}.
+               \item extending the idea to cooperative multitasking, uncovering problems using \gls{ARDUINO};
+               \item demonstrating that upgrading to a multi-tasking variant is straightforward using \gls{MTASK};
+               \item elaborating on integrating an edge device program with a server;
+               \item and providing a reading guide for the rest of the monograph.
        \end{itemize}
 \end{chapterabstract}
 
 The edge layer of \gls{IOT} systems predominantly consists of microcontrollers.
-Microcontrollers are tiny computers designed specifically for embedded applications that much from regular computers in all aspects.
+Microcontrollers are tiny computers designed specifically for embedded applications that differ much from regular computers in all aspects.
 They are much smaller; only have a fraction of the memory and processor speed; and run on different architectures.
 However, they have much more energy-efficient sleep modes, and support connecting and interfacing with peripherals such as sensors and actuators.
 \Cref{tbl:mcu_laptop} compares the hardware properties of a typical laptop with two very popular microcontrollers.
@@ -38,40 +40,41 @@ Hence, all tasks must be manually combined into a single program.
                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}\\
+               \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}\\
                Size & $\pm$\qty{1060}{\cubic\cm} & $\pm$\qty{7.5}{\cubic\cm} & $\pm$\qty{1.1}{\cubic\cm}\\
+               Display & \numproduct{1920x1080x24} & \numproduct{1x1x1} & \numproduct{1x1x1}\\ %chktex 29
                Price & \euro{1500} & \euro{3} & \euro{4}\\
                \bottomrule
        \end{tabular}
 \end{table}
 
 Different models of microcontrollers require their own vendor-provided drivers, hardware abstraction layer, compilers and \glspl{RTS}.
-To structure this jungle of tools, platforms exist that provide abstraction layers over the low-level toolchains such as \gls{ARDUINO}.
+To structure this jungle of tools, platforms exist that provide abstraction layers over the low-level toolchains such as \gls{ARDUINO}\footnote{\refurl{https://www.arduino.cc}{\formatdate{19}{12}{2022}}}.
 It is specifically designed for education and prototyping and hence used here to illustrate traditional microcontroller programming.
 The popular \gls{ARDUINO} \ccpp{} 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 by vendor-provided \emph{cores}.
 It provides an \gls{IDE} and toolchain automation to perform all steps of the toolchain with a single command.
 
 \section{\texorpdfstring{\Glsxtrshort{TOP} for the \glsxtrshort{IOT}}{TOP for the IoT}}
-\Gls{TOP} is a programming paradigm that allows multi-tier interactive systems to be generated from a single declarative source.
-\Gls{ITASK} is a general-purpose \gls{TOP} system for programming interactive distributed web applications.
-These distributed web applications often form the core of the top two layers of \gls{IOT} applications.
-Integrating the perception layer, the edge devices, in \gls{ITASK} also is not straightforward.
-\Gls{ITASK} targets relatively fast but energy-hungry systems with large amounts of \gls{RAM} and a speedy connection.
-Edge devices in \gls{IOT} systems are typically slow but energy efficient and do not have the memory to run the naturally heap-heavy functional programs that \gls{ITASK} programs are.
-\Gls{MTASK} bridges this gap by providing a \gls{TOP} \gls{DSL} for \gls{IOT} edge devices.
-Domain-specific knowledge is embedded in the language and execution platform, drastically lowering the hardware requirements.
-The following sections compare traditional microcontroller programming with programming the devices using \gls{MTASK}.
+\Gls{TOP} is a programming paradigm that allows multi-tier interactive systems to be generated from a single declarative source (see \cref{sec:back_top}).
+An example of a \gls{TOP} system is \gls{ITASK}, a general-purpose \gls{TOP} language for programming interactive distributed web applications.
+Interactive distributed web applications often form the core of the top two layers of \gls{IOT} applications.
+Furthermore, \gls{IOT} edge devices are typically programmed with similar workflow-like programs for which \gls{TOP} is very suitable.
+Directly incorporating the perception layer in \gls{ITASK} however is not straightforward.
+\Gls{ITASK} targets relatively fast and hence energy-hungry systems with large amounts of \gls{RAM} and a speedy connection.
+Edge devices in \gls{IOT} systems are typically slow but energy efficient and do not have the memory to run the naturally heap-heavy feature-packed functional programs that \gls{ITASK} programs are.
+The \gls{MTASK} system bridges this gap by providing a \gls{TOP} \gls{DSL} for \gls{IOT} edge devices.
+Domain-specific knowledge is embedded in the language and execution platform; and unnecessary features for edge devices are removed to drastically lowere the hardware requirements.\todo{beter?}
 
 \section{Hello world!}
 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.
 Microcontrollers usually do not come with screens in the traditional sense.
-Nevertheless, almost always there is a built-in monochrome \numproduct{1x1} pixel screen, namely the built-in \gls{LED}. %chktex 29
+Nevertheless, almost always there is a built-in 1 pixel screen with a \qty{1}{\bit} color depth, namely the on-board \gls{LED}.
 The \emph{Hello World!} equivalent on microcontrollers blinks this \gls{LED}.
 
-Using \gls{ARDUINO}'s \ccpp{} dialect to create the blink program results in the code seen in \citelisting{\ref{lst:arduinoBlink}}.
+Using \gls{ARDUINO}'s \ccpp{} dialect to create the blink program results in the code seen in \cref{lst:arduinoBlink}.
 \Gls{ARDUINO} programs are implemented as cyclic executives and hence, each program defines a \arduinoinline{setup} and a \arduinoinline{loop} function.
 The \arduinoinline{setup} function is executed only once on boot, the \arduinoinline{loop} function is continuously called afterwards and contains the event loop.
 In the blink example, the \arduinoinline{setup} function only contains code for setting the \gls{GPIO} pin to the correct mode.
@@ -91,24 +94,40 @@ void loop() {
 }\end{lstArduino}
 
 \subsection{Blinking the \texorpdfstring{\glsxtrshort{LED}}{LED} in \texorpdfstring{\gls{MTASK}}{mTask}.}
-Naively translating the traditional blink program to \gls{MTASK} can be done by simply substituting some syntax as seen in \citelisting{\ref{lst:blinkImp}}.
+Naively translating the traditional blink program to \gls{MTASK} can be done by simply substituting some syntax as seen in \cref{lst:blinkImp}.
 E.g.\ \arduinoinline{digitalWrite} becomes \cleaninline{writeD}, literals are prefixed with \cleaninline{lit} and the pin to blink is changed to represent the actual pin for the builtin \gls{LED} of the device used in the exercises.
 In contrast to the imperative \gls{CPP} dialect, \gls{MTASK} is a \gls{TOP} language and therefore there is no such thing as a loop, only task combinators to combine tasks.
 To simulate a loop, the \cleaninline{rpeat} task combinator can be used as this task combinator executes the argument task and, when stable, reinstates it.
 The body of the \cleaninline{rpeat} contains similarly named tasks to write to the pins and to wait in between.
 The tasks are connected using the sequential \cleaninline{>>|.} combinator that for all current intents and purposes executes the tasks after each other.
-\begin{lstClean}[caption={Blinking the \gls{LED}.},label={lst:blinkImp}]
-blink :: Main (MTask v ()) | mtask v
-blink =
-       declarePin D2 PMOutput \d2->
+
+\begin{lstClean}[caption={Blinking the \gls{LED} using the \cleaninline{rpeat} combinator.},label={lst:blinkImp}]
+blinkTask :: Main (MTask v ()) | mtask v
+blinkTask = declarePin D2 PMOutput \ledPin->
        {main = rpeat (
-                    writeD d2 true
+                    writeD ledPin true
                >>|. delay (lit 500)
-               >>|. writeD d2 false
+               >>|. writeD ledPin false
                >>|. delay (lit 500))
        }
 \end{lstClean}
 
+However, as \gls{MTASK} is hosted in a full fledged functional language, it is also possible to define the blinking behaviour as a function.
+\Cref{lst:blinkFun} shows this more natural translation.
+The \cleaninline{main} expression is just a call to the \cleaninline{blink} function parametrised with the state.
+The \cleaninline{blink} function first writes the current state to the \gls{LED}, waits for the specific time and calls itself recursively with the inverse of the state, resulting in the same behaviour.
+Creating recursive functions like this is not possible in the \gls{ARDUINO} language because the program would run out of stack quickly and combining multiple tasks defined this would be very difficult.
+
+\begin{lstClean}[caption={Blinking the \gls{LED} using a function.},label={lst:blinkFun}]
+blinkTask :: Main (MTask v ()) | mtask v
+blinkTask = declarePin D2 PMOutput \ledPin->
+       fun \blink=(\st->
+                    writeD ledPin st
+               >>|. delay (lit 500)
+               >>|. blink (Not st))
+       In {main = blink true}
+\end{lstClean}
+
 \section{Multi tasking}
 Now say that we want to blink multiple blinking patterns on different \glspl{LED} concurrently.
 For example, blink three \glspl{LED} connected to \gls{GPIO} pins $1,2$ and $3$ at intervals of \qtylist{500;300;800}{\ms}.
@@ -145,9 +164,11 @@ In the simple case of blinking three \glspl{LED} according to fixed intervals, i
 Unfortunately, this is very hard when for example the blinking patterns are determined at runtime.
 
 \begin{lstArduino}[label={lst:blinkthread},caption={Threading three blinking patterns.}]
-long led1 = 0, led2 = 0, led3 = 0;
+long led1 = 0,    led2 = 0,    led3 = 0;
 bool st1 = false, st2 = false, st3 = false;
 
+void setup () { ... }
+
 void blink(int pin, int interval, long *lastrun, bool *st) {
        if (millis() - *lastrun > interval) {
                digitalWrite(pin, *st = !*st);
@@ -166,37 +187,41 @@ In contrast to the \arduinoinline{delay} function in \gls{ARDUINO}, \gls{MTASK}'
 It has no observable value until the target waiting time has passed, and thence is \emph{stable}.
 To make code reuse possible and make the implementation more intuitive, the blinking behaviour is lifted to a recursive function instead of using the imperatively looking \cleaninline{rpeat} task combinator.
 There is no global state, the function is parametrized with the current status, the pin to blink and the waiting time.
-Creating recursive functions like this is not possible in the \gls{ARDUINO} language because the program would run out of stack in an instant and nothing can be interleaved.
 With a parallel combinator, tasks are executed in an interleaved fashion.
 Therefore, blinking three different blinking patterns is as simple as combining the three calls to the \cleaninline{blink} function with their arguments as seen in \cref{lst:blinkthreadmtask}.
 
 % VimTeX: SynIgnore on
 \begin{lstClean}[label={lst:blinkthreadmtask},caption={Threading three blinking patterns.}]
 blinktask :: MTask v () | mtask v
-blinktask =
-       declarePin D1 PMOutput \d1->
+blinktask = declarePin D1 PMOutput \d1->
        declarePin D2 PMOutput \d2->
        declarePin D3 PMOutput \d3->
        fun \blink=(\(st, pin, wait)->
                     delay wait
                >>|. writeD d13 st
                >>|. blink (Not st, pin, wait))
-       In {main =
-                    blink (true, d1, lit 500)
-               .||. blink (true, d2, lit 300)
-               .||. blink (true, d3, lit 800)
+       In {main =   blink (true, d1, lit 500)
+               .||. blink (true, d2, lit 300)
+               .||. blink (true, d3, lit 800)
        }
 \end{lstClean}
 % VimTeX: SynIgnore off
 
-\section{Conclusion}
+\section{Conclusion and reading guide}
 The edge layer of \gls{IOT} systems is powered by microcontrollers.
 Microcontrollers have significantly different characteristics to regular computers.
 Programming them happens through compiled firmwares using low-level imperative programming languages.
 Due to the lack of an \gls{OS}, writing applications that perform multiple tasks at the same time is error prone, and complex; and requires a lot of boilerplate and manual scheduling code.
 With the \gls{MTASK} system, a \gls{TOP} programming language for \gls{IOT} edge devices, this limitation can be overcome.
 As much domain-specific knowledge is built into the language and the \gls{RTS}, the hardware requirements can be kept relatively low while maintaining a high abstraction level.
-\todo{moet dit uitgebreider?}
+Furthermore, the programs are automatically integrated with \gls{ITASK}, allowing for data sharing, task coordination, and dynamic construction of tasks.
+
+The following chapters thoroughly introduce all aspects of the \gls{MTASK} system.
+First the language setup and interface is shown in \cref{chp:mtask_dsl}.
+Then the interface for integrating \gls{MTASK} with \gls{ITASK} is provided in \cref{chp:integration_with_itask}.
+\Cref{chp:implementation} provides the implementation of the \gls{DSL}, the compilation schemes, instruction set and details on the interpreter.
+\Cref{chp:green_computing_mtask} explains all the green computing aspects of \gls{MTASK}, i.e.\ task scheduling and processor interrupts.
+Finally, \cref{chp:finale} concludes, and shows related work together with a short history of \gls{MTASK}.
 
 \input{subfilepostamble}
 \end{document}
index fcd11a4..1ae84ee 100644 (file)
@@ -7,16 +7,33 @@
 \chapter{Finale}%
 \label{chp:finale}
 \begin{chapterabstract}
-       This chapter wraps up the monograph by:
+       \noindent This chapter wraps up the monograph by means of:
        \begin{itemize}
-               \item providing a conclusion;
+               \item a conclusion;
+               \item an outlook on future work;
                \item an overview of the related work;
-               \item and giving a history of the \gls{MTASK} system.
+               \item and a history of the \gls{MTASK} system.
        \end{itemize}
 \end{chapterabstract}
 
 \section{Finale}
-\todo[inline]{Conclusion}
+The \gls{MTASK} system is a proof-of-concept system, though fully functioning, for integrating \gls{IOT} edge devices in \gls{TOP}.
+In conjunction with \gls{ITASK}, it is possible to program all layers of the \gls{IOT} from a single declarative specification.
+
+\section{Future work}
+The \gls{MTASK} systems is a proof-of-concept system for integrating \gls{IOT} edge devices.
+
+Edge computing
+
+Intermittent computing
+
+Formal semantics
+
+Automatic peripherals
+
+Different architectures (FPGA?)
+
+Mesh communication
 
 \section{Related work}
 The novelties of the \gls{MTASK} system can be compared to existing systems in several categories.
@@ -83,6 +100,56 @@ They showed that applications tend to be able to cope well with interruptions an
 However, the hardware requirements for running the standard \gls{HASKELL} system are high.
 
 \subsection{Multi tasking}\label{sec:related_multi}
+Applications for tiny computers are often parallel in nature.
+Tasks like reading sensors, watching input devices, operating actuators and maintaining communication are often loosely dependent on each other and are preferably executed in parallel.
+Microcontrollers often do not benefit from an \gls{OS} due to memory and processing constraints.
+Therefore, writing multitasking applications in an imperative language is possible but the tasks have to be interleaved by hand \citep{feijs_multi-tasking_2013}.
+This results in hard to maintain, error prone and unscalable spaghetti code.
+
+There are many solutions to overcome this problem in imperative languages.
+
+If the host language is a functional language (e.g.\ the aforementioned scheme variants) multitasking can be achieved without this burden relatively easy using continuation style multiprocessing \citep{wand_continuation-based_1980}.
+Writing in this style is complicated and converting an existing program in this continuation passing style results in relatively large programs.
+Furthermore, there is no built-in thread-safe communication possible between the tasks.
+A \gls{TOP} or \gls{FRP} based language benefits even more because the programmer is not required to explicitly define continuation points.
+
+Regular preemptive multithreading is too memory intensive for smaller microcontrollers and therefore not suitable.
+Manual interleaving of imperative code can be automated to certain extents.
+Solutions often require an \gls{RTOS}, have a high memory requirement, do not support local variables, no thread-safe shared memory, no composition or no events as described in \cref{tbl:multithreadingcompare}.
+The table compares the solutions in the relevant categories with \gls{MTASK}.
+
+\begin{table}[ht]
+       \begin{threeparttable}
+               \caption{%
+                       An overview of imperative multithreading solutions for tiny computers with their relevant characteristics.
+                       The characteristics are: sequential execution, local variable support, parallel composition, deterministic execution, bounded execution and safe shared memory (adapted from \citet[p.\ 12]{santanna_safe_2013}).
+               }\label{tbl:multithreadingcompare}
+%              \begin{tabular}{lc>{\columncolor[gray]{0.95}}cc>{\columncolor[gray]{0.95}}cc>{\columncolor[gray]{0.95}}cc}
+               \small
+               \begin{tabular}{lccccccc}
+                       \toprule
+                       \multicolumn{2}{c}{Language} & \multicolumn{3}{c}{Complexity} & \multicolumn{3}{c}{Safety}\\
+                       \midrule
+                       Name         & Year & SeqCmp    & LocVar    & ParCmp    & DetEx     & BndEx                  & SafeMem\\
+                       \midrule
+                       Preemptive   & many & \CIRCLE{} & \CIRCLE{} & \Circle{} & \Circle{} & rt                     & \Circle{}\\
+                       nesC         & 2003 & \Circle{} & \Circle{} & \Circle{} & \CIRCLE{} & async                  & \Circle{}\\
+                       OSM          & 2005 & \Circle{} & \CIRCLE{} & \CIRCLE{} & \Circle{} & \Circle{}              & \Circle{}\\
+                       Protothreads & 2006 & \CIRCLE{} & \Circle{} & \Circle{} & \CIRCLE{} & \Circle{}              & \Circle{}\\
+                       TinyThreads  & 2006 & \CIRCLE{} & \CIRCLE{} & \Circle{} & \CIRCLE{} & \Circle{}              & \Circle{}\\
+                       Sol          & 2007 & \CIRCLE{} & \CIRCLE{} & \CIRCLE{} & \CIRCLE{} & \Circle{}              & \Circle{}\\
+                       FlowTask     & 2011 & \CIRCLE{} & \CIRCLE{} & \Circle{} & \Circle{} & \Circle{}              & \Circle{}\\
+                       Ocram        & 2013 & \CIRCLE{} & \CIRCLE{} & \Circle{} & \CIRCLE{} & \Circle{}              & \Circle{}\\
+                       C\'eu        & 2013 & \CIRCLE{} & \CIRCLE{} & \CIRCLE{} & \CIRCLE{} & \CIRCLE{}              & \CIRCLE{}\\
+                       \Gls{MTASK}  & 2022 & \CIRCLE{} & \CIRCLE{} & \CIRCLE{} & \CIRCLE{} & \LEFTcircle{}\tnote{1} & \LEFTcircle{}\tnote{2}\\
+                       \bottomrule
+               \end{tabular}
+               \begin{tablenotes}
+                       \item [1] Only for tasks, not for expressions.
+                       \item [2] Using \glspl{SDS}.
+               \end{tablenotes}
+       \end{threeparttable}
+\end{table}
 
 \section{History of \texorpdfstring{\gls{MTASK}}{mTask}}
 The development of \gls{MTASK} or its predecessors has been going on for almost seven years now though it really set off during my master's thesis.
@@ -117,16 +184,13 @@ In 2019, the \gls{CEFP}\slash\gls{3COWS} summer school in Budapest, Hungary host
 In 2022, the SusTrainable summer school in Rijeka, Croatia hosted a course on developing greener \gls{IOT} applications using \gls{MTASK} as well \citep{lubbers_green_2022}.
 Several students worked on extending \gls{MTASK} with many useful features:
 \Citet{van_der_veen_mutable_2020} did preliminary work on a green computing analysis, built a simulator, and explored the possibilities for adding bounded datatypes; \citet{de_boer_secure_2020} investigated the possibilities for secure communication channels; \citeauthor{crooijmans_reducing_2021} \citeyearpar{crooijmans_reducing_2021,crooijmans_reducing_2022} added abstractions for low-power operation to \gls{MTASK} such as hardware interrupts and power efficient scheduling; and \citet{antonova_mtask_2022} defined a preliminary formal semantics for a subset of \gls{MTASK}.
+In 2023, the SusTrainable summer school in Coimbra, Portugal will host a course on \gls{MTASK} as well.
 
 \subsection*{\texorpdfstring{\gls{MTASK}}{mTask} in practise}
 Funded by the Radboud-Glasgow Collaboration Fund, collaborative work was executed with Phil Trinder, Jeremy Singer, and Adrian Ravi Kishore Ramsingh.
-An existing smart campus application was developed using \gls{MTASK} and quantitively and qualitatively compared to the original application that was developed using a traditional \gls{IOT} stack \citep{lubbers_tiered_2020}.
+An existing smart campus application was developed using \gls{MTASK} and quantitatively and qualitatively compared to the original application that was developed using a traditional \gls{IOT} stack \citep{lubbers_tiered_2020}.
 This research was later extended to include a four-way comparison: \gls{PYTHON}, \gls{MICROPYTHON}, \gls{ITASK}, and \gls{MTASK} \citep{lubbers_could_2022}.
-Currently, power efficiency behaviour of traditional versus \gls{TOP} \gls{IOT} stacks is being compared as well adding a \gls{FREERTOS} implementation to the mix as well.
-
-\section{Future work}
-Plans for extensions and improvements include exploring integrating \gls{TINYML} into \gls{MTASK}; adding intermittent computing support to \gls{MTASK}; and extending the formal semantics to cover the entirety of the language.
-In 2023, the SusTrainable summer school in Coimbra, Portugal will host a course on \gls{MTASK} as well.
+Currently, power efficiency behaviour of traditional versus \gls{TOP} \gls{IOT} stacks is being compared as well adding a \gls{FREERTOS}, and an elixer/potato implementation to the mix as well.
 
 \input{subfilepostamble}
 \end{document}
index 5064d7e..2ba1ffd 100644 (file)
@@ -7,10 +7,12 @@
 \chapter{Green computing with \texorpdfstring{\gls{MTASK}}{mTask}}%
 \label{chp:green_computing_mtask}
 \begin{chapterabstract}
-       This chapter demonstrate the energy saving features of \gls{MTASK}.
-       First it gives an overview of general green computing measures for edge devices.
-       Then \gls{MTASK}'s task scheduling is explained and it is shown how to customise it so suit the applications and energy needs.
-       Finally it shows how to use interrupts in \gls{MTASK} to reduce the need for polling.
+       \noindent This chapter demonstrate the energy saving features of \gls{MTASK} by
+       \begin{itemize}
+               \item giving an overview of general green computing measures for edge devices;
+               \item explaining \gls{MTASK}'s task scheduling, and it is shown how to customise it so suit the applications and energy needs;
+               \item showing how to use interrupts in \gls{MTASK} to reduce the need for polling.
+       \end{itemize}
 \end{chapterabstract}
 
 The edge layer of the \gls{IOT} contains small devices that sense and interact with the world and it is crucial to lower their energy consumption.
diff --git a/top/img/sim.png b/top/img/sim.png
new file mode 100644 (file)
index 0000000..ed0aabd
Binary files /dev/null and b/top/img/sim.png differ
index d33198b..20d2a52 100644 (file)
@@ -7,8 +7,12 @@
 \chapter{Implementation}%
 \label{chp:implementation}
 \begin{chapterabstract}
-       This chapter shows the implementation of the \gls{MTASK} system.
-       It is threefold: first it shows the implementation of the byte code compiler for \gls{MTASK}'s \gls{TOP} language, then is details of the implementation of \gls{MTASK}'s \gls{TOP} engine that executes the \gls{MTASK} tasks on the microcontroller, and finally it shows how the integration of \gls{MTASK} tasks and \glspl{SDS} is implemented both on the server and on the device.
+       \noindent This chapter shows the implementation of the \gls{MTASK} system by:
+       \begin{itemize}
+               \item shows the implementation of the byte code compiler for \gls{MTASK}'s \gls{TOP} language;
+               \item gives details of the implementation of \gls{MTASK}'s \gls{TOP} engine that executes the \gls{MTASK} tasks on the microcontroller;
+               \item and explains how the integration of \gls{MTASK} tasks and \glspl{SDS} is implemented both on the server and on the device.
+       \end{itemize}
 \end{chapterabstract}
 
 Microcontrollers usually have flash-based program memory which wears out fairly quick.
@@ -480,8 +484,7 @@ instance sds BCInterpret where
 \end{lstClean}
 % VimTeX: SynIgnore off
 
-
-\section{\texorpdfstring{\Gls{RTS}}{Run time system}}
+\section{\texorpdfstring{\Glsxtrlong{RTS}}{Run time system}}
 
 The \gls{RTS} is designed to run on systems with as little as \qty{2}{\kibi\byte} of \gls{RAM}.
 Aggressive memory management is therefore vital.
index f7e9ec3..effca75 100644 (file)
        \noindent This chapter introduces the \gls{TOP} language \gls{MTASK} language by:
        \begin{itemize}
                \item introducing the setup of the \gls{EDSL};
-               \item and showing the language interface and examples for the type system, data types, expressions, tasks and their combinators.
+               \item describing briefly the various interpretations;
+               \item and showing the language interface for:
+                       \begin{itemize}
+                               \item the types;
+                               \item expressions, datatypes, and functions;
+                               \item tasks and task combinators;
+                               \item and \glspl{SDS}.
+                       \end{itemize}
        \end{itemize}
 \end{chapterabstract}
 
 The \gls{MTASK} system is a complete \gls{TOP} programming environment for programming microcontrollers.
 This means that it not only contains a \gls{TOP} language but also a \gls{TOP} engine.
-It is implemented as an \gls{EDSL} in \gls{CLEAN} using class-based---or tagless-final---embedding (see \cref{sec:tagless-final_embedding}).
 Due to the nature of the embedding technique, it is possible to have multiple interpretations for programs written in the \gls{MTASK} language.
-Not all of these intepretations are necessarily \gls{TOP} engines, some may perform an analysis over the program or typeset the program so that the output can be shown after evaluating the expression at run time.
-The following interpretations are available for \gls{MTASK}.
+As the language is implemented as an \gls{EDSL} in \gls{CLEAN} using class-based---or tagless-final---embedding (see \cref{sec:tagless-final_embedding}).
+This means that the language is a collection of type classes and interpretations are data types implementing these classes.
+Consequently, the language is extensible both in language constructs and in intepretations.
+Adding a language construct is as simple as adding a type class and adding an interpretation is done by creating a new data type and providing implementations for the various type classes.
+Let us illustrate this by taking the very simple language of literal values.
+This language interface can be described using a single type constructor class with a single function \cleaninline{lit}.
+This function is for lifting a values, as long as it has a \cleaninline{toString} instance, from the host language to our new \gls{DSL}.
+
+\begin{lstClean}
+class literals v where
+       lit :: a -> v a | toString a
+\end{lstClean}
+
+Providing an evaluator is straightforward as can be seen in the following listing.
+The evaluator is just a box holding a value of the computation but could also be some monadic computation.
+
+\begin{lstClean}
+:: Eval a = Eval a
+
+runEval :: (Eval a) -> a
+runEval (Eval a) = a
+
+instance literals Eval where
+       lit a = Eval a
+\end{lstClean}
+
+Extending our language with a printer happens by defining a new data type and providing instances for the type constructor classes.
+The printer stores a printed representation and hence the type is just a phantom type.
+
+\begin{lstClean}
+:: Printer a = Printer String
+
+runPrinter :: (Printer a) -> String
+runPrinter (Printer a) = a
+
+instance literals Printer where
+       lit a = Printer (toString a)
+\end{lstClean}
+
+Finally, adding language constructs happens by defining new type classes and giving implementations for some of the interpretations.
+The following listing adds an addition construct to the language and shows implementations for the evaluator and printer.
 
-\begin{description}
-       \item[Printer]
+\begin{lstClean}
+class addition v where
+       add :: v a -> v a -> v a | + a
 
-               This interpretation converts the expression to a string representation.
-               As the host language \gls{CLEAN} constructs the \gls{MTASK} expressions at run time, it can be useful to show the constructed expression.
-       \item[Simulator]
+instance addition Eval where
+       add (Eval l) (Eval r) = Eval (l + r)
 
-               The simulator converts the expression to a ready-for-work \gls{ITASK} simulation in which the user can inspect and control the simulated peripherals and see the internal state of the tasks.
-       \item[Byte code compiler]
+instance addition Printer where
+       add (Printer l) (Printer r) = Printer ("(" +++ l +++ "+" +++ r +++ ")")
+\end{lstClean}
+
+Terms in our little toy language can be overloaded in their interpretation, they are just an interface.
+For example, $1+5$ is written as \cleaninline{add (lit 1) (lit 5)} and has the type \cleaninline{v Int \| literals, addition v}.
+\todo{hier nog uit\-leg\-gen hoe je meer\-de\-re in\-ter\-pre\-ta\-tions kunt ge\-brui\-ken?}
+
+\section{Interpretations}
+This section describes all \gls{MTASK}'s interpretations.
+Not all of these interpretations are necessarily \gls{TOP} engines, i.e.\ not all of the interpretations execute the terms/tasks.
+Some may perform an analysis over the program or typeset the program so that a textual representation can be shown.
+
+\subsection{Pretty printer}
+This interpretation converts the expression to a string representation.
+As the host language \gls{CLEAN} constructs the \gls{MTASK} expressions at run time, it can be useful to show the constructed expression.
+The only function exposed for this interpretation is the \cleaninline{showMain} (\cref{lst:showmain}) function.
+It runs the pretty printer and returns a list of strings containing the pretty printed result as shown in \cref{lst:showexample}.
+The pretty printing function does the best it can but obviously cannot reproduce the layout, curried functions and variable names.
+This shortcoming is illustrated by the example application for blinking a single \gls{LED} using a function and currying in \cref{lst:showexample}.
+
+\begin{lstClean}[caption={The entrypoint for the pretty printing interpretation.},label={lst:showmain}]
+:: Show a // from the mTask Show library
+showMain :: (Main (Show a)) -> [String] | type a
+\end{lstClean}
+
+\begin{lstClean}[caption={Pretty printing interpretation example.},label={lst:showexample}]
+blinkTask :: Main (MTask v Bool) | mtask v
+blinkTask =
+       fun \blink=(\state->
+               writeD d13 state >>|. delay (lit 500) >>=. blink o Not
+       ) In {main = blink true}
+
+// output:
+// fun f0 a1 = writeD(D13, a1) >>= \a2.(delay 1000) >>| (f0 (Not a1)) in (f0 True)
+\end{lstClean}
+
+\subsection{Simulator}
+The simulator converts the expression to a ready-for-work \gls{ITASK} simulation in which the user can inspect and control the simulated peripherals and see the internal state of the tasks.
+The task resulting from the \cleaninline{simulate} function presents the user with an interactive simulation environment (see \cref{lst:simulatemain,fig:sim}).
+From within the interactive application, tasks can be (partly) executed, peripheral states changed and \glspl{SDS} interacted with.
+
+\begin{lstClean}[caption={The entrypoint for the simulation interpretation.},label={lst:simulatemain}]
+:: TraceTask a // from the mTask Show library
+simulate :: (Main (TraceTask a)) -> [String] | type a
+\end{lstClean}
+
+\begin{figure}
+       \centering
+       \includegraphics[width=\linewidth]{simg}
+       \caption{Simulator interface for the blink program.}\label{fig:sim}
+\end{figure}
 
-               The compiler compiles the \gls{MTASK} program to a specialised byte code.
-               Using a handful of integration functions and tasks (see \cref{chp:integration_with_itask}), \gls{MTASK} tasks can be executed on microcontrollers and integrated in \gls{ITASK} as if they were regular \gls{ITASK} tasks.
-               Furthermore, with special language constructs, \glspl{SDS} can be shared between \gls{MTASK} and \gls{ITASK} programs.
-\end{description}
+\subsection{Byte code compiler}
+The main interpretation of the \gls{MTASK} system is the byte code compiler.
+With it, and a handful of integration functions and tasks, \gls{MTASK} tasks can be executed on microcontrollers and integrated in \gls{ITASK} as if they were regular \gls{ITASK} tasks.
+Furthermore, with a special language construct, \glspl{SDS} can be shared between \gls{MTASK} and \gls{ITASK} programs as well.
+This interface is explained thoroughly in \cref{chp:integration_with_itask}.
 
 When using the byte code compiler interpretation in conjunction with the \gls{ITASK} integration, \gls{MTASK} is a heterogeneous \gls{DSL}.
-I.e.\ some components---e.g.\ the \gls{RTS} on the microcontroller---is largely unaware of the other components in the system, and it is executed on a completely different architecture.
+I.e.\ some components---for example the \gls{RTS} on the microcontroller---is largely unaware of the other components in the system, and it is executed on a completely different architecture.
 The \gls{MTASK} language is an enriched simply-typed $\lambda$-calculus with support for some basic types, arithmetic operations, and function definition; and a task language (see \cref{sec:top}).
 
 \section{Types}
index e861028..3360822 100644 (file)
@@ -4,7 +4,7 @@
 
 \begin{document}
 \input{subfileprefix}
-\chapter{Could Tierless Languages Reduce IoT Development Grief?}%
+\chapter{Could Tierless Languages Reduce \texorpdfstring{\glsxtrshort{IOT}}{IoT} Development Grief?}%
 \label{chp:smart_campus}
 
 \begin{chapterabstract}