slides/slides01.tex
changeset 140 ecec79b9ab25
parent 137 53c769a78a1e
child 141 822adb464c90
equal deleted inserted replaced
139:3350cc06804b 140:ecec79b9ab25
    53 
    53 
    54 \begin{textblock}{6}(3,4)
    54 \begin{textblock}{6}(3,4)
    55 \begin{tabular}{l}
    55 \begin{tabular}{l}
    56 \mbox{}\hspace{-1mm}\includegraphics[scale=0.36]{../pics/twitter.png}\\[-1mm]
    56 \mbox{}\hspace{-1mm}\includegraphics[scale=0.36]{../pics/twitter.png}\\[-1mm]
    57 \includegraphics[scale=0.30]{../pics/linked.png}\\
    57 \includegraphics[scale=0.30]{../pics/linked.png}\\
    58 \includegraphics[scale=0.30]{../pics/guardian.jpg}\\[-3mm]
    58 %\includegraphics[scale=0.30]{../pics/guardian.jpg}\\[-3mm]
    59 \mbox{}\hspace{-2mm}\includegraphics[scale=0.38]{../pics/morgan.png}\\[-3mm]
    59 \mbox{}\hspace{-2mm}\includegraphics[scale=0.38]{../pics/morgan.png}\\[-3mm]
    60 \includegraphics[scale=0.30]{../pics/suisse.png}\\
    60 \includegraphics[scale=0.30]{../pics/suisse.png}\\
    61 {\large\bf ...}
    61 {\large\bf ...}
    62 \end{tabular}
    62 \end{tabular}
    63 \end{textblock}
    63 \end{textblock}
    91 \item often one can write very concise and elegant code
    91 \item often one can write very concise and elegant code
    92 \end{itemize}\bigskip\medskip  
    92 \end{itemize}\bigskip\medskip  
    93 
    93 
    94 \small
    94 \small
    95 alternatives:\\
    95 alternatives:\\
    96 Elm, Haskell, Ocaml, F\sharp, Erlang, ML, Lisp (Racket), \ldots
    96 Elm, Haskell, Ocaml, F$\sharp$, Erlang, ML, Lisp (Racket), \ldots
    97 
    97 
    98 \end{frame}
    98 \end{frame}
    99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
    99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   100 
   100 
   101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   111 \texttt{\lstinputlisting{Point.scala}}}
   111 \texttt{\lstinputlisting{Point.scala}}}
   112 
   112 
   113 \begin{textblock}{6}(13,3)
   113 \begin{textblock}{6}(13,3)
   114 \textbf{\large Java}
   114 \textbf{\large Java}
   115 \end{textblock}
   115 \end{textblock}
   116 
       
   117 
       
   118 
   116 
   119 \begin{textblock}{6}(13,13.4)
   117 \begin{textblock}{6}(13,13.4)
   120 \textbf{\large Scala}
   118 \textbf{\large Scala}
   121 \end{textblock}  
   119 \end{textblock}  
   122 
   120 
   146 
   144 
   147 
   145 
   148   %
   146   %
   149   \mbox{}\\[3.5cm]
   147   \mbox{}\\[3.5cm]
   150   \small
   148   \small
   151 Scala, Elm, Haskell, Ocaml, F\sharp, Erlang, ML, Lisp (Racket), \ldots 
   149 Scala, Elm, Haskell, Ocaml, F$\sharp$, Erlang, ML, Lisp (Racket), \ldots 
   152 
   150 
   153 \only<3>{
   151 \only<3>{
   154 \begin{textblock}{6}(2,6.2)
   152 \begin{textblock}{6}(2,6.2)
   155 \begin{bubble}[10cm]
   153 \begin{bubble}[10cm]
   156 \normalsize``If you want to see which features will be in mainstream programming
   154 \normalsize``If you want to see which features will be in mainstream programming
   287       \includegraphics[scale=0.50]{../pics/skeleton.jpg}\\
   285       \includegraphics[scale=0.50]{../pics/skeleton.jpg}\\
   288     \end{bubble}  
   286     \end{bubble}  
   289   \end{textblock}}
   287   \end{textblock}}
   290 
   288 
   291 \only<3>{
   289 \only<3>{
   292   \begin{textblock}{5}(1,8)
   290   \begin{textblock}{14.2}(1,12.3)
   293     \begin{bubble}[2.1cm]
   291     In FP: Once a variable is created, it is assigned a value and then
   294       \footnotesize{}in Java or C++\\
   292     never changed again $\Rightarrow$ no synchronisation\smallskip\\
   295     \end{bubble}  
   293     \small\textcolor{gray}{(Andrew's second favourite feature of C++)}
   296   \end{textblock}}
   294   \end{textblock}}
   297 
   295 
   298 \end{frame}
   296 \end{frame}
   299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
   300 
   298 
   378 \begin{frame}[c]
   376 \begin{frame}[c]
   379 
   377 
   380 {\lstset{language=Java}\fontsize{7}{8}\selectfont
   378 {\lstset{language=Java}\fontsize{7}{8}\selectfont
   381 \texttt{\lstinputlisting{URLReader.java}}}
   379 \texttt{\lstinputlisting{URLReader.java}}}
   382 
   380 
       
   381 \end{frame}
       
   382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
       
   383 
       
   384 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   385 \begin{frame}[c]
       
   386 \frametitle{Coursework}
       
   387 
       
   388 \begin{itemize}
       
   389 \item sorry, I might have been a bit wordy:\\
       
   390   CW description is 7 pages, but
       
   391   I only needed \mbox{< 100} loc for all the CW\bigskip
       
   392 
       
   393 \item there is email feedback when pushing code to github\bigskip
       
   394 
       
   395 \item we want you to learn FP: \alert{no vars}, no mutable
       
   396   datastructures, e.g.~\texttt{ListBuffer}
       
   397 \end{itemize}
       
   398 \end{frame}
       
   399 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   400 
       
   401 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   402 
       
   403 \begin{frame}[c, fragile]
       
   404 \frametitle{The Joy of Immutability}
       
   405 
       
   406 \begin{itemize}
       
   407 \item If you need to manipulate some data in a list say, then you make
       
   408   a new list with the updated values, rather than revise the original
       
   409   list. Easy!\medskip
       
   410 
       
   411   {\small
       
   412   \begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
       
   413     val old_list = List(1, 2, 3, 5)
       
   414     val new_list = 0 :: old_list
       
   415   \end{lstlisting}}  
       
   416   
       
   417 \item You do not have to be defensive about who can access the data
       
   418   (concurrency, lazyness).
       
   419 \end{itemize}  
       
   420 \end{frame}
       
   421 
       
   422 
       
   423 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   424 
       
   425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   426 \begin{frame}[t]
       
   427 \frametitle{Email: Hate 'val'}
       
   428 
       
   429 \mbox{}\\[-25mm]\mbox{}
       
   430 
       
   431 \begin{center}
       
   432   \begin{bubble}[10.5cm]
       
   433   Subject: \textbf{Hate '\textbf{\texttt{val}}'}\hfill 01:00 AM\medskip\\
       
   434 
       
   435   Hello Mr Urban,\medskip\\
       
   436 
       
   437   I just wanted to ask, how are we suppose to work
       
   438   with the completely useless \textbf{\texttt{val}}, that can’t be changed ever? Why is
       
   439   this rule active at all? I’ve spent 4 hours not thinking on the
       
   440   coursework, but how to bypass this annoying rule. What’s the whole
       
   441   point of all these coursework, when we can’t use everything Scala
       
   442   gives us?!?\medskip\\
       
   443 
       
   444   Regards.\\
       
   445   \mbox{}\hspace{5mm}\textcolor{black!50}{<<deleted>>}\\
       
   446   \end{bubble}
       
   447 \end{center}
       
   448 
       
   449 \end{frame}
       
   450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   451 
       
   452 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   453 \begin{frame}[c]
       
   454 
       
   455 \mbox{}\\[-25mm]\mbox{}
       
   456 
       
   457 \begin{center}
       
   458   \begin{bubble}[10.5cm]
       
   459   Subject: \textbf{Re: Hate '\textbf{\texttt{val}}'}\hfill 01:02 AM\bigskip\bigskip\\
       
   460 
       
   461   \textcolor{black!70}{
       
   462     \textit{\large<<my usual rant about fp\ldots\\ concurrency bla bla\ldots{} better programs
       
   463     yada>>}}\bigskip\bigskip\bigskip
       
   464   
       
   465   PS: What are you trying to do where you desperately want to use \texttt{var}?
       
   466   \end{bubble}
       
   467 \end{center}
       
   468 
       
   469 \end{frame}
       
   470 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   471 
       
   472 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   473 \begin{frame}[c,fragile]
       
   474 
       
   475 \begin{textblock}{6}(0.5,0.5)
       
   476 \begin{bubble}[11.5cm]
       
   477   \small  
       
   478   Subject: \textbf{Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:04 AM\medskip\\
       
   479 
       
   480   \textbf{Right now my is\_legal function works fine:}
       
   481   
       
   482 \footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
       
   483  def is_legal(dim: Int, path: Path)(x: Pos): Boolean = {
       
   484    var boolReturn = false
       
   485    if(x._1 > dim || x._2 > dim || x._1 < 0 || x._2 < 0) {
       
   486    else { var breakLoop = false
       
   487           if(path == Nil) { boolReturn = true }
       
   488           else { for(i <- 0 until path.length) {
       
   489                     if(breakLoop == false) {
       
   490                       if(path(i) == x) {
       
   491                         boolReturn = true
       
   492                         breakLoop = true
       
   493                       }
       
   494                       else { boolReturn = false }
       
   495                     } else breakLoop
       
   496             }
       
   497           }
       
   498           boolReturn
       
   499    }
       
   500 \end{lstlisting}
       
   501 \end{bubble}
       
   502 \end{textblock}
       
   503 
       
   504 \begin{textblock}{6}(8.2,11.8)
       
   505 \begin{bubble}[5.5cm]\footnotesize\bf
       
   506 \ldots{}but I can’t make it work with boolReturn being val. What approach would
       
   507 you recommend in this case, and is using var in this case justified?
       
   508 \end{bubble}
       
   509 \end{textblock}
       
   510 
   383 \only<2>{
   511 \only<2>{
   384 \begin{textblock}{5}(12,2)
   512 \begin{textblock}{6}(0.3,11.8)
   385 \includegraphics[scale=0.50]{../pics/skeleton.jpg}\\
   513   \begin{bubble}[3.1cm]
       
   514     \textbf{Me:}
       
   515     \raisebox{-12mm}{\includegraphics[scale=0.08]{../pics/throwup.jpg}}
       
   516   \end{bubble}
   386 \end{textblock}}
   517 \end{textblock}}
   387 \end{frame}
   518 
   388 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   519 \end{frame}
       
   520 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
       
   521 
       
   522 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   523 \begin{frame}[t,fragile]
       
   524 
       
   525 \mbox{}\\[-25mm]\mbox{}
       
   526 
       
   527 \begin{textblock}{6}(0.5,2)
       
   528   \begin{bubble}[11.5cm]
       
   529   Subject: \textbf{Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 01:06 AM\bigskip\\
       
   530   \small
       
   531   
       
   532   OK. So you want to make sure that the \texttt{x}-position is not outside the
       
   533   board....and furthermore you want to make sure that the \texttt{x}-position
       
   534   is not yet in the path list. How about something like\bigskip
       
   535 
       
   536 \footnotesize\begin{lstlisting}[language=Scala, numbers=none, xleftmargin=-1mm]
       
   537  def is_legal(dim: Int, path: Path)(x: Pos): Boolean = 
       
   538    ...<<some board conditions>>... && !path.contains(x)
       
   539 \end{lstlisting}\bigskip
       
   540   
       
   541   \small Does not even contain a \texttt{val}.
       
   542   \end{bubble}
       
   543 \end{textblock}
       
   544 
       
   545 \begin{textblock}{6}(7,12)
       
   546 \footnotesize\textcolor{black!50}{(This is all on one line)}
       
   547 \end{textblock}
       
   548 
       
   549 \end{frame}
       
   550 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     
       
   551 
       
   552 
       
   553 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       
   554 \begin{frame}[t,fragile]
       
   555 
       
   556 \mbox{}\\[-15mm]\mbox{}
       
   557 
       
   558 \begin{textblock}{6}(1,3)
       
   559   \begin{bubble}[10.5cm]
       
   560     Subject: \textbf{Re: Re: Re: Re: Hate '\textbf{\texttt{val}}'}\hfill 11:02 AM\bigskip\bigskip\\
       
   561     
       
   562     THANK YOU! You made me change my coding perspective. Because of you,
       
   563     I figured out the next one\ldots
       
   564   \end{bubble}
       
   565 \end{textblock}
       
   566 
       
   567 \only<2>{
       
   568 \begin{textblock}{6}(0.3,11.8)
       
   569   \begin{bubble}[3.1cm]
       
   570     \textbf{Me:}
       
   571     \raisebox{-12mm}{\includegraphics[scale=0.15]{../pics/happy.jpg}}
       
   572   \end{bubble}
       
   573 \end{textblock}}
       
   574 
       
   575 \end{frame}
       
   576 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
       
   577 
   389 
   578 
   390 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   391 \begin{frame}[c]
   580 \begin{frame}[c]
   392 \frametitle{Conclusion}
   581 \frametitle{Conclusion}
   393 
   582 
   394 \begin{itemize}
   583 \begin{itemize}
   395 \item Scala is still under heavy development\\ (the compiler is terribly slow)\medskip
   584 \item Scala is still under heavy development\\ (the compiler is terribly slow)\medskip
   396 \item {\bf\url{http://www.scala-lang.org/}}\bigskip
   585 \item {\bf\url{http://www.scala-lang.org/}}\bigskip
   397 \item it is a rather \textbf{\alert{deep}} language\ldots i.e.~gives you a lot of
   586   
   398   rope to shoot yourself\bigskip\bigskip 
   587 \item it is a rather \textbf{\alert{deep}} language\ldots i.e.~gives
   399 
   588   you a lot of rope to shoot yourself\bigskip
       
   589 
       
   590 \item learning functional programming is not easy\ldots{}when you have
       
   591   spent all of your career thinking in a procedural way it is hard to
       
   592   change\bigskip\medskip
       
   593   
   400 \item hope you have fun with the coursework  
   594 \item hope you have fun with the coursework  
   401 \end{itemize}
   595 \end{itemize}
   402 \end{frame}
   596 \end{frame}
   403 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   404 
   598 
   405 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   599 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   406 \begin{frame}[c]
   600 \begin{frame}[c]
   407 \frametitle{\begin{tabular}{c}\\[3cm]\alert{Questions?}\end{tabular}}
   601 \frametitle{\begin{tabular}{c}\\[0cm]\alert{Questions?}\end{tabular}}
   408 
   602 
   409 \mbox{}
   603 \begin{center}
       
   604   \begin{tabular}[t]{@{}l@{}l@{}}
       
   605     \includegraphics[scale=0.1]{../pics/mand4.png} &
       
   606     \raisebox{1.2mm}{\includegraphics[scale=0.1]{../pics/mand3.png}}      
       
   607   \end{tabular}     
       
   608 \end{center}
       
   609 
       
   610 \begin{center}
       
   611 My Scala Office Hours: Thursdays 11 -- 13
       
   612 \end{center}
   410 \end{frame}
   613 \end{frame}
   411 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   614 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
   412 \end{document}
   615 \end{document}
   413 
   616 
   414 
   617 
   417 %%% Local Variables:  
   620 %%% Local Variables:  
   418 %%% mode: latex
   621 %%% mode: latex
   419 %%% TeX-master: t
   622 %%% TeX-master: t
   420 %%% End: 
   623 %%% End: 
   421 
   624 
       
   625 
       
   626 “Functional programming is often regarded as the best-kept secret of
       
   627 scientific modelers, mathematicians, artificial intelligence
       
   628 researchers, financial institutions, graphic designers, CPU designers,
       
   629 compiler programmers, and telecommunications engineers.”
       
   630 
       
   631 The Wikipedia F# page