Rather than machine code, programs can be written in human readable form. For example, we can use short English language strings instead of hexidecimal or binary.
Assembly code can be converted to machine code using an assembler.
The assembler takes the assembly code as input and returns machine code.
Directly to machine code
Evaluate each line as it is run
Compile to code in intermediate language which has its own compiler for further compiling
Variables can either refer to a part of memory, reserving that space for just that variable, alternatively, rather than store value, we can store pointer.
So in first case we have \(x=2\) and \(y=2\), and then we want to change both to \(3\).
In first example, initiate both and store \(2\) in memory twice. update both.
In second example we can have x and y have the same value of a pointer, pointing to a third memory location. we can the update this memory location to change both to \(3\).
Two variable can be the same by value, but additionally by pointer.
eg \(x=2\) and \(y=2\). \(x==y\), but if they have the same pointer, they are the same thing. changing one changes the other.
We can update \(x\) and \(y\) will automatically update
When we say \(x=2\), \(y=x\) we are either making \(y\) mutable or immutable. mutable means same pointer. language specific rules apply.
If we set \(x=2\) we can either create \(2\) in memory, or simply point \(x\) to \(2\), which is already in memory
That means if we do \(x=2\) \(y=2\) they have the same pointer.
Can also cache some other common data values, eg empty lists.
Makes sense if pointer is smaller in memory than value.
Not separate, code is replaced before it is run
Two ways of giving args to parameters, value evals when func called, name evals whenever needed.
Can cause change of state outside of function.
Write too many instructions to stack. can be caused by infinite recursion. eg fun x() return x()).
if we set x =2 we can either create 2 in memory, or simply point x to 2, which is already in memory
that means if we do x=2 y=2 they have the same pointer
can also cache some other common data values, eg empty lists
makes sense if pointer is smaller in memory than value