“Computer science is a terrible name for this business… First of all,
it’s not a science… It’s also not really very
much about computers” (Harold Abelson, MIT
6.001 Structure and Interpretation, 1986). Watch the first episode
of this course to have a wonderful introduction to programming
Programming is about processes, building how-to
knowledge.
If their birth date is more recent
than the previous youngest person’s (or if it’s the first person we
ask), consider this person the youngest person in the
group.
We have to remember “somehow” whose birth date is
the most recent and which person is the youngest
during the process, in order to give the correct answer at the
end. We need to storesome data during the process: we
need memory.
We need to namedata to identify them
correctly.
Let’s do this again using a piece of paper as
memory, to keep track of the correct answer.
Take a piece of paper and writenone for “Youngest Person” and “Birthdate”.
For each person in the group:
Ask for their birth date and their name.
If their birth date is more recent than the
one written on the paper (or if it’s the first person),
update the paper: erase the old info
and write down this new person’s name and birth
date.
Show the name written on the paper.
Find the
youngest person program, a graphical view #
Pseudo-code or structured english (For each, If,
Update, Erase, etc.). This program can not be (yet!) executed
by a computer, because computers speak only binary
language
Our piece of paper = memory (read and write to
it)
Youngest Person,Birthdate are
variables:
They have a name (unique identifier)
They store some dataduring the
process
Our procedure
has two parts: Data and Instructions #
bg right contain
Our program is made of two parts:
Data: “Birth Date”, “Name” are data. It’s facts,
information, values. It doesn’t do
anything.
Actions/Instructions: “For each”, “if”, “update the
paper”, “ask for” are instructions, actions to perform.
Instructions are executable.
Once figured it out, we can code (encode, translate)
this processinto a programming language, like
the Python language (or any other language!), to
automate its execution with a
computer.
Any program can be encoded into different
programming languages
Computers are electronic machines able to execute
very simple operations with bits
Computers only understand binary code, called Machine
code
Machine code is binary patterns that encodes signals for the
hardware to activate specific circuits and execute specific
actions (Read, Write, Add, Compare, etc.). This correspondence is
called Instruction Set Architecture (ISA)
Each machine (CPU) has his own Instruction Set.
Ex: 00010101 10110101 machine code for a given machine
could result in the action “write the value
to memory” or “compare 72 to 16”.
Von
Neumann Architecture is based on a core principle: data and
programs are stored in the same main memory (in binary)
Prior, machines required physical rewiring to switch
programs (One problem to solve = One machine). The Von Neumann
architecture allows computers to run any program simply by loading new
binary instructions into memory! This is Software!
Von Neumann architecture remains the standard computer
architecture used today!
Fundamental architecture: modern computers
still follow the Von Neumann model (a single memory for both
data and instructions, a processing unit and a control unit);
How we program machines: our programming
languages and concepts remain
nearly unchanged, even though hardware has evolved
drastically.
^ -> Python, PHP, Lisp, Java, R, Fortran, etc.
| ----------------------
| Higher level languages (closer to humans)
| ----------------------
| - C Language : on the border between lower and higher level languages
| ---------------------
| Lower level languages (closer to hardware)
| ---------------------
| - Assembly languages (last human readable programming language before binary)
| - Machine code (just bits)
Hardware details are exposed (CPU architecture, registers, memory
addresses). Memory is managed explicitly. Perfect for embedded systems.
Examples: Assembly languages, C/C++ (from a modern perspective).
Pros:
Performance and optimization: Direct control over
execution speed and resource usage (Manual Memory
Management)
What you write is (almost) directly what the hardware executes
Abstract away hardware details. Focus on
problem-solving logic rather than how the
computer works (CPU, RAM). Examples: Java, JavaScript, Lisp,
Python!, etc.
Pros:
“Closer” to the problem to solve, stronger
abstractions (loops, data structures, procedures/functions,
modules, etc.), more human friendly
Portability: Write once, run anywhere
(cross-platform*).
Automatic Memory Management via Garbage
Collection and automatic allocation.
Compiled languages : the entire high-level program
is transformed directly into Machine Code
(01001000...) by a compilerprior
to running. Produces an executable file tailored directly to the CPU
instruction set, yielding maximum execution performance and determinism.
Examples: C, C++, Fortran, Go, Rust
Interpreted languages : a pre-compiled
program, called an interpreter, reads and
translates code line by line into intermediate code
(bytecode), executing instructions dynamicallyon the fly. Offers flexibility and ease of development, but
adds a translation layer above hardware execution and requires to load
the interpreter in memory. Examples: Lisp, PHP, JavaScript, Python
We need to learn its language
syntax to code our procedures.
Syntax changes slightly from one language to another,
concepts and fundamentals don’t! Without knowing, by
learning Python, you will be learning many other languages at the
same time!
Explain something (a concept, a copy/paste piece of
code)
Debug some code
Don’t use it to code/work for you ! Writing code
has never been the problem
You must be able to Understand,
Explain and Modify your code
without AI. You are responsible of
your code and what it does.
Make mistakes. In programming, you can test
your understanding by executing your program!
You will make mistakes and that’s ok. A (good) program is
written iteratively.
Don’t worry, you will have PLENTY OF TIME to be productive in
your (future) job! We are here to LEARN, not
to be productive.
Learning space: Learn by making
mistakes, Receivefeedback, Do
things manually, Use simple or specialized tools, Work on
small-scale problems and systems, Follow
provided specifications (labs, exams, projects)
Production space: Gather
requirements, specify a solution, Respect
constraints (deadline, budget) and tradeoffs (quality/cost),
Communicate, Use more complex environments and
tools, Take responsibility, Deliver, Deploy to
production, Monitor, Maintain, Work on large and complex
systems
Von Neumann has made major contributions to quantum
mechanics, functional analysis, mathematical logic, quantum logic,
computer science, economics, etc! He also participated in U.S. military
programs (Manhattan
Project).
The difference comes down to when variable types are
checked: at compile time (before running) or at runtime (while
running).
Statically Typed languages:
Types are associated with variables and
determined at compile time. Once a variable is declared
as an integer, it cannot hold a string. Examples: C, C++, Java, Rust,
Go, Swift.
Compilers can detect errors before running the
program (at compile time)
Dynamically Typed Languages :
Types are associated with values, not variables,
and checked at runtime. A single variable can hold an
integer, then a string, then a list, etc. Examples:
Python, JavaScript, Ruby, PHP.
Faster to write, with less boilerplate code. Ideal for rapid
prototyping.
Type errors cause crashes while the program is
running!
Python IS a (strong) dynamically typed language
Demonstration:
from high level code to binary code in C #
Compilation of a C program with gcc compiler.
High level C code (main.c)
After compilation (cc -S main.c), assembly
code (main.s)
After assembling (cc main.c), binary
code (a.out). See binary code in hexadecimal
format with hexdump -C a.out