Pre-lecture


Testing, edge-cases, and names.

Bill Sempf - On Testing
Patrick McKenzie - Falsehoods Programmers Believe About Names

Code As Object - Lecture 2

Coding Concepts I

Python vs. Processing (java) vs. p5.js (javascript)

Many small differences which we'll cover as we come to them.

Python uses whitespace to organize information, Processing and p5.js use curly brackets and semi-colons.

Let's take a look at the wikipedia page about Python's syntax and semantics to illustrate this.

Let's also take a look at some conversion examples from Processing to p5.js

Esoteric Programming Languages

We're focusing on programming languages that are specifically designed to be useable and relatively easy to learn. However, there are programming languages that are designed to be difficult or unusual, called esoteric programming languages. Let's take a quick look at their Wikipedia page.

Pseudocode and Flowcharts

Pseudocode

Pseudocode is just text that's written to feel like code without particular concern for syntax.

Let's try an exercise in writing pseudocode.

Write a program that will draw a circle that moves from the lower left corner of the screen to the upper right.

Flowcharts

A flowchart is a graphical representation of an algorithm.

Let's start programming.
Functions

In processing, and in most object oriented programming languages, we're going to use functions to do things. Functions encapsulate other instructions. We'll learn how to write functions later, for now let's talk about how to use functions that other people have written.

Draw an ellipse in Processing, p5.js, or Python (in Processing).

Reference!

There are going to be many times throughout the semester when you forget how to do something, or need some help. The reference page for each language can help!

Python mode in Processing
Processing
p5.js

Variables

What are variables?

Containers for information that a program can look into and change.

Variables are named so you and the computer can find and change them.

What are variables for?

Values that change over time

Multiple instances of the same value

What else?

You have to declare and/or initialize variables in order to use them.

Initialization is when you assign a value to a variable when you declare it.
(Like labeling a box and putting something inside it.)

You can declare variables without assigning values.
(Like labeling a box without putting anything inside it.)

In Processing (java) you have to choose a variable type when you declare a variable. In p5.js and Python this isn't necessary

This is because Python and javascript are dynamically typed, while java is statically typed. You can read more about what that means here.

Variable types:

Integer

Float

String

Boolean

Additionally, instances of objects can often seem/act like variables.

End of Lecture.