Module
Fundamentals of Programming
Instructor: Fred. Yeboah Email:fredericky@aiti-kace.com.gh
Course Objectives
Understand basics of programming Analyse problem Design solution algorithms using flow chart and pseudo-code Prove correctness of developed algorithms
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
Session 1 What is programming ?
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
What is programming?
is the act of writing instructions using a particular programming technology or language for a computing device to execute them
Note:
for any special computing device to provide a functionality to its user implies a program has been written by someone for that device. Think of the following computing devices:
mobile phones, personal computers, servers, calculators, scientific calculators, etc...
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
What you need to know
Computing devices do what we tell them to do and NOT what we want them to do! Computing devices do not have the capacity to think and make judgment on their own Computing devices have different capacity in terms of volume of instructions to execute and space to store information or data
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
What is a programming language?
A programming language gives the programmer the ability to express him / her intention by writing them as instructions for the computing device.
Its also referred to as programming technology
Programming languages are synonymous to written languages. Think of this:
C programming (C) - French Java programming - English Visual Basic (V.B) - German
Note: they all have rules & sentence structure
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
Types of programming languages
Programming languages allow programmers to code software. The three major families of languages are:
Machine languages Assembly languages High-Level languages
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
Machine Languages
Comprised of 1s and 0s The native language of a computer Difficult to program one misplaced 1 or 0 will cause the program to fail. Example of code:
1110100010101 10111010110100 111010101110 10100011110111
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
Assembly Languages
Assembly languages are a step towards easier programming. Assembly languages comprised of a set of elemental commands which are tied to a specific processor. Assembly language code needs to be translated to machine language before the computer processes it. Example:
ADD 1001010, 1011010
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
High_level Languages
High-level languages represent a giant leap towards easier programming. The syntax of HL languages is similar to English. Historically, we divide HL languages into two groups:
Procedural languages Object-Oriented languages (OOP)
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
10
Compiling / Interpretation
Regardless of the HL Language
all HL programs need to be translated to machine code so that a computer can process the program.
Some programs are translated using a compiler. During compilation all source code are translated all at once.
Some programs are translated using an interpreter. Such programs are translated line-by-line instead of all at once (like compiled programs).
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
11
Examples of the syntax
Written languages
English : German: French :
I love you ich libe dish Je t'aime
Programming languages
Java : System.out.println(Hello, World); C VB : printf(Hello, World ); : PRINT "Hello, World"
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
12
Some programming technologies
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
13
Interacting with a computing device
Communication cycle
One complete unit of communication includes:
An idea to be sent. An encoder. A sender. A medium. A receiver. A decoder. A response.
Speaker encodes information
Listener decodes information
Listener returns feedback to speaker
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
14
Interacting with a computing device (2)
Substituting a computer for one of the people in the communication process.
User encodes information
Computer decodes information
Process is basically the same. Response may be symbols on the monitor.
Computer returns results to user
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
15
Where do they differ?
While communication between individuals use the same language, computing devices and individuals do not. The following areas are where they differ
Semantics Syntax
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
16
Semantics: Refer to meaning
Human language:
Computer language:
Refers to the meaning of what is being said. Words often pick up multiple meanings. Phrases sometimes have idiomatic meanings: let sleeping dogs lie
Refers to the specific command you wish the computer to perform.
Input, Output, Print Each command has a very specific meaning. Computers associate one meaning with one computer command.
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
17
Syntax: Refers to form or structure
Human language:
Computer language:
Refers to rules governing grammatical structure.
Refers to rules governing exact spelling and punctuation, plus:
Pluralization, tense, agreement of subject and verb, pronunciation, and gender.
Formatting, repetition, subdivision of tasks, identification of variables, definition of memory spaces.
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
18
Syntax: Refers to form or structure (2)
Human language:
Computer language:
Humans tolerate the use of language.
Computers do not tolerate syntax errors.
How many ways can you say no? Do they have the same meaning?
@2011 AITI-KACE All Rights Reserved - Fundamentals of Programming
19