Programming for Non-Programmers
Tools of the trade
- Check that you have a JDK on your computer
(on console type javac -version) - Go to http://scala-ide.org/download/sdk.html, download Scala IDE
Why we needed computers?
- We needed a reliable and fast way to do math operations.
- As computers became more and more advanced
people began to find other uses: video, audio, etc. - Nowadays you can do anything(*) with a computer
if you have the time!
Why computers use binary system?
- To achieve really fast speeds, electricity is the way to go!
- Representing 0's and 1's is really easy: is there an
electrical current (ON) or isn't (OFF)? - Current research for computers that can
represent more digits (3 or 4)
What is the standard
architecture for computers?
- It's called the Von Neumann architecture
- The ALU do the calculations, the Control Unit controls the flow of information, the memory storages data and programs, input & output (i/o) interacts with user
- Nowadays the ALU and Control Unit are called the processsor /CPU
A CPU can do a limited
number of operations
- Move this value into a register,
Add two values on register store result into this register,
Go to line-memory #x, etc. - Everything else is just a composition of those basic operations!
A CPU understands instructions
- A 0 or a 1 is called a bit
- 8-bits are called a byte
- Instruction are bytes that the CPU knows how to interpret (e.g. 00000010 means "sum")
- Each CPU has it's own Machine Language
Why we need
Operating Systems?
- They create an abstraction over the CPU
Programming is
- A set of instructions for a computer to execute
- This can be: sum these numbers, draw this to the screen, produce this sound, send this data to another computer, repeat this instruction until something else happens, etc.
- Anything you can define as an algorithm, can be programmable it's just a matter of time (which almost always implies money)
Programming Languages
- Were invented to be able to write on a more readable language
- They also are independent of the computer architecture
- But then, you need a translator to create machine code;
the compiler
Usual process of
creating software
- Write code in the programming language of your choice
- Run a compiler to check if your syntax
is valid while creating a better representation
of your code to be consumed for a computer - Run a linker to create one file written
on machine code - Run program, the computer will do as you say!
Different Computer
Architecture uses different machine languages
If you want to run your program on a different OS you need to recompile
Supposedly, to recompile you wouldn't need to change your code!
- But in reality it wasn't always like that!
- People wanted something
Write Once, Run Everywhere!
Interpreters to the rescue
- You write code on your programming
language of choice - A compiler produces intermediary
code usually called bytecode - That bytecode will be the same regardless of OS
- You run the bytecode using a virtual machine
- The virtual machine translate the bytecode to machine language
Compiled vs Interpreted
languages
- Compiled languages tend to be faster
- Interpreted languages don't need
to be recompiled ever
Programming Paradigms
-
Over time, people began creating best practices on how to program
-
Some of this practices were unified in a paradigm.
-
Some language are created with a paradigm in mind.
-
There are 3 paradigms used on the industry: imperative, functional, object-oriented.
OOP has been since the '80s the predominant programming paradigm in the industry
Programming
Languages
C++
- It popularized OOP
- It was the successor to
the most important imperative language: C - It's still in use, but not in web development
Java
- It overtook C++ as the most popular
OOP language - It's interpreted; it's virtual machine
is called the JVM It has been criticised
as a verbose and old-fashioned language - Since Java 8 it introduced some FP features
- It's now guided by from Oracle
C#
- OOP language created by Microsoft
- It's part of the .NET Framework,
which is mostly for Windows - It also has some FP features
Scala
- It's a JVM language that mixes OOP and FP
- It has become the 2nd most popular
language on the JVM - For years the industry has expected it to overthrow Java as the most used language on the JVM, but it has not happened yet
- It's guided by Typesafe
Javascript
- It's a language mainly used in front-end web development.
- It also mixes OOP and FP, although is a mostly misunderstood language.
- It's guided by the W3C (World Wide Web Consortium)
Programming for Non-Programmers
By Carlos Obregón
Programming for Non-Programmers
- 1,780