kill all orphans and widows
[phd-thesis.git] / top / finale.tex
index 3864fd2..1b65cfc 100644 (file)
@@ -2,7 +2,7 @@
 
 \input{subfilepreamble}
 
-\setcounter{chapter}{7}
+\setcounter{chapter}{8}
 
 \begin{document}
 \input{subfileprefix}
 \section{Finale}
 Traditionally, the \gls{IOT} has been programmed using layered, or tiered, architectures.
 Every layer has its own software and hardware characteristics, resulting in semantic friction.
+It is hard to orchestrate the smooth cooperation of the individual components, especially during maintenance of the entire \gls{IOT} application.
 \Gls{TOP} is a declarative programming paradigm designed to describe multi-tiered interactive systems from a single source.
+Such a tierless system prevents the orchestration problems of the tiered approach.
+The type system of the host language checks the \gls{ITASK} and \gls{MTASK} components and their interaction.
 However, it is not straightforward to run \gls{TOP} systems on resource-constrained devices such as edge devices.
 
 The \gls{MTASK} system bridges this gap by providing a \gls{TOP} programming language for edge devices.
@@ -30,7 +33,7 @@ Besides the usual \gls{FP} constructs, it contains basic tasks, task combinators
 It integrates seamlessly in \gls{ITASK}, a \gls{TOP} system for interactive web applications.
 In \gls{ITASK}, abstractions are available for the gritty details of interactive web applications such as program distribution, web applications, data storage, and user management.
 The \gls{MTASK} system abstracts away of all technicalities specific to edge devices such as communication, abstractions for sensors and actuators, interrupts and (multi) task scheduling.
-With \gls{ITASK} and \gls{MTASK}, all layers of an \gls{IOT} system can be programmed from a single declarative specification.
+When \gls{MTASK} is used together with \gls{MTASK}, all layers of the \gls{IOT} application are programmed from a single declarative specification.
 
 Any device equipped with the \gls{MTASK} \gls{RTS} can be used in the system and dynamically receive tasks for execution.
 This domain-specific \gls{OS} only is uploaded once, hence saving precious write cycles on the program memory.
@@ -42,8 +45,8 @@ Furthermore, \gls{ITASK} \glspl{SDS} can be lowered to \gls{MTASK} tasks as well
 
 \section{Related work}
 The novelties of the \gls{MTASK} system can be compared to existing systems in several categories.
-It is a 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}).
-\Cref{sec_t4t:TiredvsTierless} contains an elaborate related work section regarding tierless systems in general.
+It is an 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}).
+\Cref{sec_t4t:TiredvsTierless} contains an elaborate related work section regarding tierless systems.
 
 \subsection{Interpretation}\label{sec:related_int}
 There are a myriad of interpreted programming languages available for more powerful edge devices.
@@ -53,12 +56,12 @@ They lay pretty hefty constraints on the memory and as a result do not work on s
 Another interpretation solution for the tiniest devices is Firmata, a protocol for remotely controlling the microcontroller 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.
+It differs from our approach because it is required to mark continuation points by hand and there is no automatic safe data communication.
 
 \Citet{baccelli_reprogramming_2018} provide a single language \gls{IOT} system based on the RIOT \gls{OS} that allows runtime deployment of code snippets called containers.
 Both client and server are written in JavaScript.
 However, there is no integration between the client and the server other than that they are programmed from a single source.
