handouts/scala-ho.tex
changeset 405 30dd644ba71a
parent 402 55f097ab96c9
child 430 e0492fe3d10b
--- a/handouts/scala-ho.tex	Tue Jun 14 11:41:48 2016 +0100
+++ b/handouts/scala-ho.tex	Thu Jul 14 13:10:01 2016 +0100
@@ -11,19 +11,28 @@
 \section*{A Crash-Course on Scala}
 
 Scala is a programming language that combines functional and
-object-oriented programming-styles. It has received in the
-last five years or so quite a bit of attention. One reason for
+object-oriented programming-styles. It has received quite a
+bit of attention in the last five years or so. 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.} Unlike Java, however, Scala often
+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 much better Java. A number of
+Some therefore say: Scala is the much better Java. 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. If
-you want to try out Scala yourself, the Scala compiler can be
+production code, or at least to some substantial degree. It
+also seems to be useful in job-interviews (in Data Science)
+according to this annectotical report
+
+\begin{quote}
+\url{https://techcrunch.com/2016/06/14/scala-is-the-new-golden-child/}
+\end{quote}
+
+\noindent
+If you want to try out Scala yourself, the official Scala compiler can be
 downloaded from
 
 \begin{quote}
@@ -40,11 +49,11 @@
 would not look pretty. Since the Scala compiler is free, you
 can download the code-snippets and run every example I give.
 But if you prefer, you can also easily translate them into any
-other functional language, for example Haskell, Standard ML,
-F$^\#$, Ocaml and so on.
+other functional language, for example Haskell, Swift,
+Standard ML, F$^\#$, Ocaml and so on.
 
 Developing programs in Scala can be done with the Eclipse IDE
-and also with IntelliJ IDE, but for the small programs I will
+and also with the IntelliJ IDE, but for the small programs I will
 develop the good old Emacs-editor is adequate for me and I
 will run the programs on the command line. One advantage of
 Scala over Java is that it includes an interpreter (a REPL, or
@@ -62,9 +71,10 @@
 scala>
 \end{lstlisting}
 
-\noindent The precise response may vary due to the platform
-where you installed Scala. At the Scala prompt you can type
-things like \code{2 + 3} \keys{Ret} and the output will be
+\noindent Of course the precise response may vary due to the
+version and platform where you installed Scala. At the Scala
+prompt you can type things like \code{2 + 3} \keys{Ret} and
+the output will be
 
 \begin{lstlisting}[numbers=none]
 scala> 2 + 3
@@ -197,10 +207,10 @@
 \end{lstlisting}
 
 \noindent As you can see, in order to make such assignments,
-no constructor is required in the class (as in Java). However,
-if there is the need for some non-standard initialisation, you
-can of course define such a constructor in Scala too. But we
-omit such ``tricks'' here. 
+no \code{new} or constructor is required in the class (as in
+Java). However, if there is the need for some non-standard
+initialisation, you can of course define such a constructor in
+Scala too. But we omit such ``tricks'' here. 
 
 Note that Scala in its response says the variable \code{r} is
 of type \code{ALT}, not \code{Rexp}. This might be a bit
@@ -208,10 +218,11 @@
 tries to find the most general type that is needed for a
 variable or expression, but does not ``over-generalise''. In
 our definition the type \code{Rexp} is more general than
-\code{Rexp}, since it is the abstract class. But in this case
-there is no need to give \code{r} the more general type of
-\code{Rexp}. This is different if you want
-to form a list of regular expressions, for example
+\code{ALT}, since it is the abstract class for all regular
+expressions. But in this particular case there is no need to
+give \code{r} the more general type of \code{Rexp}. This is
+different if you want to form a list of regular expressions,
+for example
 
 \begin{lstlisting}[numbers=none]
 scala> val ls = List(ALT(CHAR('a'), CHAR('b')), ZERO)
@@ -360,7 +371,7 @@
 cases above did not match. Cases are always tried out from top
 to bottom.
  
-\subsection*{Loops, or the Absence thereof}
+\subsection*{Loops, or better the Absence thereof}
 
 Coming from Java or C, you might be surprised that Scala does
 not really have loops. It has instead, what is in functional
@@ -933,6 +944,7 @@
 \item \url{http://www.scala-lang.org/docu/files/ScalaTutorial.pdf}
 \item \url{https://www.youtube.com/user/ShadowofCatron}
 \item \url{http://docs.scala-lang.org/tutorials}
+\item \url{https://www.scala-exercises.org}
 \end{itemize}
 
 \noindent There is also a course at Coursera on Functional