0% found this document useful (0 votes)
3 views

Programming Fundamentals_Definitions and Languages_links

The document provides an overview of programming fundamentals, including definitions of key terms such as computer programs, compilers, and programming languages. It describes the different generations of programming languages, their characteristics, and the roles of translators like assemblers, interpreters, and compilers. Additionally, it discusses high-level and low-level languages, their advantages and disadvantages, and examples of integrated development environments (IDEs).

Uploaded by

wba59179
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Programming Fundamentals_Definitions and Languages_links

The document provides an overview of programming fundamentals, including definitions of key terms such as computer programs, compilers, and programming languages. It describes the different generations of programming languages, their characteristics, and the roles of translators like assemblers, interpreters, and compilers. Additionally, it discusses high-level and low-level languages, their advantages and disadvantages, and examples of integrated development environments (IDEs).

Uploaded by

wba59179
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

Programming

Fundamentals
DE F I N ITIONS, T R A NSL ATORS A N D P ROG R AMM ING
L A N G UAGES
NICOLA TURING

REFERENCE: Form 3, Unit 3. Pages 63-75.


Senior Secondary Computer Studies, Andrew Nasalangwa.
Students should
demonstrate an
understanding of basic
programming techniques
Learning and should be able to:
outcomes
• Define computer program,
complier, translator, assembler
• Describe the generations of
programming languages
• State examples of programming
languages
“List of instructions that enable a
computer to perform a specific task”

Computer Using the analogy of a recipe, a program


contains:
program:
Definition ❖Variables (list of ingredients)
❖Statements (list of instructions that
instructs the computer what to do with the
variables)
Computer programming:
Definition
“process of writing a computer
program using a programming
language”

Programmer = person who writes programs


Software developer / software engineer =
person who writes programs at a higher level
Algorithm design = process of designing a
program (requires both a scientific approach
and creative thinking to come up with a good
design)
Programming languages:
Definition
“formal language that specifies the syntax and
semantic rules for writing computer programs”
Source code: Definition
➢Set of instructions or statements written by a programmer that not yet
converted into machine readable form
➢Usually a text file written using programming languages like:
➢BASIC
➢Pascal
➢C
➢C++
➢Delphi
➢Java
➢Python
Object code: Definition
➢A computer program after
Input Output
translation into machine code
➢To convert source code into
High-level Machine
machine code use language Compiler
language code
processors / translators including:
➢Assemblers
➢Interpreters High-level
Executes
Interpreter each
➢Compilers language
statement

Assembly Machine
Assembler
language code
Translator: definition
“the systems software used to translate a source program
written in any language other than machine code”

Low level High level


languages languages

Assembler Interpreter

Compiler
Assembler: Definition
“An assembler program converts assembly language programs into
machine code that the computer can understand and execute.”
Assemblers either store the program directly in the main memory ready
for execution as it is translated, or store the translated program on
storage media (which will then need a loader program to load the stored
program into the main memory to be executed)

Source code
Object code
(written in
Assembler (version of
assembly
machine code)
language)
Interpreter: Definition
“An Interpreter is a computer program that converts the source
code(from a high-level language) into machine code statement by
statement allowing the CPU to execute one line at a time”

High-level Executes each


Interpreter
language statement

➢ Interpreted line NOT stored in the computer memory


➢ Every time the program needed for execution, each line has to be
interpreted
➢ If an error is found the interpreter prompts the user to correct the error
Compiler: Definition
“ A Compiler is a computer program that translates a source
program written in a high-level language to machine code
or p-code, object code that can be directly used by a
computer to perform tasks”

Object code = a computer program after translation into machine code


P-code = name for several of Microsoft's proprietary intermediate
languages. They provided an alternate binary format to machine code.
Abbreviation for either packed code or pseudo code.
Compiler

High-level Machine
Compiler
language code

Once a program is compiled, the machine code can be used again and
again to perform the same task without re-compilation.
Linking to convert object code
into an executable file
Linking combines the object code with library files that are
required for the execution of the program

Libraries
Executable file
CPU
(.exe)
Source code Preprocessed Object code

Preprocess Compile Link (linker) Load to RAM


