diff -r f70d74fea67f -r 2a30c7dfe3ed handouts/pep-ho.tex --- a/handouts/pep-ho.tex Sun Sep 15 12:57:59 2024 +0100 +++ b/handouts/pep-ho.tex Mon Jul 21 16:38:07 2025 +0100 @@ -186,24 +186,24 @@ \noindent\alert For PEP, make sure you are using the version 3(!) of Scala. This is the version I am going to use in the lectures and in the coursework. This -can be any version of Scala 3.X where $X=\{3,4\}$. Also the minor +can be any version of Scala 3.X where $X=\{4,5\}$. Also the minor number does not matter. Note that this will be the second year I am using this newer version of Scala -- some hiccups can still happen. Apologies in advance!\bigskip -\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black] - I will be using the \textbf{\texttt{scala-cli}} REPL for Scala 3, rather - than the ``plain'' Scala REPL. This is a batteries included version of - Scala 3 and is easier to use and to install. In fact - \texttt{scala-cli} is designated to replace - the ``plain'' Scala REPL in future versions of Scala. - So why not using it now? - It can be downloaded from: - - \begin{center} - \url{https://scala-cli.virtuslab.org} - \end{center} -\end{tcolorbox}\medskip +%\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black] +% I will be using the \textbf{\texttt{scala-cli}} REPL for Scala 3, rather +% than the ``plain'' Scala REPL. This is a batteries included version of +% Scala 3 and is easier to use and to install. In fact +% \texttt{scala-cli} is designated to replace +% the ``plain'' Scala REPL in future versions of Scala. +% So why not using it now? +% It can be downloaded from:% +% +% \begin{center} +% \url{https://scala-cli.virtuslab.org} +% \end{center} +%\end{tcolorbox}\medskip \noindent @@ -251,7 +251,7 @@ I have also bound the keys \keys{Ctrl} \keys{Ret} to the action ``Run-Selected-Text-In-Active-Terminal'' in order to quickly evaluate small code snippets in the Scala REPL. I use Codium's internal - terminal to run \texttt{scala-cli} version 1.0.5 which + terminal to run \texttt{scala} version 1.0.5 which uses Scala 3.3.1.\label{vscode}} \end{boxedminipage} \end{figure} @@ -284,7 +284,7 @@ \noindent But you should be careful if you use them for your coursework: they are meant to play around, not really for serious work. Therefore make -sure \texttt{scala-cli} works on your own machine ASAP! +sure \texttt{scala} works on your own machine ASAP! As one might expect, Scala can be used with the heavy-duty IDEs Eclipse and IntelliJ. For example IntelliJ includes plugins for @@ -534,30 +534,30 @@ \subsection*{The Very Basics} -Let us get back to Scala and \texttt{scala-cli}: One advantage of +Let us get back to Scala: One advantage of Scala over Java is that it includes an interpreter (a REPL, or \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. It is my preferred way of writing small Scala programs. Once -you installed \texttt{scala-cli}, you can start the interpreter by typing on the +you installed \texttt{scala}, you can start the interpreter by typing on the command line: \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small] -$ scala-cli -Welcome to Scala 3.4.1 (21.0.2, Java OpenJDK 64-Bit Server VM). -Type in expressions for evaluation. Or try :help. +$ scala +Welcome to Scala 3.5.1 (21.0.4, Java OpenJDK 64-Bit Server VM). +Type in expressions for evaluation. Or try :help. scala> \end{lstlisting}%$ \noindent The precise response may vary depending on the version and -platform where you installed \texttt{scala-cli}. Make sure however that -\texttt{scala-cli} uses Scala version 3---you can find the version +platform where you installed \texttt{scala}. Make sure however that +\texttt{scala} uses version 3---you can find the version number in the welcome message. Also note that at the first time -\texttt{scala-cli} runs, it might download various components, for +\texttt{scala} runs, it might download various components, for example the Scala compiler, Scala runtimes etc. Once -\texttt{scala-cli} is up and running, you can type at the prompt +\texttt{scala} is up and running, you can type at the prompt expressions like \code{2 + 3}\;\keys{Ret} and the output will be \begin{lstlisting}[numbers=none,language={}] @@ -595,7 +595,7 @@ now, the latter kind of functions always has \code{Unit} as return type. It is just not printed by Scala. -You can try more examples with the \texttt{scala-cli} REPL, but feel free to +You can try more examples with the \texttt{scala} REPL, but feel free to first guess what the result is (not all answers by Scala are obvious): \begin{lstlisting}[numbers=none,language={}] @@ -654,11 +654,11 @@ %} \noindent save it in a file, say {\tt hello-world.scala}, and -then use \texttt{scala-cli} (which compiles the +then use \texttt{scala} (which compiles the scala file and runs it): \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small] -$ scala-cli hello-world.scala +$ scala hello-world.scala hello world \end{lstlisting} @@ -668,7 +668,7 @@ Runtime. This can be done as follows: \begin{lstlisting}[language={},numbers=none,basicstyle=\ttfamily\small] -$ scala-cli --power package --assembly hello-world.scala +$ scala --power package --assembly hello-world.scala $ java -jar Hello.jar hello world \end{lstlisting}