Lecture 1: Introduction to
Programming
|
Outline
• Definition:
– Program
– Computer Programming
– Programming Languages
• Categories of Programming Languages
– Low Level Languages
– High Level Languages
• Translating High Level Language
04/27/202
5
Lecture 1: Introduction to Programming |
Program
• A sequence of instructions that a compute
r can execute to perform some task.
• Without programs, computers are useless
04/27/202
5
Lecture 1: Introduction to Programming |
Computer Programming
• Computer programming is the process of
writing, testing,
debugging/troubleshooting, and
maintaining the source code of computer
programs.
• This source code is written in a
programming language.
04/27/202
5
Lecture 1: Introduction to Programming |
Programming Language
• A programming language is a set of rules
that provides a way of telling a computer
what operations to perform.
04/27/202
5
Lecture 1: Introduction to Programming |
Programming Language
• A programming language is an artificial
language designed to communicate
instructions to a computer.
• Examples: C++, Java, Python, Html
• Any other names you might know of?
04/27/202
5
Lecture 1: Introduction to Programming |
Programming Languages
• English is a natural language: It has words,
symbols and grammatical rules.
• A programming language albeit artificial
also has words, symbols and rules of
grammar.
• The grammatical rules are called syntax.
– Discuss some of the rules in different official
languages
• Each programming language has a
different set of syntax rules.
04/27/202
5
Lecture 1: Introduction to Programming |
Very many programming
languages
• Programming languages have evolved
over times as better ways have been
developed to design them.
– First PLs developed in the 1950s
– Since then thousands of language have been
developed
• Different programming languages are
designed for different types of programs
04/27/202
5
Lecture 1: Introduction to Programming |
Categories of Programming
Languages
04/27/202
5
Lecture 1: Introduction to Programming |
Categories of Programming
Languages
• Low level languages
– Machine Language
– Assembly Language
• High Level Languages
– Procedural Languages
– Object Oriented Programming Languages
• A Low Level language is one which exposes
a significant amount of the computer's inner
workings while high level programming
languages hide the details of the computer.
04/27/202
5
Lecture 1: Introduction to Programming |
Low Level Languages
04/27/202
5
Lecture 1: Introduction to Programming |
Machine Language
• Consist of a string of binary numbers (1s and
0s)
• “Natural language” of a computer and as such
defined by its hardware design.
• Machine dependent:-Any computer can directly
understand only its own machine language.
• Easily understood by computers
• Cumbersome for humans:
– Too slow
– Tedious
– Error prone
04/27/202
5
Lecture 1: Introduction to Programming |
Machine Language Example
04/27/202
5
Lecture 1: Introduction to Programming |
Assembly Languages
• Programmers began using English-like
abbreviations “mnemonics” to represent
elementary operations
• The abbreviations formed the basis of
assembly languages.
• Clearer to humans, incomprehensible to
computers until translated.
• Translator programs called assemblers created
to convert assembly language programs to
machine language.
• Machine dependent
04/27/202
5
Lecture 1: Introduction to Programming |
Assembly Languages
04/27/202
5
Lecture 1: Introduction to Programming |
High Level Languages
04/27/202
5
Lecture 1: Introduction to Programming |
High Level Languages
• Allow the writing of computer programs
using statements resembling everyday
spoken language.
• Easier to program: Closer to human
languages
• Require translation into machine language
• Machine Independent/ Portable
04/27/202
5
Lecture 1: Introduction to Programming |
Procedural Languages
• Procedural programming could be
regarded as a list of instructions telling a
computer, step-by-step, what to do and
usually having a linear order of
execution from the first statement to the
second and so forth with occasional loops,
functions and branches.
• Examples: C, Fortran, Pascal, BASIC
04/27/202
5
Lecture 1: Introduction to Programming |
Object Oriented Programming
Languages
• The focus of OOP languages is not on
structure, but on modeling data.
• Programmers code using “blueprints” of
data models called classes.
• Examples of OOP languages include Java,
C++,Visual Basic.NET and Java.
04/27/202
5
Lecture 1: Introduction to Programming |
Translation of HL Languages
• All HL programs
need to be
translated to
machine language
so that a
computer can
process the
program.
04/27/202
5
Lecture 1: Introduction to Programming |
Translation of HL Languages
• These translation can occur in two ways:
– Compiling: Block of source code translated all
at once:
– Interpreting: Block of source code translated
one line after another:
04/27/202
5
Lecture 1: Introduction to Programming |
Compiling
• Compile is to transform a program written in a
high-level programming language from source
code into object code.
• This can be done by using a tool called compiler.
• A compiler reads the whole source code and
translates it into a complete machine code
program to perform the required tasks which is
output as a new file.
• Compiled programs typically execute more
quickly than interpreted programs, but have a
slower translation speed.
04/27/202
5
Lecture 1: Introduction to Programming |
Compiling
04/27/202
5
Lecture 1: Introduction to Programming |
Interpreting
• Interpreter is a program that executes
instructions written in a high-level language.
• An interpreter reads the source code one
instruction or line at a time, converts this
line into machine code and executes it. Such
programs are translated line-by-line instead
of all at once (like compiled programs).
• Interpreted programs generally translate
quicker than compiled programs, but have a
slower execution speed.
04/27/202
5
Lecture 1: Introduction to Programming |
Comparison
04/27/202
5
Lecture 1: Introduction to Programming |
Discussion
• Procedural programming
• Object oriented programming
• Functional programming
04/27/202
5
Lecture 1: Introduction to Programming |
Reading Task
• Identify 4 programming languages used to
develop each of the below categories of
software:
– Mobile applications
– Web applications
– Desktop applications
04/27/202
5
Lecture 1: Introduction to Programming |