diff -r b37052895281 -r 37b1bfcdba79 handouts/pep-ho.tex --- a/handouts/pep-ho.tex Fri Jan 19 14:09:08 2018 +0000 +++ b/handouts/pep-ho.tex Fri Feb 23 22:26:42 2018 +0000 @@ -6,10 +6,65 @@ %cheat sheet %http://worldline.github.io/scala-cheatsheet/ +% case class, apply, unappy +% see https://medium.com/@thejasbabu/scala-pattern-matching-9c9e73ba9a8a + \begin{document} \section*{A Crash-Course in Scala} + +Scala is a programming language that combines functional and +object-oriented programming-styles. It has received quite a bit of +attention in the last five or so years. One reason for this attention +is that, like the Java programming language, Scala compiles to the +Java Virtual Machine (JVM) and therefore Scala programs can run under +MacOSX, Linux and Windows.\footnote{There are also experimental + backends for Android and JavaScript; and also work is under way to + have a native compiler, see + \url{https://github.com/scala-native/scala-native}.} Unlike Java, +however, Scala often allows programmers to write very concise and +elegant code. Some therefore say: ``Scala is the better +Java''.\footnote{\url{https://www.slideshare.net/maximnovak/joy-of-scala}} +Also a number of companies (the Guardian, Twitter, Coursera, +FourSquare, LinkedIn to name a few) either use Scala exclusively in +production code, or at least to some substantial degree. Scala seems +also to be useful in job-interviews (in Data Science) according to +this anecdotal report + +\begin{quote}\small +\url{https://techcrunch.com/2016/06/14/scala-is-the-new-golden-child/} +\end{quote} + +\noindent +The official Scala compiler can be downloaded from + +\begin{quote} +\url{http://www.scala-lang.org} +\end{quote} + +\noindent +A ready-made bundle with the Eclipse IDE is at + +\begin{quote} +\url{http://scala-ide.org/download/sdk.html} +\end{quote} + +\noindent +When developing Scala programs, I personally prefer to use Emacs +or Sublime as my environment, since they provide an easy access +to the Scala REPL (see below). But it is also possible to work +completely on the command line and also with heavy-duty IDEs +like Eclipse of IntelliJ. There is even an online editor and +environment for developing Scala programs called ScalaFiddle + +\begin{quote} +\url{https://scalafiddle.io} +\end{quote} + + + + \subsection*{The Very Basics} One advantage of Scala over Java is that it includes an interpreter (a @@ -17,6 +72,7 @@ \underline{R}ead-\underline{E}val-\underline{P}rint-\underline{L}oop) with which you can run and test small code-snippets without the need of a compiler. This helps a lot with interactively developing +programs. This is really the preferred way of writing small Scala programs. Once you installed Scala, you can start the interpreter by typing on the command line: