JK C - 1 - An Overview of Programming Languages

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 27

An overview of programming

languages
Objectives
• Learn basic computer terminology and
component architecture

• Explore the history of programming languages

• Recognize the similarities between


programming languages and spoken languages

• Solve problems and develop algorithms

2
Understanding Basic Computer
Terminology And Component
Architecture
• Understand basic computer terms

• Fundamentals of how computer works

• Computer requires:
• Hardware

• Software

3
Understanding Basic Computer
Terminology And Component
Architecture (continued)
• Hardware

– Physical components of computer

• Architecture

– Arrangement of hardware components within


computer

4
Computer Systems: Computer Hardware and Software

Hardware
Central
Processing
Unit
Input Output
Device Device
Main
Memory

Secondary
Storage
Software

Software refers to the programs that run on a computer.

Two categories of software:


1.Operating system (OS)
A set of programs that manage the computer’s hardware
devices and control their processes.
Examples: Windows Vista, Mac OS X, Linux.
2.Application software
Programs that make the computer useful to the user.
Examples: Microsoft Word, Adobe PDF Reader
Programs and Programming Languages

What is a program?

A computer program is a set of instructions that enables the


computer to solve a problem or perform a task.

The program steps are called an algorithm.


Main Memory

• Commonly referred to as Random Access Memory (RAM)


• Is an ordered sequence of storage cells, each capable of
holding a piece of data.
• Each memory cell has a distinct address.
• The information held can be input data, computed values, or
program instructions, which are represented in combination
of 0s or 1s. This is so-called binary representation.
• The information stored in RAM is volatile.
Secondary Storage

•A nonvolatile storage medium


•Contents retained while power is off
•Hard disk drives are most common
•Records data magnetically on a circular disk
•Provides fast access to large amounts of data
•Optical devices store data on CD’s as pits
•USB flash memory devices
•High capacity device plugs into USB port
•Portable, reliable, and fits easily in a pocket
Input Device

•Any type of device that provides data to a computer from


the outside world
•For example:
•Keyboard
•Mouse
•Scanner
Output Devices

•Any type of device that provides data from a computer to the


outside world
•Examples of output data:
•A printed report
•An image such as a picture
•A sound
•Common output devices include:
•Monitor (display screen)
•Printer
Programming Languages

•The steps in our algorithm must be stated in a form the


computer understands
•The CPU processes instructions as a series of 1’s and 0’s
called machine language
•This is a tedious and difficult format for people
•Instead, programming languages allow us to use words
instead of numbers
•Software converts the programming language statements to
machine language
History of Programming Languages

Machine Languages

Computer hardware consists of microelectronic switches,


which can be switched on or off. The on/off switch status can
be represented using binary 1 and 0.

Example of machine language code:


0010 1100 0110 0000
Machine language is CPU type-dependent. That is, every type
of CPU has its own machine language.

Machine languages are low-level programming languages.


Low-level Programming Languages

Assembly Languages

Assembly languages use mnemonics in place of the 0s and 1s


in programs. It is common to see that the mnemonic ADD is
used to represent the add operation. For example,

ADD bx, ax

In order to execute a program written in Assembly language,


the program should be first converted into a machine language
program using an Assembler, which is also a program.

Assembly languages are low-level languages and are CPU


type-dependent.
High-Level Programming Languages

High-level program languages more resemble English language than low-level languages. Examples:

• Visual Basic • C#
• Python • C
• Javascript • C++
• Java • PHP

• Visual Basic is not just a programming language


• It’s a programming environment with tools to:
• Create screen elements
• Write programming language statements
High-Level Languages (cont’d)

High-level languages allow programmers to write programs in a


more readable form. For example:

grossPay = hours * rate

Programs written in high-level languages should be converted


into machine languages using interpreters or compilers.

An interpreter translates a program from high-level language


into machine language line by line during program execution.

A compiler translates a program into machine language in its


entirety before executing the complied program.
Language Portability

Low-level languages are CPU-dependent, thus they are not


portable.

High-level languages are not CPU-dependent, thus they are


portable. Compilers that work for specific types of computer
systems made the high-level language portable.
High-level Languages
(continued)
• Compiler
– Translate program to machine code
• Linker
– Combines object code with other programs in class
libraries
• Loader
– Loads object code into memory
– Executes program

18
High-level Languages (continued)
• Source code refers to the program written in a high-level
language.

• Object code is the machine language version of the source


code.
• Executable code is created from the object code and
necessary software library components. The executable
code is ready to be run on an operating system.
• In Microsoft Windows operating system, a file with file
types of .exe holds the executable code.
• Class library Collection of object files

– Support features and functions of a high-level language

19
20
Learning a Programming Language
• Understand basic vocabulary
• Keywords
– Words built into language
– Also called reserved words
• Statements
– Consist of:
• Keywords- Words with special meaning to Visual Basic (e.g.,
printf , scanf
• Identifiers - Names created by the programmer (e.g.,
sngGrossPay, btnClose)
• Operators: Special symbols to perform common operations
(e.g., +, -, *, and /)
• Comments - Remarks: Comments inserted by the programmer – these
are ignored when the program runs (e.g., any text preceded by a single
quote)

21
Learning a Programming
Language (continued)
• Syntax
– Rules of language
– Includes:
• Spelling
• Punctuation
• Grammar
– Each programming language has own unique
syntax and structure

22
Learning a Programming
Language (continued)
• Syntax error

– Mistake in program

• Violates language rules

– Compiler checks for syntax errors

23
Learning a Programming
Language
• Logic error

– Mistake in program

• Executes and produces incorrect result

– Also known as bugs

– Not checked by compiler

24
Solving Problems and
Developing Algorithms
• Computer programming is problem solving
• Problems solved by programs
– Require inputs
– Produce outputs
• Algorithm
– Sequence of steps used to transform input(s) into
desired output(s)
25
26
Summary
• Computer consists of:
– Hardware
– Software
• Programming languages:
– Machine language
– Assembly language
– High-level languages

27

You might also like