Comparison of Interpreters and Compilers (1)
Interpreter Compiler
Translation of source program Translates one statement at a Entire source code translated
time before execution
Time taken to run / execute Takes longer to run as each Take shorter time to run as
the program line of source code needs to translation already completed
be translated before it is & the machine code
executed every time the generated may also have
program is run been optimised by the
compiler
Memory required Less More – object files are larger
Errors May still contain syntax or No syntax or semantic errors
semantic errors
Possible to execute on Not possible to interpret Source program can be
another computer program on one type of translated on one type of
computer and then run on computer & then executed on
another type of computer another type of computer
Comparison of Interpreters and Compilers (2)
Interpreter Compiler
Error detection Easier to debug a program Finds all errors in a program.
using an interpreter as errors May find more errors than
can be corrected on each line the actual number of errors
and the program restarted as may detect errors later in
from any place the program that won’t exist
if earlier errors are corrected.
May cause computer to crash No Yes
Ease of development Possible to view partial Only possible to view partial
results during development, results during development
allowing developer to decide by writing special routines.
what should be done with a More difficult to assess
section of code quality of sections of code.
Modification by end users Yes - end users have all the No – no access to source
possible source code and run-time code or run-time libraries and
libraries, allowing them to so reliant on developer for
modify the program as updates and alterations.
required
HIGH LEVEL LANGUAGE ASSEMBLY MACHINE
(COMPILER) LANGUAGE CODE

Sum:=FirstNumber+SecondNumber LDA First 0001 00010010


ADD Second 0100 00010011
STO Sum 0000 00011010

Example to show results of compiler and assembler


Integrated Development
Environment (IDE)
“An Integrated Development Environment (IDE) is a suite of programs used
to write and test a computer program written in a high-level programming
language.”
In general, an IDE is a graphical user interface (GUI)-based workbench
designed to aid a developer in building software applications with an
integrated environment combined with all the required tools at hand.

Source code editor

Compiler and / or interpreter

IDE Run-time environment with debugger

Auto-documenter
Apache NetBeans

Examples of PyCharm (Python IDE from


Integrated Jet Brains)
Development
Environments
(IDEs) Visual Studio (Microsoft)

SharpDevelop (open-source
IDE for the .NET platform)
High and low level
programming languages
Understandable
by human

High-level languages

Assembly languages

Low-level
Machine code
languages

Binary code

Understandable
by machine
Low level languages
Machine languages / code (1st Assembly languages (2nd
generation) generation)
➢Written using hexadecimal or ➢Attempted to make computer
binary code languages readable
➢Many lines of code needed to ➢Programs written as set of
accomplish even a simple task symbolic operation codes
(pneumonics = shortened 2 or 3
➢Different CPUs understand letter words)
different machine languages
➢Programs hard to write and
debug
➢Programs easy to execute from
the computer point of view
To make use of special
hardware

To make use of special


When are machine-dependent
instructions
Assembly
languages
used? To write code that doesn’t
take up much space in
primary memory

To write code that performs a


task very quickly
LDA First
ADD Second
STO Sum

Program in
Assembly LDA means load the value of the
variable into the accumulator
Language to add 2
numbers together ADD means add the value of
another variable to the value
stored in the accumulator
STO means replace the value of the
variable by the value stored in the
accumulator
Advantages and disadvantages
of low-level languages
ADVANTAGES DISADVANTAGES
➢CPU understands machine ➢Difficult & cumbersome to use and
language directly with minimal or no learn
conversion
➢Require highly trained
➢Processor executes low-level programmers to develop and
programs faster as complex maintain programs written in low
instructions already broken down level languages
into smaller simpler ones
➢Correcting errors (debugging) in
➢Stable and rarely crash or low level programs difficult
breakdown once written
➢Machine dependent (ie NOT
portable from one machine to
another) - for example the code for
Intel processors may differ from
Motorola processors
High level languages
➢Enable programmer to focus on ➢Once a programmer has learnt
the problem to be solved the techniques of programming in
any high-level language, these can
➢Require no knowledge of the be transferred to working in other
hardware and instruction set of high-level languages
the computer that will use the
program Programs written in a high level
language are easier to:
➢Portable
➢Read and understand as closer to
➢Can be used on different types of human language
computer (machine independent)
➢Write in shorter time
➢Designed for programmers –
programming statements easier to ➢Debug at the development stage
understand than those written in
low level language ➢Maintain once in use
Categories of high
level languages
1. Third generation languages
2. Fourth generation languages
3. Fifth generation languages
4. Object-oriented languages
5. Web development and scripting languages
Third generation languages
(Structured / procedural languages)
➢Program broken down into Examples of 3rd generation programming languages:
components called modules /
sub-program, each ➢Pascal initially developed as procedural language to help
performing a specific task in teaching & learning of structured programming
➢Control structures used in ➢FORTRAN (FORmula TRANslator) written for use by
problem solving mathematicians, scientists & engineers
➢Flexible ➢COBOL (Common Business-Oriented Language) designed
for common business problems such as inventory control
➢Easier to read systems
➢Easier to modify ➢BASIC (Beginners All-purpose Symbolic Instructional
Code) developed to enable students to easily learn
programming
➢C used for developing system software such as the OS –
provides programmers with powerful features of low level
languages whilst being easy to understand
➢Ada named after first lady programmer, Ada Lovelace.
Used for developing military, industrial and real-time
systems

