Setup

We will be using the Julia programming language for this course. It is a neat language that is easy for beginners to pick up and is commonly used for data science.

First, install the latest version of Julia for your operating system. You can get it from the official website or from your OS's package manager.

Once that is installed, we'll install some packages that we will be using throughout the semester. When you start julia, you will get the Julia REPL:

julia>

Press ] to activate the Pkg REPL

(@v1.5) pkg>

Then add some packages like so:

(@v1.5) pkg> add DataStructures Pluto Gadfly StatsBase WordTokenizers

To get out of the Pkg REPL, you can just press Backspace.

And that's it! These are the packages you'll need for our first homework.

  • Pluto is for notebooks, where we will be doing most of our coding.
  • DataStructures provides some convenient data structures. We'll be using the Counter.
  • Gadfly is for plotting pretty graphs.
  • StatsBase provides convenient statistics functions. We'll be doing weighted sampling.
  • WordTokenizers is for tokenizing (splitting a sentence into words).

Let's test them out!

For Gadfly, you can generate pretty plots. It will be slow the first time you do this.

julia> using Gadfly

julia> plot(x=[1,2,3,4,5], y=[3,2,4,1,5], Geom.line)

For DataStructures, the counter() function will generate a Dict containing the frequency of every element in an array:

julia> counter("aaabbcccdde")

For WordTokenizers, something like

julia> using WordTokenizers

julia> tokenize("This is a test!")

julia> split_sentences("This is a sentence! This is another sentence!")

For Pluto, run the following:

julia> using Pluto

julia> Pluto.run(1234)

Then go to localhost:1234 in your web browser. Then you can write code in the cells and press Shift+Enter to execute the contents of each cell.

If you are running Pluto on a remote machine, you can do port forwarding like so:

ssh user@ugradx.cs.jhu.edu -L 1234:localhost:1234

Then going to localhost:1234 on your computer will work as intended.

MIT is running a course on Computational Thinking using Julia this semester. Check out this video here for installing Julia and Pluto.