better structure with subfiles
[phd-thesis.git] / introduction / introduction.tex
1 \documentclass[../thesis.tex]{subfiles}
2
3 \begin{document}
4 \ifSubfilesClassLoaded{
5 \pagenumbering{arabic}
6 }{}
7 \chapter{Introduction}%
8 \label{chp:introduction}
9 The sheer number of connected devices around us is increasing exponentially.
10 First and foremost, these devices are driven by software.
11 This thesis is about \ldots
12 \todo[inline]{introduction}
13
14 \section{Internet of Things}
15 \todo[inline]{add more citations and rewrite to make modern}
16 The \gls{IOT} is growing rapidly and it is changing the way people and machines interact with the world.
17 While the term \gls{IOT} briefly gained interest around 1999 to describe the communication of \gls{RFID} devices~\cite{}, it probably already popped up halfway the eigthies in a speech by Peter T. Lewis~\cite{peter_t_lewis_speech_1985}.
18
19 \begin{quote}
20 The \acrlong{IOT}, or \acrshort{IOT}, is the integration of people, processes and technology with connectable devices and sensors to enable remote monitoring, status, manipulation and evaluation of trends of such devices.
21 \end{quote}
22
23 CISCO states that the \gls{IOT} only started when there where as many connected devices as there were people on the globe, i.e.\ around 2008~\cite{evans_internet_2011}.
24 Today, the \gls{IOT} is the term for a system of devices that sense the environment, act upon it and communicate with each other and the world.
25 These connected devices are already in everyone's household in the form of smart electricity meters, smart fridges, smartphones, smart watches, home automation, \etc.
26
27 When describing \gls{IOT} systems, a layered, or tiered architecture is often used to compartmentalize the technology.
28 The number of tiers heavily depends on the complexity of the model but for the intents and purposes of the thesis, the four layer architecture shown in \cref{fig:iot-layers} is used.
29
30 \begin{figure}[ht]
31 \centering
32 \includestandalone{iot-layers}
33 \caption{The four layered \gls{IOT} architecture.}%
34 \label{fig:iot-layers}
35 \end{figure}
36
37 \begin{description}
38 \item[Presentation layer] This presentation layer provides the interface between the user and the \gls{IOT} application.
39 For example, in home automation, this is often implemented as a web interface or a mobile app.
40 \item[Application layer]
41 Servers often power the application layer, by providing the data storage,
42 One of its goals is to provide the \gls{API}, interfaces and data storage
43 \item[Network layer] connects all layers together.
44 In many applications this may be implemented using conventional networking techniques such as WiFi or wire networks.
45 However, recently, networks tailored to the needs of \gls{IOT} applications have been increasingly popular such as \gls{BLE}, LoRa, ZigBee or LTE-M.
46 \item[Perception layer], also called edge layer, collects the data, interacts with the environment and consists of (edge) devices equipped with various sensors and actuators.
47 As a special type of device, it may also contain a \gls{SN}.
48 A \gls{SN} is a collection of sensors connected by a mesh network or central hub.
49 \end{description}
50
51 While the number of devices seems to be growing exponentially fast, programming \gls{IOT} systems remains difficult as there is a lot of semantic friction~\cite{ireland_classification_2009}.
52
53 The devices are a large heterogeneous collection of different platforms, protocols and languages resulting in impedance problems or semantic friction between layers~\cite{ireland_classification_2009}.
54
55 Additionaly, the perception layer often is a heterogeneous collections of microcontrollers as well, each having their own peculiarities, language of choice and hardware interfaces.
56 The hardware needs to be cheap, small-scale and energy efficient.
57 As a result, the \glspl{MCU} used to power these devices do not have a lot of computational power, a soup\c{c}on of memory, and little communication bandwidth.
58 Typically the devices do not run a full fledged \gls{OS} but a compiled firmware.
59 This firmware is often written in an imperative language that needs to be flashed to the program memory.
60 It is possible to dynamically send the program to the program memory using \gls{OTA} programming~\cite{baccelli_scripting_2018,baccelli_reprogramming_2018}.
61 Program memory typically is flash based and only lasts a couple of thousand writes before it wears out.
62 While devices are getting a bit faster, smaller, and cheaper, they keep these properties to an extent.
63 The properties of the device greatly reduce the flexibility for dynamic systems where tasks are created on the fly, executed on demand and require parallel execution.
64 These problems can be mitigated by dynamically sending code to be interpreted to the \gls{MCU}.
65 With interpretation, a specialized interpreter is flashed in the program memory once that receives the program code to execute at runtime.
66
67 %weiser_computer_1991
68 \section{Domain-specific languages}
69 % General
70 Programming languages can be divided up into two categories: \glspl{DSL} and \glspl{GPL}~\cite{fowler_domain_2010}.
71 Where \glspl{GPL} are not made with a demarcated area in mind, \glspl{DSL} are tailor-made for a specific domain.
72 Writing idiomatic domain-specific code in an \gls{DSL} is easy but this may come at the cost of the \gls{DSL} being less expressive to an extent that it may not even be Turing complete.
73 \Glspl{DSL} come in two main flavours: standalone and embedded\footnote{Also called external and internal respectively.} of which \glspl{EDSL} can again be classified into heterogeneous and homogeneous languages (see \cref{fig:hyponymy_of_dsls} for this hyponymy).
74
75 \begin{figure}[ht]
76 \centering
77 \includestandalone{hyponymy_of_dsls}
78 \caption{Hyponymy of \glspl{DSL} (adapted from~\cite[pg.\ 2]{mernik_extensible_2013})}%
79 \label{fig:hyponymy_of_dsls}
80 \end{figure}
81
82 \glspl{DSL} where historically created as standalone languages which means all the machinery is developed solely for the language.
83 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.
84 Unfortunately it also means that they need to develop a compiler or interpreter for the language to be usable making standalone \glspl{DSL} costly to create.
85 Examples of standalone \glspl{DSL} are regular expressions, make, yacc, XML, SQL, \etc.
86
87 A radically different approach is embeddding the \gls{DSL} in a host language, i.e.\ \glspl{EDSL}~\cite{hudak_modular_1998}.
88 By defining the language as constructs in the host language, much of the machinery is inherited and the cost of creating embedded languages is very low.
89 There are however two sides to the this coin.
90 If the syntax of the host language is not very flexible, the syntax of the \gls{DSL} may become clumsy.
91 Furthermore, errors shown to the programmer may be larded with host language errors, making it difficult for a non-expert of the host language to work with the \gls{DSL}.
92
93 Tratt applied a notion from metaprogramming~\cite{sheard_accomplishments_2001} to \glspl{EDSL} to define homogeneity and heterogeneity of \glspl{EDSL} as follows~\cite{tratt_domain_2008}:
94 \begin{quote}
95 a homogeneous system is one where all the components are specifically designed to work with each other, whereas in heterogeneous systems at least one of the components is largely, or completely, ignorant of the existence of the other parts of the system.
96 \end{quote}
97 Homogeneous \glspl{EDSL} are therefore languages that are solely defined as an extension to their host language.
98 They often restrict features of the host language to provide a safer interface or capture an idiomatic pattern in the host language for reuse.
99 The difference between a library and a homogeneous \glspl{EDSL} is not always clear.
100 Examples of homogeneous \glspl{EDSL} are libraries such as ones for \glspl{GUI} creation, LISP's macro system, \etc.
101
102 On the other hand, heterogeneous \glspl{EDSL} are languages that are not executed in the host language.
103 For example, Elliott et al.\ 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~\cite{elliott_compiling_2003}.
104 In fact, \gls{ITASK} and \gls{MTASK} are both heterogeneous \glspl{EDSL}.
105
106 \section{Functional programming}\label{ssec:functional programming}
107 \Gls{FP} is \ldots
108 \Gls{FP} languages are naturally suitable as a host language for \gls{DSL} embedding because of their rich type systems and minimal and extensible syntax~\cite{gibbons_functional_2015}.
109
110 \section{Task-oriented programming}
111 \Gls{TOP} is a declarative programming paradigm designed to model interactive systems~\cite{plasmeijer_task-oriented_2012}.
112 Instead of dividing problems into layers or tiers, as is done in \gls{IOT} architectures as well, it deals with separation of concerns in a novel way.
113 From the data types, utilising various \emph{type-parametrised} concepts, all other aspects are handled (see \cref{fig:tosd}).
114 This approach to software development is also called \gls{TOSD}~\cite{wang_maintaining_2018}.
115
116 \begin{figure}[ht]
117 \centering
118 \begin{subfigure}[t]{.5\textwidth}
119 \centering
120 \includestandalone{traditional}
121 \caption{Traditional layered approach.}
122 \end{subfigure}%
123 \begin{subfigure}[t]{.5\textwidth}
124 \centering
125 \includestandalone{tosd}
126 \caption{\Gls{TOSD} approach.}
127 \end{subfigure}
128 \caption{Separation of concerns in a traditional setting and in \gls{TOSD} (adapted from~\cite[pg.\ 20]{wang_maintaining_2018}).}%
129 \label{fig:tosd}
130 \end{figure}
131
132 \begin{description}
133 \item[Presentation layer: UI]
134 The \gls{UI} of the system is automatically generated from the representation of the type.
135 For instance, \gls{TOP} languages implemented in an \gls{FP} language often use generic programming or template metaprogramming to automatically achieve this.
136 \Gls{TOP} languages embedded in imperative programming languages may use introspection\todo{Do I want this sentence here?}.
137 Even though the \gls{UI} is generated from the structure of the datatypes, in many practical \gls{TOP} systems it can be tweaked afterwards to suit the specific needs of the application.
138 \item[Business layer: Tasks]
139 A task is an abstract representation of a piece of work that needs to be done.
140 It provides an intuitive abstraction over work in the real world.
141 Just as with real-life tasks and workflow, tasks can be combined in various ways such as in parallel or in sequence.
142 Furthermore, tasks are observable which means it is possible to observe a --- partial --- result during execution and act upon it by for example starting new tasks.
143 Examples of tasks are filling in a form, sending an email, reading a sensor or even doing a physical task.
144 \item[Resource access: \glspl{SDS}]
145 Tasks can communicate using task values but this imposes a problem in many collaboration patterns where tasks that are not necessarily related need to share data.
146 Tasks can also share data using \glspl{SDS}.
147 \Glspl{SDS} are an abstraction over any data.
148 An \gls{SDS} can represent typed data stored in a file, a chunk of memory, a database \etc.
149 \Glspl{SDS} can also represent external impure data such as the time, random numbers or sensory data.
150 Similar to tasks, transformation and combination of \glspl{SDS} is possible.
151 \item[\Gls{UOD}: PL]
152 The \gls{UOD} from the business layer is explicitly and separately modelled by the relations that exist in the functions of the host language.
153 \gls{TOP} languages are usually embedded in \gls{FP} languages but this not necessarily the case.
154 Some host languages also provide the implementations for the tasks and \glspl{SDS}.
155 \todo{dit moet beter}
156 \end{description}
157
158 \section{Thesis outline}
159
160 \todo[inline]{reference correct chapters}
161 Chapters 0 and 0 are based on the paper \emph{A Task-Based \acrshort{DSL} for Microcomputers}~\cite{koopman_task-based_2018}.
162
163 Chapters 0 and 0 are based on the Master's thesis and paper \emph{\glst{TOP} and the \glst{IOT}}~\cite{lubbers_task_2017,lubbers_task_2018}.
164
165 Chapters 0 and 0 are based on the paper \emph{Multitasking on Microcontrollers using \glst{TOP}}~\cite{lubbers_multitasking_2019}.
166
167 Chapters 0 and 0 are based on the paper \emph{Tiered versus Tierless \acrshort{IOT} Stacks: Comparing Smart Campus Software Architectures}~\cite{lubbers_tiered_2020}.
168
169 Chapters 0 and 0 are based on the paper \emph{Interpreting \glst{TOP} Programs on Tiny Computers}~\cite{lubbers_interpreting_2019}.
170
171 Chapters 0 and 0 are based on the paper \emph{Writing \glst{IOT} applications with \glst{TOP}}~\cite{lubbers_writing_2019}.
172
173 \input{subfilepostamble}
174 \end{document}