Programming Basics

Software is made by programmers
• Computers need all kinds of software, from
operating systems to applications
• People learn how to tell the computers what
to do so that the computers do useful things
• Software on modern computers usually
requires many instructions, millions
sometimes so programmers work together in
teams at software development companies
Programming skills
• Programmers need skills to write good
• Some can be learned, some are innate
• They need to be good communicators, both
with machines and with people
• They should enjoy logic and mental puzzles
• Ideally they also have knowledge of the
domain where their programs will be used
Programming Languages
• The first computer language was machine
language, written in binary (first generation)
• Humans found it very very tedious
• Simple actions took hundreds of machine
• Humans had to translate their desired steps
into machine instructions and then punch
them in or toggle switches to make it happen
Assembly languages
• Soon the computer operators wanted an
easier language to use (second generation)
• Assembly languages look a little like English
– STO 4, X
– ADD 23, X
• Still lots of steps but a little more
Assembly languages
• But assembly language programs had to be
translated back to machine code to be useful
• Machine code is the only language CPUs know
• The translating program is called an assembler
• There are still jobs for people who are good at
assembly languages. Assembly is still used in
game consoles, appliances, chips controlling
machines, etc.
Higher Level Languages
• People still wanted easier languages to use,
ones that were closer to how humans think
instead of how computers work, more
abstract (third generation, high-level
• FORTRAN was the first commercially
successful high-level language (Formula
Translator), done in the 1950’s
• High-level languages also need translator
programs – they are called compilers and
• Other high-level languages are COBOL, Basic
(all kinds of versions), C, C++, Java, Perl,
• Some have free translators, some translators
cost money
How to Program
• Any programmer will have a routine to follow
when given an assignment or deciding what
they want to program
• Sometimes they work through it by hand,
sometimes they have to ask the customer /
manager / employer questions about the
How to, Part 2
• Make a plan! A test plan!
– Involves thinking about how to test the program
• Testing? It does not exist yet! But this early planning
can give insights into how to solve the problem
• Make a design = writing an algorithm in
• Pseudocode is a structured English, with no strict rules
• It’s a way to write a rough draft of a program before it
actually gets put into a programming language
Test Plan
Test Case
Expected Outputs
Normal score in A
Normal score in B
Normal score in C
Error due to wrong
size of score
Error message
about value
Error due to wrong
type of input
Actual Outputs
Design in pseudocode
Open the file for reading
Get all the data from the file into a list
Close the file
Start the total at zero
For each item in the list
– Add the value of the item to a total
– If the value is larger than 75, display a message
• Display the total
Programming Languages
• Languages (human and computer) have
syntax and semantics
• The rules you learned in grammar school
about spelling, punctuation, subject/verbs,
parts of speech, etc. were syntax rules for
• Programming languages have much stricter
rules and will not work if you don’t follow
• The semantics of a human language is the
meaning that the statements convey, the idea
that you are trying to send from your brain to
your listeners’ brains.
• The semantics of a programming language is
what does the computer do when the
program is translated to machine code and
run by the CPU
• Syntax to a human is not strictly necessary, we
can get meaning from a statement which does
not have perfect syntax (things like Twitter
messages and text messages, for example)
• Syntax to a computer is required to be correct,
so programmers have to have pretty good
memories to remember the rules of the
• When an English statement has an error,
misspelling, wrong punctuation, wrong word,
etc., we can usually figure out what is meant
• When a program has a syntax error, it cannot
be translated, so it’s useless. Programmers
get good at fixing syntax errors
• When a program has a semantics error, it is
not doing what the programmer meant it to
do (that’s called a bug)
• Debugging (fixing mistakes in programs) is an
• Programmers have tools to help them do this,
but it is difficult. That’s one reason software
packages have various versions. Bugs get fixed
and the fixes are released to the customers
A career as a programmer
• Many people are employed as programmers
– They may create new programs for their boss
– They may maintain programs which are already
written, debugging, modifying, updating, etc.
• Some people start their own companies to make
the software they think will be useful or popular
or profitable
• Some are self-employed contractors, hiring out to
do programming jobs for different companies