handouts/pep-ho.tex
changeset 170 37b1bfcdba79
parent 152 114a89518aea
child 178 fdf77ee57cdc
equal deleted inserted replaced
169:b37052895281 170:37b1bfcdba79
     4 \usepackage{marvosym}
     4 \usepackage{marvosym}
     5 
     5 
     6 %cheat sheet
     6 %cheat sheet
     7 %http://worldline.github.io/scala-cheatsheet/
     7 %http://worldline.github.io/scala-cheatsheet/
     8 
     8 
       
     9 % case class, apply, unappy
       
    10 % see https://medium.com/@thejasbabu/scala-pattern-matching-9c9e73ba9a8a
       
    11 
     9 \begin{document}
    12 \begin{document}
    10 
    13 
    11 \section*{A Crash-Course in Scala}
    14 \section*{A Crash-Course in Scala}
       
    15 
       
    16 
       
    17 Scala is a programming language that combines functional and
       
    18 object-oriented programming-styles. It has received quite a bit of
       
    19 attention in the last five or so years. One reason for this attention
       
    20 is that, like the Java programming language, Scala compiles to the
       
    21 Java Virtual Machine (JVM) and therefore Scala programs can run under
       
    22 MacOSX, Linux and Windows.\footnote{There are also experimental
       
    23   backends for Android and JavaScript; and also work is under way to
       
    24   have a native compiler, see
       
    25   \url{https://github.com/scala-native/scala-native}.} Unlike Java,
       
    26 however, Scala often allows programmers to write very concise and
       
    27 elegant code.  Some therefore say: ``Scala is the better
       
    28 Java''.\footnote{\url{https://www.slideshare.net/maximnovak/joy-of-scala}}
       
    29 Also a number of companies (the Guardian, Twitter, Coursera,
       
    30 FourSquare, LinkedIn to name a few) either use Scala exclusively in
       
    31 production code, or at least to some substantial degree. Scala seems
       
    32 also to be useful in job-interviews (in Data Science) according to
       
    33 this anecdotal report
       
    34 
       
    35 \begin{quote}\small
       
    36 \url{https://techcrunch.com/2016/06/14/scala-is-the-new-golden-child/}
       
    37 \end{quote}
       
    38 
       
    39 \noindent
       
    40 The official Scala compiler can be downloaded from
       
    41 
       
    42 \begin{quote}
       
    43 \url{http://www.scala-lang.org}
       
    44 \end{quote}
       
    45 
       
    46 \noindent
       
    47 A ready-made bundle with the Eclipse IDE is at
       
    48 
       
    49 \begin{quote}
       
    50 \url{http://scala-ide.org/download/sdk.html}
       
    51 \end{quote}
       
    52 
       
    53 \noindent
       
    54 When developing Scala programs, I personally prefer to use Emacs
       
    55 or Sublime as my environment, since they provide an easy access
       
    56 to the Scala REPL (see below).  But it is also possible to work
       
    57 completely on the command line and also with heavy-duty IDEs
       
    58 like Eclipse of IntelliJ. There is even an online editor and
       
    59 environment for developing Scala programs called ScalaFiddle
       
    60 
       
    61 \begin{quote}
       
    62 \url{https://scalafiddle.io}
       
    63 \end{quote}
       
    64   
       
    65 
       
    66 
    12 
    67 
    13 \subsection*{The Very Basics}
    68 \subsection*{The Very Basics}
    14 
    69 
    15 One advantage of Scala over Java is that it includes an interpreter (a
    70 One advantage of Scala over Java is that it includes an interpreter (a
    16 REPL, or
    71 REPL, or
    17 \underline{R}ead-\underline{E}val-\underline{P}rint-\underline{L}oop)
    72 \underline{R}ead-\underline{E}val-\underline{P}rint-\underline{L}oop)
    18 with which you can run and test small code-snippets without the need
    73 with which you can run and test small code-snippets without the need
    19 of a compiler. This helps a lot with interactively developing
    74 of a compiler. This helps a lot with interactively developing
       
    75 programs. This is really the preferred way of writing small Scala
    20 programs. Once you installed Scala, you can start the interpreter by
    76 programs. Once you installed Scala, you can start the interpreter by
    21 typing on the command line:
    77 typing on the command line:
    22 
    78 
    23 \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
    79 \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small]
    24 $ scala
    80 $ scala