22
|
1 |
\documentclass[dvipsnames,14pt,t,xelatex]{beamer}
|
|
2 |
\usepackage{../slides}
|
32
|
3 |
\usepackage{../graphics}
|
22
|
4 |
\usepackage{../langs}
|
|
5 |
%\usepackage{../data}
|
|
6 |
|
|
7 |
\hfuzz=220pt
|
|
8 |
|
|
9 |
%\setmonofont[Scale=.88]{Consolas}
|
|
10 |
%\newfontfamily{\consolas}{Consolas}
|
|
11 |
|
|
12 |
\lstset{language=Scala,
|
|
13 |
style=mystyle,
|
|
14 |
numbersep=0pt,
|
|
15 |
numbers=none,
|
|
16 |
xleftmargin=0mm}
|
|
17 |
|
|
18 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}}
|
|
19 |
|
|
20 |
% beamer stuff
|
|
21 |
\renewcommand{\slidecaption}{PEP (Scala) 01, King's College London}
|
|
22 |
|
|
23 |
|
|
24 |
\begin{document}
|
|
25 |
|
|
26 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
27 |
\begin{frame}[t]
|
|
28 |
\frametitle{%
|
|
29 |
\begin{tabular}{@ {}c@ {}}
|
|
30 |
\\[5mm]
|
|
31 |
\huge PEP Scala (1)
|
|
32 |
\end{tabular}}
|
|
33 |
|
|
34 |
\normalsize
|
|
35 |
\begin{center}
|
|
36 |
\begin{tabular}{ll}
|
|
37 |
Email: & christian.urban at kcl.ac.uk\\
|
|
38 |
Office: & S1.27 (1st floor Strand Building)\\
|
|
39 |
Slides \& Code: & KEATS
|
|
40 |
\end{tabular}
|
|
41 |
\end{center}
|
|
42 |
|
|
43 |
|
|
44 |
\end{frame}
|
|
45 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
46 |
|
|
47 |
|
|
48 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
49 |
\begin{frame}[c]
|
|
50 |
\frametitle{Why Scala?}
|
|
51 |
|
23
|
52 |
\begin{textblock}{6}(3,4)
|
22
|
53 |
\begin{tabular}{l}
|
|
54 |
\mbox{}\hspace{-1mm}\includegraphics[scale=0.36]{../pics/twitter.png}\\[-1mm]
|
|
55 |
\includegraphics[scale=0.30]{../pics/linked.png}\\
|
|
56 |
\includegraphics[scale=0.30]{../pics/guardian.jpg}\\[-3mm]
|
|
57 |
\mbox{}\hspace{-2mm}\includegraphics[scale=0.38]{../pics/morgan.png}\\[-3mm]
|
|
58 |
\includegraphics[scale=0.30]{../pics/suisse.png}\\
|
23
|
59 |
{\large\bf ...}
|
|
60 |
\end{tabular}
|
|
61 |
\end{textblock}
|
|
62 |
|
|
63 |
\begin{textblock}{6}(9,4)
|
|
64 |
\begin{tabular}{l}
|
22
|
65 |
\includegraphics[scale=0.20]{../pics/edf.png}\\[-1mm]
|
|
66 |
\includegraphics[scale=0.08]{../pics/novell.png}\\[-1mm]
|
|
67 |
\includegraphics[scale=0.30]{../pics/foursquare.png}\\
|
|
68 |
\includegraphics[scale=0.30]{../pics/hsbc.png}\\
|
|
69 |
{\large\bf ...}
|
|
70 |
\end{tabular}
|
|
71 |
\end{textblock}
|
|
72 |
|
|
73 |
\end{frame}
|
|
74 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
75 |
|
23
|
76 |
|
|
77 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
78 |
\begin{frame}[c]
|
|
79 |
\frametitle{Why Scala?}
|
|
80 |
|
|
81 |
\begin{itemize}
|
33
|
82 |
\item compiles to the JVM\\ (also JavaScript, native X86 in the works)\medskip
|
32
|
83 |
\item integrates seamlessly with Java\medskip
|
33
|
84 |
\item combines \underline{\bf functional} and {\bf object-oriented} programming\bigskip
|
|
85 |
\item often one can write very concise and elegant code
|
|
86 |
\end{itemize}\bigskip\medskip
|
|
87 |
|
|
88 |
\small
|
|
89 |
alternatives: Elm, Haskell, Ocaml, ML, Lisp (Racket), \ldots
|
23
|
90 |
|
|
91 |
\end{frame}
|
22
|
92 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
23
|
93 |
|
|
94 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
95 |
\begin{frame}[c]
|
32
|
96 |
\frametitle{Java vs Scala}
|
|
97 |
|
|
98 |
{\lstset{language=java}\fontsize{12}{12}\selectfont
|
|
99 |
\texttt{\lstinputlisting{Point.java}}}
|
|
100 |
|
33
|
101 |
\rule{11cm}{0.3mm}\\[-2mm]
|
|
102 |
|
32
|
103 |
{\lstset{language=scala}\fontsize{12}{12}\selectfont
|
|
104 |
\texttt{\lstinputlisting{Point.scala}}}
|
|
105 |
|
|
106 |
\begin{textblock}{6}(13,3)
|
|
107 |
\textbf{\large Java}
|
33
|
108 |
\end{textblock}
|
|
109 |
|
32
|
110 |
|
33
|
111 |
|
|
112 |
\begin{textblock}{6}(13,13.4)
|
32
|
113 |
\textbf{\large Scala}
|
|
114 |
\end{textblock}
|
|
115 |
|
|
116 |
\end{frame}
|
|
117 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
118 |
|
33
|
119 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
120 |
\begin{frame}[c]
|
|
121 |
\frametitle{Scala Tools}
|
32
|
122 |
|
33
|
123 |
\begin{itemize}
|
|
124 |
\item there is a plugin for Eclipse (called Scala IDE)\medskip
|
|
125 |
\item there is also a plugin for IntelliJ\bigskip
|
|
126 |
\item I use the venerable Emacs ;o)
|
|
127 |
\end{itemize}
|
|
128 |
|
|
129 |
\end{frame}
|
|
130 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
32
|
131 |
|
|
132 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
133 |
\begin{frame}[c]
|
23
|
134 |
\frametitle{Types}
|
|
135 |
|
|
136 |
\begin{itemize}
|
33
|
137 |
\item Base types\smallskip
|
23
|
138 |
|
33
|
139 |
\begin{tabular}{@{}l@{}}
|
23
|
140 |
\textcolor{codegreen}{\texttt{Int}},
|
|
141 |
\textcolor{codegreen}{\texttt{Long}},
|
|
142 |
\textcolor{codegreen}{\texttt{BigInt}},
|
|
143 |
\textcolor{codegreen}{\texttt{Float}},
|
|
144 |
\textcolor{codegreen}{\texttt{Double}}\\
|
|
145 |
\textcolor{codegreen}{\texttt{String}},
|
25
|
146 |
\textcolor{codegreen}{\texttt{Char}}\\
|
|
147 |
\textcolor{codegreen}{\texttt{Boolean}}
|
23
|
148 |
\end{tabular}
|
|
149 |
|
33
|
150 |
\item Compound types \smallskip
|
23
|
151 |
|
33
|
152 |
\begin{tabular}{@{}ll@{}}
|
23
|
153 |
\textcolor{codegreen}{\texttt{List[Int]}} & lists of Int's \\
|
|
154 |
\textcolor{codegreen}{\texttt{Set[Double]}} & sets of Double's \\
|
|
155 |
\textcolor{codegreen}{\texttt{(Int, String)}} & Int-String pair\\
|
|
156 |
\textcolor{codegreen}{\texttt{List[(BigInt, String)]}} &
|
|
157 |
lists of BigInt-String\\
|
|
158 |
& pairs\\
|
26
|
159 |
\textcolor{codegreen}{\texttt{List[List[Int]]}} & list of lists of Int's\\
|
23
|
160 |
\end{tabular}
|
|
161 |
|
|
162 |
\end{itemize}
|
|
163 |
|
|
164 |
\end{frame}
|
|
165 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
166 |
|
32
|
167 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
168 |
\begin{frame}[c]
|
|
169 |
\frametitle{An Http Request}
|
|
170 |
|
|
171 |
\begin{textblock}{1}(2,5)
|
|
172 |
\begin{tabular}{c}
|
|
173 |
\includegraphics[scale=0.15]{../pics/servers.png}\\[-2mm]
|
|
174 |
\small Server
|
|
175 |
\end{tabular}
|
|
176 |
\end{textblock}
|
|
177 |
|
|
178 |
\begin{textblock}{1}(5.6,4)
|
|
179 |
\begin{tikzpicture}[scale=1.1]
|
|
180 |
\draw[white] (0,1) node (X) {};
|
|
181 |
\draw[white] (2,1) node (Y) {};
|
|
182 |
\draw[white] (0,0) node (X1) {};
|
|
183 |
\draw[white] (2,0) node (Y1) {};
|
|
184 |
\draw[white] (0,-1) node (X2) {};
|
|
185 |
\draw[white] (2,-1) node (Y2) {};
|
|
186 |
\draw[red, <-, line width = 2mm] (X) -- (Y);
|
|
187 |
\node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {};
|
|
188 |
\draw[red, ->, line width = 2mm] (X1) -- (Y1);
|
|
189 |
\node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {};
|
|
190 |
\draw[red, <-, line width = 2mm] (X2) -- (Y2);
|
|
191 |
\node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {};
|
|
192 |
\end{tikzpicture}
|
|
193 |
\end{textblock}
|
|
194 |
|
|
195 |
|
|
196 |
\begin{textblock}{1}(9,5.5)
|
|
197 |
\begin{tabular}{c}
|
|
198 |
\includegraphics[scale=0.15]{../pics/laptop.png}\\[-2mm]
|
|
199 |
\small Browser
|
|
200 |
\end{tabular}
|
|
201 |
\end{textblock}
|
|
202 |
\end{frame}
|
|
203 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
204 |
|
|
205 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
206 |
\begin{frame}[c]
|
|
207 |
|
|
208 |
{\lstset{language=Java}\fontsize{7}{8}\selectfont
|
|
209 |
\texttt{\lstinputlisting{URLReader.java}}}
|
|
210 |
|
|
211 |
\only<2>{
|
|
212 |
\begin{textblock}{5}(12,2)
|
|
213 |
\includegraphics[scale=0.50]{../pics/skeleton.jpg}\\
|
|
214 |
\end{textblock}}
|
|
215 |
\end{frame}
|
|
216 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
217 |
|
33
|
218 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
219 |
\begin{frame}[c]
|
|
220 |
\frametitle{Conclusion}
|
|
221 |
|
|
222 |
\begin{itemize}
|
|
223 |
\item Scala is still under heavy development\\ (the compiler is terribly slow)\medskip
|
|
224 |
\item {\bf\url{http://www.scala-lang.org/}}\bigskip
|
|
225 |
\item it is a rather \textbf{\alert{deep}} language\ldots i.e.~gives you a lot of
|
|
226 |
rope to shoot yourself\bigskip\bigskip
|
|
227 |
|
|
228 |
\item hope you have fun with the coursework
|
|
229 |
\end{itemize}
|
|
230 |
\end{frame}
|
|
231 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
232 |
|
|
233 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
234 |
\begin{frame}[c]
|
|
235 |
\frametitle{\begin{tabular}{c}\\[3cm]\alert{Questions?}\end{tabular}}
|
|
236 |
|
|
237 |
\mbox{}
|
|
238 |
\end{frame}
|
|
239 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
240 |
\end{document}
|
32
|
241 |
|
|
242 |
|
22
|
243 |
\end{document}
|
|
244 |
|
|
245 |
%%% Local Variables:
|
|
246 |
%%% mode: latex
|
|
247 |
%%% TeX-master: t
|
|
248 |
%%% End:
|
|
249 |
|