Browse Source

Initial commit

Julian Ospald 5 years ago
No known key found for this signature in database GPG Key ID: 220CD1C5BDEED020
2 changed files with 138 additions and 0 deletions
  1. +138
  2. BIN

+ 138
- 0
VL1.tex View File

@@ -0,0 +1,138 @@

% packages

% package configuration

% title page information
\author{Julian Ospald}
\institute{FH Bielefeld}
\title{Haskell: introduction}

% color definition


% page 0

% page 1
\frametitle{Why haskell?}
A Haskeller might claim: haskell...
\item eliminates certain classes of bugs
\item makes it easy to reason about code
\item decreases the bus-factor
\item makes it possible to apply huge changes to large programs without worrying about the implicit state machine
\item makes it easier to program complex problems
\item allows for clean APIs, even without any OOP
\item a haskell program of 10K LOC isn't that much different to maintain as a 100K LOC
We'll have to see if this holds true.

% page 1
\frametitle{Why haskell? (ctn.)}
From C++ std:
void pop();
From the C FLINT library:
void fmpz_mod_poly_add(
fmpz_mod_poly_t res,
const fmpz_mod_poly_t poly1,
const fmpz_mod_poly_t poly2);
Regular C functions in real-world (omitting examples on purpose):
\item 100+ LOC
\item at least 7 ifs, 4 whiles, 12 variables, 1 goto
\item access both static and global variables
\item indenting level of 5 or more
\item a lot of memory management and custom-made error handling

\frametitle{Why haskell? (ctn.)}
You need to change only one single line in such a C function. You have to know:
\item does the order of function calls matter?
\item how does the change effect the memory management? Do we have memory leaks? Do we access invalid memory?
\item does it change the state of static or global variables?
\item does it implicitly change the state of out-parameters?
\item if it changes any of those states, is the function still correct?
\item does the program flow break? Do we have unreachable codepaths now?
\item did you just nuke a small former Soviet state?

\frametitle{Why haskell? (ctn.)}
But java helps! Does it?
Sort of, because:
\item it improves APIs compared to C, since you can hide information in the state of an object (but... it's hidden now)
\item it has a garbage collector, so you don't need to worry too much about memory... unless it doesn't work OOTB anymore
Unfortunately, we:
\item now got even more states to keep track of (intellectual complexity?)
\item have clouded the program flow... it's now about object-interaction with their implicit states
\item still have \textbf{side effects} everywhere: one object changes the state of another and vice versa, may arbitrarily write to the hard drive, do kernel calls or launch a missle
Some parts of the implicit state machine have been made explicit by modelling classes, but it's still there and we have to deal with it, because we are modelling everything around states. Wouldn't it be nice if we could just forget about the global state machine? Maybe there is even a way to remove side effects and have more "predictability"? We are lucky. There is. It's called \textbf{Haskell}.

% page 2
\frametitle{What is haskell?}
Haskell is a \textbf{functional}, \textbf{pure}, \textbf{lazy} and \textbf{statically typed} high-level programming language.

% page3
\frametitle{What does \textbf{functional} mean?}
Think of haskell functions as regular \emph{mathematical} functions.
\item does this function write to the hard drive?
\item does the output depend on anything else except the input (e.g. time, environment, ...)?

% page4
\frametitle{What does \textbf{functional} mean? (ctn.)}
\item \emph{first-class} citizens: functions are values
\item a haskell program is what happens when \emph{expressions are evaluated}


function-machine.png View File

Before After
Width: 350  |  Height: 350  |  Size: 30 KiB