Instructor: Irene Fubara-Manuel
Week 2
Codes—by name and by matter—are what determine us today, and what we must articulate if only to avoid disappearing under them completely
Etymology of Code
A specific process with enough detail to allow the instructions to be followed. […] just a precise way of explaining how to do something.
Code has become arguably as important as natural language because it causes things to happen, which requires that it be executed as commands the machine can run. Code that runs on a machine is performative in a much stronger sense than that attributed to language.
Code is the only language that is executable.
Code works by being coded, and this code is encoded, that is, it is less than obvious or immediately legible. […] Without the ‘coding of code’, code has no force and it does not ‘execute’.
Source code: The form of a program that is input to a compiler or translator [interpreter] for conversion into an equivalent object.
Sol Lewitt, Instructions by Sol LeWitt for the exhibition Drawing Now: 1955-1975,
Vera Molnar, Toward Aesthetic Guidelines forr Paintings with the Aid of a Computer, 1975
// Two slashes start single-line comments var x; // declaring a variable x = 3 + y; // assigning a value to the variable `x` foo(x, y); // calling function `foo` with parameters `x` and `y` obj.bar(3); // calling method `bar` of object `obj` // A conditional statement if (x === 0) { // Is `x` equal to zero? x=123; } // Defining function `baz` with parameters `a` and `b` function baz(a, b) { return a + b; }
Data Type | Values |
---|---|
Booleans: | true or false |
Numbers: | Integers 1023 |
Floats 7.851 | |
Strings: | ‘hello’ or “hello” |
Plain objects | { firstName: ‘Jane’, lastName: ‘Doe’ } |
Arrays: | [ ‘apple’, ‘banana’, ‘cherry’ ] |
var x; // Declaration x = 12; // Assignment var x = 12; // Shorthand
A variable created inside a block (code enclosed within braces: { and }) exists only inside that block.
ellipse(width/2, height/2, 100, 100); // What is the slash after width
Symbol | Operation |
---|---|
+ | Addition |
− | Subtraction |
* | Multiplication |
/ | Division |
= | Assignment |
!: PEMDAS (Parentheses, Exponents, Multiplication, Division, Addition, Subtraction) when using arithmetics
Symbol | Operation |
---|---|
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
== | Equal to |
!= | Not equal to |