-Mat\`e is an example of an early tierless sensor network framework where devices are provided with a virtual machine using TinyOS for dynamic provisioning \citep{levis_mate_2002}.
+Mat\`e is an example of a tierless framework for sensor networks where devices run a virtual machine using TinyOS for dynamic provisioning \citep{levis_mate_2002}.
 
 \subsection{DSLs}\label{sec:related_dsl}
 Many \glspl{DSL} provide higher-level programming abstractions for microcontrollers, for example providing strong typing or memory safety.
@@ -68,7 +71,7 @@ Both imperative \glspl{DSL} embedded in a functional language that compile to \c
 \subsection{Functional programming}\label{sec:related_fp}
 \Citet{haenisch_case_2016} showed that there are major benefits to using functional languages on edge devices.
 They show 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 resource-constrained computers.
+Traditional implementations of general purpose functional languages have high memory requirements rendering them unuseable for resource-constrained 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.
@@ -81,20 +84,19 @@ An interpreted Lisp implementation called uLisp also exists that runs on microco
 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}.
+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 is superior to manual threading because the programmer is not required to explicitly define continuation points.
+Moreover, there is no built-in thread-safe communication possible between the tasks.
+A \gls{TOP} or \gls{FRP} language is superior to manual threading 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}.
-This table extends a comparison table with various solutions to multitasking to \gls{MTASK} in the relevant categories.
-\todo[inline]{Uitleg over de talen geven}
+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}.
+This table extends the comparison table with \gls{MTASK} in the relevant categories.
 
 \begin{table}
        \begin{threeparttable}
@@ -121,7 +123,7 @@ This table extends a comparison table with various solutions to multitasking to
                        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}\\
+                       \gls{MTASK}  & 2022 & \CIRCLE{} & \CIRCLE{} & \CIRCLE{} & \CIRCLE{} & \CIRCLE{}\tnote{1} & \CIRCLE{}\tnote{2}\\
                        \bottomrule
                \end{tabular}
                \endgroup
@@ -144,26 +146,23 @@ Tasks in \gls{TOP} are also event driven and can be combined with combinators.
 \Gls{TOP} allows for more complex collaboration patterns than \gls{FRP} \citep{wang_maintaining_2018}.
 Consequently, \gls{TOP} is unable to provide strong guarantees on memory usage, something \gls{FRP} is capable of.
 For example, arrowised \gls{FRP} can give guarantees on upper memory bounds \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 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, in contrast to in \gls{MTASK}, the tasks are not interpreted and there is no automated communication with a server.
-
-Other examples are 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 \citep{hess_arduino-copilot_2020}.
+Other examples are CFRP \citep{suzuki_cfrp_2017}, XFRP \citep{shibanai_distributed_2018}, Juniper \citep{helbling_juniper:_2016}, Hailstorm \citep{sarkar_hailstorm_2020}, Haski \citep{valliappan_towards_2020}, arduino-copilot \citep{hess_arduino-copilot_2020}.
 
 \subsection{Task-oriented programming}\label{sec:related_top}
 \Gls{TOP} as a paradigm has 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.
+\Gls{IOT} applications contain a distributed and multi-user component, but the software on the device 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 show that applications tend to be able to cope well with interruptions and are more maintainable.
@@ -175,7 +174,7 @@ There are many ways of extending the research on the \gls{MTASK} system that als
 \subsection{Security}
 The \gls{IOT} has reached the news concerningly many times regarding the lack of security \citep{alhirabi_security_2021}.
 The fact that the devices are embedded in the fabric, are hard to reach and thus to update, and can only run limited cryptographic algorithms due to their constrained resources makes security difficult.
-The security of \gls{MTASK} and the used protocols are deliberately overlooked at the moment
+The security of \gls{MTASK} and the used protocols are deliberately overlooked at the moment.
 The \gls{MTASK} language and \gls{RTS} are modular.
 For example, the communication channels are communication method agnostic and operate through a simple duplex channel interface.
 It should therefore be fairly easy to apply standard security measures to them by replacing communication methods and applying off-the-shelve authentication and encryption to the protocol.
@@ -184,7 +183,8 @@ Nonetheless, this deserves much more attention.
 The future and related work for the security of \gls{MTASK} and tierless systems is more thoroughly presented in \cref{ssec_t4t:security}.
 
 \subsection{Advanced edge devices techniques}
-Edge devices produce a lot of data and it is not always effective to send this data to the server for processing.
+Edge devices produce a lot of data.
+It is not always effective to send this data to the server for processing.
 Leaving the produced data and computations on the edge device is called edge computing \citep{shi_edge_2016}.
 The \gls{MTASK} system exhibits many properties of edge computing because it is possible to run entire workflows on the device.
 However, it is interesting to see how far this can be extended.
@@ -198,18 +198,19 @@ Instead of equipping the edge device with a battery, a capacitor is used in conj
 After a reset, the program state is resumed from a checkpoint that was stored in some non-volatile memory.
 This technique is called intermittent computing \citep{hester_batteries_2019}.
 Many intermittent computing solutions rely on annotations from the programmer to divide the program into atomic blocks, sometimes called tasks as well.
-These blocks are marked as such, because in the case of an reset of the system, the work must be done again.
+These blocks are marked as such, because in the case of a reset of the system, the work must be done again.
 Examples of such blocks are \gls{I2C} transmissions or calculations that rely on recent sensor data.
 In \gls{MTASK}, all work expressed by tasks is already split up in atomic pieces of work, i.e.\ the work is a side effect of rewriting.
-Furthermore, creating checkpoints should be fairly straightforward as \gls{MTASK} tasks do not rely on any global state---all information required to execute a task is stored in the task tree.
-It is interesting to see what \gls{TOP} abstraction are useful for intermittent computing and what solutions are required to make this work.
+Furthermore, creating checkpoints is fairly straightforward as \gls{MTASK} tasks do not rely on any global state---all information required to execute a task is stored in the task tree.
+It is interesting to see what \gls{TOP} abstractions are useful to support intermittent computing properly and what solutions are required to make it work.
 
-Mesh networks allow for communication not only to-and-fro the device and server but also between devices.
+Mesh networks allow for communication not only to and fro the device and server but also between devices.
 The \gls{ITASK} system already contains primitives for distributed operation.
 For example, it is possible to run tasks or share data with \glspl{SDS} on different machines.
 It is interesting to investigate how this networking technique can be utilised in \gls{MTASK}.
 
-Finally, \glspl{FPGA} have been becoming cheaper and faster recently, allowing for purely functional code to be translated to \glspl{FPGA} code efficiently \citep{baaij_digital_2015}.
+\Glspl{FPGA} are highly customisable integrated chips consisting of programmable gates.
+Promising research has gone into translating purely functional code to \gls{FPGA} configurations \citep{baaij_digital_2015}.
 It would be interesting to see how and whether (parts of) \gls{TOP} programs or the functionality of the \gls{MTASK} \gls{OS} could be translated to \gls{FPGA} specifications.
 
 \subsection{Formal semantics}
@@ -231,8 +232,9 @@ However, this approach requires a very powerful host language in which task comb
 It could be fruitful to investigate which workflows cannot be specified with the limited set of combinators available in \gls{MTASK}.
 Furthermore, it is unclear whether all derived combinators from \gls{ITASK} can be expressed in terms of \gls{MTASK} combinators.
 \Citet{van_der_aalst_workflow_2003} defines a benchmark set of workflow patterns.
-It is interesting to see which patterns can be implemented with \gls{MTASK}, and what additional combinators are needed.
-Moreover, editors are a crucial part of \gls{TOP}.
+It is interesting to see which patterns can already be implemented with just \gls{MTASK}, which require a round-trip with the server, and what additional combinators would be needed.
+
+Editors are a crucial part of \gls{TOP}.
 In \gls{MTASK}, sensors can be seen as read-only shared editors that are updated by the system.
 It is interesting to investigate how actual interactive editors would fit in \gls{MTASK}.
 For example, many smartwatches contain touch sensitive screens that could be used to interact with the user in this way.
@@ -266,7 +268,7 @@ However, it should be possible to make abstractions over an increasing number of
 For example, the pin mode could be made a type parameter of the \gls{GPIO} pins, or interrupt handling could be made safer by incorporating the capabilities of the devices in order to reduce run-time errors.
 
 \subsection{Scheduling}
-The scheduling in \gls{MTASK} works quite well but it is not real time.
+The scheduling in \gls{MTASK} works quite well, but it is not real time.
 There is a variant of \gls{FRP} called \gls{PFRP} that allows for real-time operation \citep{belwal_variable_2013}.
 Furthermore, an alternative to reducing the energy consumption by going to sleep is stepping down the processor frequency.
 So called \gls{DVFS} is a scheduling technique that slows down the processor in order to reach the goals as late as possible, reducing the power consumption.
@@ -283,7 +285,7 @@ A first throw at a class-based shallowly \gls{EDSL} for microcontrollers was mad
 The language was called \gls{ARDSL} and offered a type safe interface to \gls{ARDUINO} \gls{CPP} dialect.
 A \gls{CPP} code generation interpretation was available together with an \gls{ITASK} simulation interpretation.
 There was no support for tasks nor functions.
-Some time later in the 2015 \gls{CEFP} summer school, an extended version was created that allowed the creation of imperative tasks, local \glspl{SDS} and the usage of functions \citep{koopman_type-safe_2019}.
+Some time later in the 2015 CEFP summer school, an extended version was created that allowed the creation of imperative tasks, local \glspl{SDS} and the usage of functions \citep{koopman_type-safe_2019}.
 The name then changed from \gls{ARDSL} to \gls{MTASK}.
 
 \subsection{Integration with iTask}
@@ -293,7 +295,7 @@ In this way, entire \gls{IOT} systems could be programmed from a single source.
 However, this version used a simplified version of \gls{MTASK} without functions.
 This was later improved upon by creating a simplified interface where \glspl{SDS} from \gls{ITASK} could be used in \gls{MTASK} and the other way around \citep{lubbers_task_2018}.
 It was shown by \citet{amazonas_cabral_de_andrade_developing_2018} that it was possible to build real-life \gls{IOT} systems with this integration.
-Moreover, a course on the \gls{MTASK} simulator was provided at the 2018 \gls{CEFP}\slash\gls{3COWS} winter school in Ko\v{s}ice, Slovakia \citep{koopman_simulation_2023}.
+Moreover, a course on the \gls{MTASK} simulator was provided at the 2018 \gls{3COWS} winter school in Ko\v{s}ice, Slovakia \citep{koopman_simulation_2023}.
 
 \subsection{Transition to Task-oriented programming}
 The \gls{MTASK} language as it is now was introduced in 2018 \citep{koopman_task-based_2018}.
@@ -301,7 +303,7 @@ This paper updated the language to support functions, simple tasks, and \glspl{S
 Later the byte code compiler and \gls{ITASK} integration was added to the language \citep{lubbers_interpreting_2019}.
 Moreover, it was shown that it is very intuitive to write microcontroller applications in a \gls{TOP} language \citep{lubbers_multitasking_2019}.
 One reason for this is that a lot of design patterns that are difficult using standard means are for free in \gls{TOP} (e.g.\ multithreading).
-In 2019, the \gls{CEFP}\slash\gls{3COWS} summer school in Budapest, Hungary hosted a course on developing \gls{IOT} applications with \gls{MTASK} as well \citep{lubbers_writing_2023}.
+In 2019, the \gls{3COWS} summer school in Budapest, Hungary hosted a course on developing \gls{IOT} applications with \gls{MTASK} as well \citep{lubbers_writing_2023}.
 
 \subsection{Task-oriented programming}
 In 2022, the SusTrainable summer school in Rijeka, Croatia hosted a course on developing greener \gls{IOT} applications using \gls{MTASK} \citep{lubbers_green_2022}.
@@ -312,8 +314,8 @@ In 2023, the SusTrainable summer school in Coimbra, Portugal will host a course
 \subsection{Using 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 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}, and an Elixir implementation to the mix as well.
+This research was later extended to include a four-way comparison: \gls{PYTHON}, \gls{MICROPYTHON}, \gls{ITASK}, and \gls{MTASK} \citep{lubbers_could_2023} (see \cref{chp:smart_campus}).
+Currently, power efficiency behaviour of traditional versus \gls{TOP} \gls{IOT} stacks is being compared as well adding a FreeRTOS, and an Elixir implementation to the mix as well.
 
 \input{subfilepostamble}
 \end{document}