0% found this document useful (0 votes)
16 views27 pages

Understanding Programming Languages

A programming language is a formal language used to instruct computers, consisting of syntax rules and symbols. They are categorized into low-level languages (machine and assembly) and high-level languages (third, fourth, and fifth generations), each with varying ease of use and capabilities. Language processors, including compilers and interpreters, translate high-level instructions into machine language, while errors in programming can be classified as syntax or semantic errors.

Uploaded by

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

Understanding Programming Languages

A programming language is a formal language used to instruct computers, consisting of syntax rules and symbols. They are categorized into low-level languages (machine and assembly) and high-level languages (third, fourth, and fifth generations), each with varying ease of use and capabilities. Language processors, including compilers and interpreters, translate high-level instructions into machine language, while errors in programming can be classified as syntax or semantic errors.

Uploaded by

tyagiyash1078
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Programming Language

What is a Programming Languages

A programming language is a formal constructed language


designed to communicate instructions to a machine,
particularly a computer.

A programming language is a set of rules that provides a


way of telling a computer what operations to perform.
What is a Programming Language

• English is a natural language. It has words, symbols and


grammatical rules.
• A programming language also has words, symbols and rules of
grammar.
• The grammatical rules are called syntax.
• Each programming language has a different set of syntax rules.
The Evolution of Programming Languages

Programming languages fall into two broad categories:


• Low level language

Machine level language


Assembly language

• High level language


Levels of Programming Languages
High-level program class
class Triangle
Triangle {{
...
...
float
float surface()
surface()
return
return b*h/2;
b*h/2;
}}

Low-level program LOAD


LOAD r1,b
r1,b
LOAD
LOAD r2,h
r2,h
MUL
MUL r1,r2
r1,r2
DIV
DIV r1,#2
r1,#2
RET
RET

Executable Machine code 0001001001000101001001


0001001001000101001001
001110110010101101001.
001110110010101101001.
..
..
The Evolution of Programming Languages -
Machine Languages

• Machine languages (first-generation languages) are the


most basic type of computer languages, consisting of strings
of numbers the computer's hardware can use.
• Different types of hardware use different machine code. For
example, IBM computers use different machine language
than Apple computers.
Advantages of Machine Language

• It makes fast and efficient use of the computer


i.e. execution of programs become faster.

• It requires no translator to translate the code


i.e. directly understood by the computer
Disadvantages of Machine Language:

• All operation codes have to be remembered


• All memory addresses have to be remembered.
• It is hard to amend or find errors in a program written in
the machine language
• These languages are machine dependent i.e. a particular
machine language can be used on only one type of
computer
The Evolution of Programming Languages –
Assembly Languages

• Assembly languages (Second-generation languages) are only


somewhat easier to work with than machine languages.

• To create programs in assembly language, developers use


cryptic English-like phrases to represent strings of numbers.

• The code is then translated into object code, using a translator


called an assembler.

• Easy to write as compared to machine language.


Assembly
code

Assembler
Object code
Advantages of Assembly Language

• It is easier to understand and use as compared to machine


language.
• It is easy to locate and correct errors.
• It can be modified easily
Disadvantages of Assembly Language

• Like machine language it is also machine dependent.

• Since it is machine dependent therefore programmer should


have the knowledge of the hardware also.
The Evolution of Programming Languages -
Higher-Level Languages

Higher-level languages are more powerful than assembly language and


allow the programmer to work in a more English-like environment.

Higher-level programming languages are divided into three


"generations," each more powerful than the last:

• Third-generation languages

• Fourth-generation languages

• Fifth-generation languages
Higher-Level Languages -
Third-Generation Languages

• Third-generation languages (3GLs) are the first to use true English-like


phrasing, making them easier to use than previous languages.

• 3GLs are portable, meaning the object code created for one type of
system can be translated for use on a different type of system.

• The following languages are 3GLs:

FORTAN C
COBOL C++
BASIC Java
Pascal ActiveX
Advantages of High-Level Language

• User-friendly
• Similar to English with vocabulary of words and symbols
• Therefore, it is easier to learn.
• They require less time to write.
• They are easier to maintain.
• It is independent of the machine on which it is used i.e. Programs
developed in high level language can be run on any computer
Disadvantages of High-Level Language

• A high-level language has to be translated into the machine


language by a translator and thus a price in computer time is
paid.

• Execution of programs slower as compared to low level


languages.
Higher-Level Languages -
Fourth-Generation Languages
• Fourth-generation languages (4GLs) are even easier to use than
3GLs.

• 4GLs may use a text-based environment (like a 3GL) or may


allow the programmer to work in a visual environment, using
graphical tools.

• The following languages are 4GLs:


Visual Basic (VB) Query languages
VisualAge Report generators
Forms designers
Fourth Generation Languages

Advantages
• Average users can quickly learn to “query” the database
• Average users can easily learn how to write programs
• Programs are written faster

Disadvantages
• Can not write sophisticate programs like word processors,
graphics, etc.
• Mostly for data base applications.
Higher-Level Languages -
Fifth-Generation Languages

• Fifth-generation languages (5GLs) are an issue of debate in the


programming community – some programmers cannot agree that they
even exist.

• Based on problem-solving using constraints given to the program,


rather than using an algorithm written by a programmer.

• Fifth-generation languages are used mainly in artificial intelligence


research.
• Examples
• Prolog
• Lisp
• Mercury
Language Processors

• Translators: As the computer accepts digits and characters as


input, such input to be conversed into machine language. The
Software which makes conversion possible and increases the
productivity of the programmer are called Translators.
• There are three basic types of translators they are
i. Compilers
ii. Interpreters
iii. Assembler
Compilers: - A compiler is a software that will convert the high level
instructions into equivalent Machine level instructions at a time.

Interpreters:- A Interpreter is a software that will convert the high


level instructions into equivalent Machine level instructions step by
step.

Assembler:- Assembler is a software that will convert the high level


instructions into equivalent Machine level instructions but here, the
input programs are in assembly language. The output is in machine
language.
• Linker - Tool that merges the object files produced by
separate compilation or assembly and creates an executable
file. Searches the program to find library routines used by
program, e.g. printf(), math routines,…
• Loader - Part of the OS that brings an executable file
residing on disk into memory and starts it running
C Program

Compiler

Object: Library routine(Machine


Object: Machine Language Module
Language)

Linker

Executable: Machine Language Program

Loader

Memory
Difference between Compiler & Interpreter
1. The interpreter takes one statement then translates it and
executes it and then takes another statement. While the
compiler translates the entire program in one go and then
executes it.
2. Compiler generates the error report after the translation of the
entire program while an interpreter will stop the translation
after it gets the first error.
3. Compiler takes a larger amount of time in analyzing and
processing the high level language code comparatively
interpreter takes lesser time in the same process.
4. Besides the processing and analyzing time the overall execution
time of a code is faster for compiler relative to the interpreter.
Errors during Program writing

Generally we encounter with two types of errors while writing program.

1. Syntax Error.
2. Semantics Error.
Errors during Program writing
Syntax - Syntax is the way in which we construct sentences by following
principles and rules.
Syntax error – Error due to the violation of syntax of any programming
language.

Example
int x = "five";

This will not compile because it does not follow the syntax of the language
and does not make any sense to the compiler.
Errors during Program writing
Semantics - is the interpretations of and meanings derived from
the sentence transmission and understanding of the message.
Semantic Error - it is a logical error. it is due to wrong logical
statements.
Example: A semantic error would compile, but be incorrect
logically:

const int pi = 12345;

Your program will likely compile and run without error but your
results will be incorrect. (Note that these types of errors are
usually much harder to debug)

You might also like