Categories of high level languages


Fourth generation languages
➢Improvement on 3rd generation Examples of 4th generation
languages to make the programming languages:
programmer focus more on the
problem than on the algorithm or ➢Powerbuilder
structure of the program ➢FoxPro
➢Some overlap with 3rd generation ➢Python
languages
➢Progress 4GL
➢Include advanced programming
tools for: ➢Microsoft Visual Basic
➢integrating programs with
databases ➢Delphi Pascal
➢Generating reports
➢Creating GUI applications

Categories of high level languages


Fifth generation languages
(natural languages)
➢Used to develop systems that Examples of 5th generation
solve problems using Artificial programming languages:
Intelligence (AI)
➢PROLOG
➢AI includes:
➢Visual (seeing) perception
➢Mercury
➢Speech recognition ➢LISP
➢Decision making
➢OPS5
➢Movement

➢Programmer only worries about


the constraints required for the
problem to be solved, but not
designing the algorithm

Categories of high level languages


Object-oriented programming
(OOP)
➢Program may consist of several Examples of OOP languages:
objects that interact by sending
messages to each other ➢Java
➢Several objects linked together by ➢Microsoft Visual Basic.Net
a method known as association to ➢Objective-C
create a complete program
➢C++
➢NOT classified as a separate
generation – shift in program ➢C#
development methodology
➢Python
➢Most languages that supported
structured programming have ➢Ruby
been enhanced to support OOP
➢Delphi Pascal
➢Smalltalk

Categories of high level languages


Web Development Languages
➢Web pages created in Hypertext Markup Language(HTML)
➢HTML consists of tags that are interpreted by the web browser software to
display content when the file is opened in the browser. It includes the
semantics (meaning) and structural part of the document
➢Tag word, symbol or character enclosed in angle brackets <> that a browser
can interpret as a command. Most HTML elements have an
➢opening tag (enclosed between < >) and a
➢closing tag (enclosed between </ >)
➢XML (extended HTML) – alternative to HTML that allows users to define
their own tags
➢Note: HTML not considered as a programming language as it doesn’t have a
declaration part or control structures
➢CSS (Cascading Style Sheet) – separate file that contains everything to
control the actual presentation / style of the web pages
Web Scripting Languages
➢Enhance the interaction and Examples of scripting languages:
dynamism of HTML web pages
➢JavaScript
➢Small program code written in a
scripting language and then ➢VBScript
inserted into the HTML document ➢Hypertext Preprocessor (PHP)
to add functionalities such as:
➢Sliding
➢Calendar
➢Form validation

Categories of high level languages


Advantages and disadvantages
of high-level languages
ADVANTAGES DISADVANTAGES

➢Portable (can be installed in more ➢Encourage use of many


than one computer) instructions in one statement
which can cause slower program
➢User friendly, easy to use and processing
learn
➢Have to be interpreted /
➢More flexible, enhance creativity compiled to machine form before
of programmer, increase computer can execute them –
productivity need more hardware and software
➢Easier to debug (correct resources
programs) ➢Require large computer memory
to be executed
Revision – students should be
able to:
Define: Describe the generations of
programming languages and give
❖Computer program examples:
❖Source code ❖Low level
❖Object code ❖Machine code
❖Assembly language
❖Assembler
❖High level
❖Interpreter ❖3rd generation
❖Compiler ❖4th generation
❖5th generation
❖Translator
❖Object-oriented programming
❖Integrated development ❖Web development and web
environment (IDE) scripting languages

You might also like