![]() |
Jupyter at Bryn Mawr College |
|
|
Public notebooks: /services/public/dblank / CS206 Data Structures / 2016-Spring / Notebooks |
The goal of this course is to explore the structures of computation. These include:
If you took the Introduction to Computer Science at Bryn Mawr College or Haverford College, then you have learned some Processing or Python, respectively. We will be transitioning from those languages and systems to a new one based on Java9. To that, we will use many different tools, starting with Jupyter.
Jupyter is a set of new technologies:
Here is an example of how you will use the notebook with computation:
System.out.println("Hello, world!");
Some of you may have learned a bit about Python:
Here is an example of Python in a Java9 notebook via a %% magic:
%%python
# Here is a function definition:
def multiply(a, b):
return a * b
# And some output:
print("Hello, world!")
print(multiply(34, 5)) # Calling a function
setup()
and draw()
functionsHere is an example of Processing in a Java9 notebook via a %% magic:
%%processing
// Here is a function definition:
int multiply(int a, int b) {
return a * b;
}
void setup() {
fill(0);
}
void draw() {
text("Hello, world!", 10, 20);
text(str(multiply(34, 5)), 10, 35); // Calling a function
noLoop();
}
There is better support for both Python and Processing via their own kernels rather than these magics.
Java is typically a "compiled" language. This means that you generally can't do anything unless you compile code into something that can be run.
%%file TestClass.java
class TestClass {
public static void main(String [] args) {
System.out.println("Hello, world!");
}
}
%%shell
javac TestClass.java
java TestClass
But in this course, we will be using an interpreter rather than a compiler. Sometimes this is called a REPL which stands for Read-Eval-Print-Loop. Basically, you can type "snippets" of code interactively, one cell at a time.
System.out.println("Hello, world!");
String my_greeting = "Hello, Doug!";
System.out.println(my_greeting);