For this course we will be using Scala. Scala is a mult-paradigm language that embraces both object-oriented and functional models of programming. Like Java, it runs on the JVM and can even use Java classes!
Linux is a great tool for developers and it is important that you know are familiar with it for future employment. I am recommending that you use Ubuntu for Windows 10 as your development environment but it is not required. However, it does make installing Scala and other development tools easier so stray at your own peril. Follow these instructions for enabling Windows Subsystem for Linux. Once completed, install Ubuntu Linux for Windows 10.
Since Scala runs on Java's JVM, we first need to install the Java JDK. The following command may take a long time.
sudo apt-get install openjdk-8-jdk
Next install Scala by downloading and running my custom install script.
sudo apt-get install curl wget http://jorr.cs.georgefox.edu/courses/csis430-algorithms/scala/sbt_install sh sbt_install
If you use a Mac, do not have Windows 10, or have strong reservations about using Ubuntu on Windows 10, here are some alternative instructions for setting up Scala.
First ensure that Git is installed.
sudo apt-get update sudo apt-get install git
Change to whatever directory where you want to keep your code. Let's create a link to your documents then make a fold in there:
ln -s /mnt/c/Users/YOUR USERNAME/Documents/ Documents cd Documents mkdir src cd src
Now download the random writer example.
git clone https://github.com/gfu-csis/csis430-markov.git
Now let's change to the project directory and download some example text
cd csis430-markov wget http://www.gutenberg.org/cache/epub/10/pg10.txt
You should now see the example project in your documents folder.
It should be visible via Ubuntu and the Windows file explorer as well.
Build and run the project with the program
sbt will need to download a lot of supporting files which may take awhile.
sbt "run 10 500 pg10.txt"
The output of the program will look something like this.
[info] Loading project definition from /mnt/c/Users/jorr/Documents/src/csis430-markov/project [info] Loading settings for project csis430-markov from build.sbt ... [info] Set current project to markov (in build file:/mnt/c/Users/jorr/Documents/src/csis430-markov/) [info] Compiling 1 Scala source to /mnt/c/Users/jorr/Documents/src/csis430-markov/target/scala-2.12/classes ... [info] Done compiling. [info] Packaging /mnt/c/Users/jorr/Documents/src/csis430-markov/target/scala-2.12/markov_2.12-1.0.jar ... [info] Done packaging. [info] Running Markov 10 500 pg10.txt hour was not yet come.8:21 Then said Jesus again unto them, Know ye Laban the son of Nahor? And theysaid, We know him.... [success] Total time: 5 s
The best part of Scala are its collections, which implement the core of the functional paradigm.
Iterable is perhaps the most useful
Trait in Scala and I have provide the link to its API, along with some other useful links.
This page was last modified on 2019-01-16 at 15:34:17.
George Fox University · 414 N Meridian St · Newberg, Oregon 97132 · 503-538-8383
Copyright © 2018–2019 George Fox University. All rights reserved.