% !TEX program = xelatex
\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer}
\usepackage{../slides}
\usepackage{../graphics}
\usepackage{../langs}
%\usepackage{../data}
\usetikzlibrary{shapes}
\hfuzz=220pt
%\setmonofont[Scale=.88]{Consolas}
%\newfontfamily{\consolas}{Consolas}
\lstset{language=Scala,
style=mystyle,
numbersep=0pt,
numbers=none,
xleftmargin=0mm}
\colorlet{punct}{red!60!black}
\definecolor{background}{HTML}{EEEEEE}
\definecolor{delim}{RGB}{20,105,176}
\colorlet{numb}{magenta!60!black}
\lstdefinelanguage{json}{
basicstyle=\normalfont\ttfamily,
numbers=left,
numberstyle=\scriptsize,
stepnumber=1,
%numbersep=8pt,
showstringspaces=false,
breaklines=true,
%frame=lines,
%backgroundcolor=\color{background},
literate=
*{0}{{{\color{numb}0}}}{1}
{1}{{{\color{numb}1}}}{1}
{2}{{{\color{numb}2}}}{1}
{3}{{{\color{numb}3}}}{1}
{4}{{{\color{numb}4}}}{1}
{5}{{{\color{numb}5}}}{1}
{6}{{{\color{numb}6}}}{1}
{7}{{{\color{numb}7}}}{1}
{8}{{{\color{numb}8}}}{1}
{9}{{{\color{numb}9}}}{1}
{:}{{{\color{punct}{:}}}}{1}
{,}{{{\color{punct}{,}}}}{1}
{\{}{{{\color{delim}{\{}}}}{1}
{\}}{{{\color{delim}{\}}}}}{1}
{[}{{{\color{delim}{[}}}}{1}
{]}{{{\color{delim}{]}}}}{1},
}
\newcommand{\bl}[1]{\textcolor{blue}{#1}}
\newcommand{\RIGHTarrow}[3]{%
\begin{textblock}{0}(#2,#3)%
\onslide<#1>{%
\begin{tikzpicture}%
\node at (0,0) [single arrow, shape border rotate=0, fill=red,text=red]{a};%
\end{tikzpicture}}%
\end{textblock}}
\newcommand{\LEFTarrow}[3]{%
\begin{textblock}{0}(#2,#3)%
\onslide<#1>{%
\begin{tikzpicture}%
\node at (0,0) [single arrow, shape border rotate=180, fill=red,text=red]{a};%
\end{tikzpicture}}%
\end{textblock}}
\newcommand{\DOWNarrow}[3]{%
\begin{textblock}{0}(#2,#3)%
\onslide<#1>{%
\begin{tikzpicture}%
\node at (0,0) [single arrow, shape border rotate=270, fill=red,text=red]{a};%
\end{tikzpicture}}%
\end{textblock}}
% beamer stuff
\renewcommand{\slidecaption}{PEP (Scala) \liningnums{01}, King's College London}
% https://insights.stackoverflow.com/survey/2019#technology-most-loved-dreaded-and-wanted
% processors in the future / Ahmdahl law
% https://www.youtube.com/watch?v=_9mzmvhwMqw
\setbeamertemplate{itemize items}{$\bullet$}
\setbeamertemplate{itemize subitem}{$\bullet$}
\setbeamertemplate{itemize subsubitem}{$\bullet$}
\usepackage{tcolorbox}
\newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black}
\newtcolorbox{mybox2}[1]{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,title=#1}
\newtcolorbox{mybox3}[1]{colback=Cyan!5!white,colframe=Cyan!75!black,fonttitle=\bfseries,title=#1}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\frametitle{%
\begin{tabular}{@ {}c@ {}}
\\[5mm]
\hspace{7mm}\huge PEP Scala (\liningnums{1})
\end{tabular}}
\normalsize
\begin{center}
\begin{tabular}{ll}
Email: & christian.urban at kcl.ac.uk\\
%Office: & N\liningnums{7.07} (North Wing, Bush House)\bigskip\\
Slides \& Code: & KEATS\bigskip\\
%Office Hours: & Thursdays 12:00 -- 14:00\\
%Additionally: & (for Scala) Tuesdays 10:45 -- 11:45\\
\end{tabular}
\end{center}
%\tiny
%developed since 2004 bv Martin Odersky
%picture about assignments
\begin{textblock}{6}(0.5,0.5)
\includegraphics[scale=0.035]{../pics/assign.jpg}\\[-1mm]
\end{textblock}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{Why Scala?}
\begin{textblock}{6}(3,3)
\begin{tabular}{l}
\mbox{}\hspace{-1mm}\includegraphics[scale=0.36]{../pics/twitter.png}\\[-1mm]
\includegraphics[scale=0.30]{../pics/linked.png}\\
\includegraphics[scale=0.30]{../pics/guardian.jpg}\\[-3mm]
\mbox{}\hspace{-2mm}\includegraphics[scale=0.38]{../pics/morgan.png}\\[-3mm]
\includegraphics[scale=0.30]{../pics/suisse.png}\\
{\large\bf ...}
\end{tabular}
\end{textblock}
\begin{textblock}{6}(9,3)
\begin{tabular}{l}
\includegraphics[scale=0.20]{../pics/edf.png}\\[-1mm]
\includegraphics[scale=0.08]{../pics/novell.png}\\[-1mm]
\includegraphics[scale=0.30]{../pics/foursquare.png}\\
\includegraphics[scale=0.30]{../pics/hsbc.png}\\
{\large\bf ...}
\end{tabular}
\end{textblock}
\begin{textblock}{12}(2,11)
\footnotesize
\begin{mybox3}{A former student working now at Quantexa:}\it
``I am a former student. I graduated last year. I got my dream job
as a backend Scala developer. Most of the Scala I know is from PEP
2018/19. My interviewers said they expect code of a lesser quality
even from people with one year of experience.''
\end{mybox3}
\end{textblock}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{textblock}{6}(2,12)
%\begin{bubble}[9.4cm]
% \small
% developed since 2004 by Martin Odersky
% (he was behind Generic Java which was included in Java 5
% \ldots I am using Scala since maybe 2008?)
%\end{bubble}
%\end{textblock}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{Why Scala?}
\begin{itemize}
\item compiles to the JVM\\
\textcolor{gray}{(also JavaScript, native X86 in the works)}\medskip
\item integrates seamlessly with Java\medskip
\item combines \underline{\bf functional} and {\bf object-oriented} programming\medskip
\item no pointers, no null
%\item it is a bit on the ``theory'' / ``mathematical'' side\\
% \textcolor{gray}{(no pointers, no \texttt{null}, but expressions)}
\item often one can write very concise and elegant code
\end{itemize}\bigskip\medskip
%\small
%alternatives:\\
%Elm, Haskell, Ocaml, F$\sharp$, Erlang, ML, Lisp (Racket), \ldots
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\frametitle{Java vs Scala}
{\lstset{language=java,numbers=right}\fontsize{12}{12}\selectfont
\texttt{\lstinputlisting{Point.java}}}
\rule{11cm}{0.3mm}\\[-3mm]
{\lstset{language=scala}\fontsize{12}{12}\selectfont
\texttt{\lstinputlisting{Point.scala}}}
\begin{textblock}{6}(13,3)
\textbf{\large Java}
\end{textblock}
\begin{textblock}{6}(13,14.3)
\textbf{\large Scala}
\end{textblock}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{First Steps: Scala Tools}
\begin{itemize}
\item contains a REPL
\item I use VS Code and a Scala extension (M'place)
\begin{center}
\includegraphics[scale=0.10]{../pics/vscode.png}\\[-10mm]\mbox{}
\end{center}\bigskip
\item there is a plugin for Eclipse (called Scala IDE)\medskip
\item there is also a plugin for IntelliJ\medskip
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c, fragile]
\small
My personal keboard shortcut for VS Code\\
(in keybindings.json)\bigskip
\tiny
\begin{lstlisting}[language=json,numbers=none]
[
{
"key": "ctrl+enter",
"command": "workbench.action.terminal.runSelectedText",
"when": "editorTextFocus && editorHasSelection"
}
]
\end{lstlisting}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\frametitle{Why Scala?}
\onslide<2->{%
\begin{center}
{\large\bf{}Money?}\bigskip\\
\begin{tabular}{@{}c@{}c@{}}
\includegraphics[scale=0.2]{../pics/salary1.png} &
\includegraphics[scale=0.2]{../pics/salary2.png}\\
\multicolumn{2}{r@{}}{\footnotesize$^*$ source: Stackoverflow Developer Survey, 2019}
\end{tabular}
\end{center}
\RIGHTarrow{2}{2.0}{6.3}
\DOWNarrow{2}{10.1}{4.4}
}
\small
Elm, Rust, Haskell, Ocaml, F$\#$, Erlang, ML, Lisp (Racket)\ldots
\only<3>{
\begin{textblock}{6}(3.3,6.2)
\begin{bubble}[6.5cm]
\bf\huge\textcolor{RoyalBlue}{Functional Programming!}
\end{bubble}
\end{textblock}}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{\begin{tabular}{c}\\[2mm]
Why Functional\\[-2mm] Programming?\end{tabular}
}
%
\mbox{}\\[3.5cm]
\small
Elm, Haskell, Ocaml, F$\#$, Erlang, ML, Lisp (Racket)\ldots
\only<2>{
\begin{textblock}{6}(1.3,6.2)
\begin{bubble}[10cm]
\normalsize``If you want to see which features will be in mainstream programming
languages tomorrow, then take a look at functional programming
languages today.''\medskip\small\\
\hfill{}---Simon Peyton Jones (works at Microsoft)\\
\hfill{}main developer of the Glasgow Haskell Compiler
\end{bubble}
\end{textblock}}
\only<3>{
\begin{textblock}{6}(5,5.8)
\hspace{2mm}\includegraphics[scale=0.06]{../pics/assign.jpg}\\[-1mm]
\Large\alert{\hspace{5mm}\textbf{Immutability}}
\end{textblock}}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\begin{center}
\includegraphics[scale=0.4]{../pics/pure.png}
\end{center}
\begin{textblock}{6}(9,14)
\tiny$^*$ from ``What pure functional programming is all about?''
\end{textblock}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c, fragile]
{\Large Why bother? or\smallskip\\\hfill What is wrong with this?}\bigskip\bigskip
\begin{lstlisting}[language=C,numbers=none]
for (int i = 10; i < 20; i++) {
//...Do something interesting
// with i...
}
\end{lstlisting}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\mbox{}\\[-21mm]\mbox{}
\begin{center}
\begin{tikzpicture}[scale=1,
node/.style={
rectangle,rounded corners=3mm,
very thick,draw=black!50,
minimum height=18mm, minimum width=20mm,
top color=white,bottom color=black!20}]
\onslide<1-10>{
\node (A) at (0,0) [node]
{\mbox{\includegraphics[scale=0.15]{../pics/cplus2.jpg}}};
\node [above right] at (A.north west) {1986};}
\onslide<2->{
\node (B) at (3.5,0) [node]
{\mbox{\includegraphics[scale=0.15]{../pics/robotron.jpg}}};
\node [above right] at (B.north west) {1988, C};
\draw [->,line width=4mm] (A) -- (B);}
\onslide<3->{
\node (C0) at (6.3,0) {};
\node (C) at (8,0) [node]
{\mbox{\includegraphics[scale=0.15]{../pics/sun.jpg}}};
\node [above right] at (C.north west) {1992, {\small Linux}};
\draw [->,line width=4mm] (B) -- (C0);
\draw [->,line width=4mm] (C0) -- (C);}
\onslide<4->{
\node (D) at (8,-3.3) [node]
{\mbox{\includegraphics[scale=0.2]{../pics/gateway.jpg}}};
\draw [->,line width=4mm] (C) -- (D);
\node [below right] at (D.south west) {1996};}
\onslide<5->{
\node (E) at (4,-3.3) [node]
{\mbox{\includegraphics[scale=0.1]{../pics/appleg4.jpg}}};
\draw [->,line width=4mm] (D) -- (E);
\node [above right] at (E.north west) {2000};}
\onslide<6->{
\node (F0) at (1.5,-3.3) {};
\node (F1) at (1,-3.3) {};
\node (F) at (-0.9,-3.3) [node]
{\mbox{\includegraphics[scale=0.3]{../pics/appleair.png}}};
\draw [->,line width=4mm] (E) -- (F0);
\draw [->,line width=4mm] (F1) -- (F);
\node [above right] at (F.north west) {2012?};}
\onslide<7->{
\node (G) at (-0.9,-6.3) [node]
{\mbox{\includegraphics[scale=0.02]{../pics/applepro.jpg}}};
\draw [->,line width=4mm] (F) -- (G);
\node [right] at (G.west) {\hspace{22mm}2017};}
\end{tikzpicture}
\end{center}
\only<1>{%
\begin{textblock}{10}(2.5,5)
\includegraphics[scale=0.26]{../pics/cplus1.jpg}\\
\footnotesize 64K RAM, no HD, no monitor, lots of cables
\end{textblock}
\begin{textblock}{6}(10.9,4.5)
\includegraphics[scale=0.09]{../pics/mand1.png}
\includegraphics[scale=0.09]{../pics/mand2.png}
\end{textblock}
\begin{textblock}{6}(10.8,2.2)
\huge\bf 3 days
\end{textblock}
}
\only<8->{%
\begin{textblock}{8}(5.8,11.6)
\large\bf
\begin{tabular}{l@{}l}
1986:\, & no Internet\\
& no Amazon\\
& no FB, no mobiles,\ldots\\
\end{tabular}
\end{textblock}
}
\only<9>{
\begin{textblock}{1}(3,3)
\begin{bubble}[9cm]
\begin{tabular}{@{\hspace{8mm}}llll@{\hspace{8mm}}}
\\
\multicolumn{4}{c}{\alert{\bf Speedup by Moore's Law}}\medskip\\
\textbf{1986:} & 3 days & \textbf{1996:} & 135 mins\\
\textbf{1988:} & 1.5 days & \textbf{1998:} & 67 mins\\
\textbf{1990:} & 18 hs & \textbf{2000:} & 33 mins\\
\textbf{1992:} & 9 hs & \textbf{2002:} & 16 mins\\
\textbf{1994:} & 4.5 hs & \multicolumn{2}{c}{???}\\
\\
\end{tabular}
\small Every two years, computers got twice as powerful.
\end{bubble}
\end{textblock}}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{Seq \;vs\; Par}
\begin{center}
\begin{tabular}[t]{@{}l@{}l@{}}
\includegraphics[scale=0.14]{../pics/mand4.png} & \hspace{4mm}
\raisebox{0mm}{\includegraphics[scale=0.14]{../pics/mand3.png}}\\
\hspace{6mm}\includegraphics[scale=0.5]{../pics/cpu2.png} &
\hspace{11mm}\includegraphics[scale=0.5]{../pics/cpu1.png}
\end{tabular}
\end{center}
\only<2>{
\begin{textblock}{5}(12,2)
\begin{bubble}[2.1cm]
\footnotesize{}in Java or C++\\
\includegraphics[scale=0.50]{../pics/skeleton.jpg}\\
\end{bubble}
\end{textblock}}
\only<3>{
\begin{textblock}{14.2}(1,13.5)
In FP: Once a variable is created, it is assigned a value and then
never changed again $\Rightarrow$ no synchronisation needed\smallskip\\
%%\small\textcolor{gray}{(Andrew's second favourite feature of C++)}
\end{textblock}}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{Types}
\begin{itemize}
\item Base types\smallskip
\begin{tabular}{@{}l@{}}
\textcolor{codegreen}{\texttt{Int}},
\textcolor{codegreen}{\texttt{Long}},
\textcolor{codegreen}{\texttt{BigInt}},
\textcolor{codegreen}{\texttt{Float}},
\textcolor{codegreen}{\texttt{Double}}\\
\textcolor{codegreen}{\texttt{String}},
\textcolor{codegreen}{\texttt{Char}}\\
\textcolor{codegreen}{\texttt{Boolean}}
\end{tabular}
\item Compound types \smallskip
\begin{tabular}{@{}ll@{}}
\textcolor{codegreen}{\texttt{List[Int]}} & lists of Int's \\
\textcolor{codegreen}{\texttt{Set[Double]}} & sets of Double's \\
\textcolor{codegreen}{\texttt{(Int, String)}} & Int-String pair\\
\textcolor{codegreen}{\texttt{List[(BigInt, String)]}} &
lists of BigInt-String\\
& pairs\\
\textcolor{codegreen}{\texttt{List[List[Int]]}} & list of lists of Int's\\ \textcolor{codegreen}{\texttt{Option[Int]}} & options of Int's \\
\end{tabular}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{frame}[c]
%\frametitle{An Http Request}
%\begin{textblock}{1}(2,5)
%\begin{tabular}{c}
%\includegraphics[scale=0.15]{../pics/servers.png}\\[-2mm]
%\small Server
%\end{tabular}
%\end{textblock}
%\begin{textblock}{1}(5.6,4)
% \begin{tikzpicture}[scale=1.1]
% \draw[white] (0,1) node (X) {};
% \draw[white] (2,1) node (Y) {};
% \draw[white] (0,0) node (X1) {};
% \draw[white] (2,0) node (Y1) {};
% \draw[white] (0,-1) node (X2) {};
% \draw[white] (2,-1) node (Y2) {};
% \draw[red, <-, line width = 2mm] (X) -- (Y);
% \node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {};
% \draw[red, ->, line width = 2mm] (X1) -- (Y1);
% \node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {};
% \draw[red, <-, line width = 2mm] (X2) -- (Y2);
% \node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {};
% \end{tikzpicture}
%\end{textblock}
%\begin{textblock}{1}(9,5.5)
%\begin{tabular}{c}
%\includegraphics[scale=0.15]{../pics/laptop.png}\\[-2mm]
%\small Browser
%\end{tabular}
%\end{textblock}
%\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{frame}[c]
%
%{\lstset{language=Java}\fontsize{7}{8}\selectfont
%\texttt{\lstinputlisting{URLReader.java}}}
%
%\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{Coursework Dates}
Similar to C++:\bigskip
\begin{itemize}
\item Preliminary Parts: Wednesdays 4pm
\begin{itemize}
\item Preliminary Part 6: 3\% (13 November)
\item Preliminary Part 7: 4\% (20 November)
\item Preliminary Part 8: 4\% (27 November)
\item Preliminary Part 9: 4\% (5 December)
\end{itemize}\medskip
\item Core Part: 35\% (15 January 2020)\bigskip
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{Coursework}
\begin{itemize}
\item Sorry, I might have been a bit wordy:\\
Part 6 of CW description is 7 pages, but
I only needed \mbox{< 100} loc for \emph{all} Part 6.\bigskip
\item there is feedback when pushing code to github\medskip
\item there are \texttt{jar}-files you can use to test
my reference implementation\bigskip
\item we want you to learn FP!\smallskip\\ \alert{\bf no vars}, no mutable
data-structures\\ \quad{}e.g.~no \texttt{Arrays}, no \texttt{ListBuffer}
\end{itemize}
\LEFTarrow{1}{11}{11.8}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c, fragile]
\frametitle{The Joy of Immutability}
\begin{itemize}
\item If you need to manipulate some data in a list say, then you make
a new list with the updated values, rather than revise the original
list. Easy!\medskip
{\small
\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
val old_list = List(1, 2, 3, 5)
val new_list = 0 :: old_list
// -> List(0, 1, 2, 3, 4, 5)
\end{lstlisting}}
\item You do not have to be defensive about who can access the data.
\item You can look at your code in isolation.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\frametitle{Email: Hate 'val'}
\mbox{}\\[-23mm]\mbox{}
\begin{center}
\begin{bubble}[10.5cm]
Subject: \textbf{Hate '\textbf{\texttt{val}}'}\hfill 01:00 AM\medskip\\
Hello Mr Urban,\medskip\\
I just wanted to ask, how are we suppose to work
with the completely useless \textbf{\texttt{val}}, that can’t be changed ever? Why is
this rule active at all? I’ve spent 4 hours not thinking on the
coursework, but how to bypass this annoying rule. What’s the whole
point of all these coursework, when we can’t use everything Scala
gives us?!?\medskip\\
Regards.\\
\mbox{}\hspace{5mm}\textcolor{black!50}{<<deleted>>}\\
\end{bubble}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\mbox{}\\[-25mm]\mbox{}
\begin{center}
\begin{bubble}[10.5cm]
Subject: \textbf{Re: Hate '\textbf{\texttt{val}}'}\hfill 01:02 AM\bigskip\bigskip\\
\textcolor{black!70}{
\textit{\large<<my usual rant about fp\ldots\\ concurrency bla bla\ldots{} better programs
yada>>}}\bigskip\bigskip\bigskip
PS: What are you trying to do where you desperately want to use \texttt{var}?
\end{bubble}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]
\begin{textblock}{6}(0.5,0.5)
\begin{bubble}[11.5cm]
\small
Subject: \textbf{Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:04 AM\medskip\\
\textbf{Right now my is\_legal function works fine:}
\footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
def is_legal(dim: Int, path: Path)(x: Pos): Boolean = {
var boolReturn = false
if(x._1 > dim || x._2 > dim || x._1 < 0 || x._2 < 0) {
else { var breakLoop = false
if(path == Nil) { boolReturn = true }
else { for(i <- 0 until path.length) {
if(breakLoop == false) {
if(path(i) == x) {
boolReturn = true
breakLoop = true
}
else { boolReturn = false }
} else breakLoop
}
}
boolReturn
}
\end{lstlisting}
\end{bubble}
\end{textblock}
\begin{textblock}{6}(8.2,11.8)
\begin{bubble}[5.5cm]\footnotesize\bf
\ldots{}but I can’t make it work with boolReturn being val. What approach would
you recommend in this case, and is using var in this case justified?
\end{bubble}
\end{textblock}
\only<2>{
\begin{textblock}{6}(0.3,11.8)
\begin{bubble}[3.1cm]
\textbf{Me:}
\raisebox{-12mm}{\includegraphics[scale=0.08]{../pics/throwup.jpg}}
\end{bubble}
\end{textblock}}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t,fragile]
\mbox{}\\[-25mm]\mbox{}
\begin{textblock}{6}(0.5,2)
\begin{bubble}[11.5cm]
Subject: \textbf{Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:06 AM\bigskip\\
\small
OK. So you want to make sure that the \texttt{x}-position is not outside the
board....and furthermore you want to make sure that the \texttt{x}-position
is not yet in the path list. How about something like\bigskip
\footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
def is_legal(dim: Int, path: Path)(x: Pos): Boolean =
...<<some board conditions>>... && !path.contains(x)
\end{lstlisting}\bigskip
\small Does not even contain a \texttt{val}.
\end{bubble}
\end{textblock}
\begin{textblock}{6}(7,12)
\footnotesize\textcolor{black!50}{(This is all on one line)}
\end{textblock}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t,fragile]
\mbox{}\\[-15mm]\mbox{}
\begin{textblock}{6}(1,3)
\begin{bubble}[10.5cm]
Subject: \textbf{Re: Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 11:02 AM\bigskip\bigskip\\
THANK YOU! You made me change my coding perspective. Because of you,
I figured out the next one\ldots
\end{bubble}
\end{textblock}
\only<2>{
\begin{textblock}{6}(0.3,11.8)
\begin{bubble}[3.1cm]
\textbf{Me:}
\raisebox{-12mm}{\includegraphics[scale=0.15]{../pics/happy.jpg}}
\end{bubble}
\end{textblock}}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{Conclusion for Today}
\begin{itemize}
\item Scala is still under development, 2.13.1 came out in Sept.\\
(the compiler is terribly slow)\medskip
\item {\bf\url{http://www.scala-lang.org/}}\bigskip
\item it is a rather \textbf{\alert{deep}} language\ldots i.e.~gives
you a lot of rope to shoot yourself\bigskip
\item learning functional programming is not easy\ldots{}when you have
spent all of your career thinking in an imperative way, it is hard to
change\bigskip\medskip
\item hope you have fun with Scala and the assignments
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c]
\frametitle{\begin{tabular}{c}\\[0cm]\alert{Questions?}\end{tabular}}
\begin{center}
\begin{tabular}[t]{@{}l@{}l@{}}
\includegraphics[scale=0.1]{../pics/mand4.png} & \hspace{4mm}
\raisebox{0mm}{\includegraphics[scale=0.1]{../pics/mand3.png}}
\end{tabular}
\end{center}
\begin{center}
My Office Hours: Thursdays 12 -- 14\\
And specifically for Scala: Tuesdays 10:45 -- 11:45
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[t]
\begin{center}
\includegraphics[scale=0.4]{../pics/blow.png}
\end{center}
\begin{textblock}{14}(2,12.4)
\Large\bf{}Mind-Blowing\\ Programming Languages: C/C++
\end{textblock}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
“Functional programming is often regarded as the best-kept secret of
scientific modelers, mathematicians, artificial intelligence
researchers, financial institutions, graphic designers, CPU designers,
compiler programmers, and telecommunications engineers.”
The Wikipedia F# page