1 - Introduction To Programming Language

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Introduction to Programming Language

• Just as humans use language to communicate, and different regions have different
languages, computers also have their own languages that are specific to them.
• A language is the main medium of communicating between the Computer systems
and the outside world.
• Computer languages can be classified into two categories such as
• Low Level Language
• High Level Language.
Low-Level Languages
• Low level languages are the machine codes in which the instructions are given in
machine language in the form of 0 and 1 to a Computer system.
• It is mainly designed to operate and handle all the hardware of a Computer.
• The main function of the Low level language is to operate, manage and manipulate
the hardware and system components.
• Low level languages are directly executable without any interpretation or translation.
• Low level language is further classified as
• Machine language
• Assembly language.
Machine Language
• It is one of the low-level programming languages.
• It is the first generation language developed for communicating with a Computer.
• It is written in machine code which represents 0 and 1 binary digits.
• Computer system can recognize electric signals so here 0 stands for turning off electric
pulse and 1 stands for turning on electric pulse.
• An instruction written in Machine Language becomes very easy to understand by the
computer and also to increase the processing speed.
Advantages
• There is no need of a translator or interpreter to translate the code,
• It increases the processing speed.
Disadvantages
• Need to remember the operation codes, memory address every time we write a
program.
• Very difficult to find errors in a program.
• It is a machine dependent and can be used by a single type of Computer.
Assembly Language
• It is the second generation programming language.
• It has almost similar structure and set of commands as Machine language.
• Instead of using numbers like in Machine languages here we use words or names in
English forms called as Mnemonics.
• The programs that have been written using Mnemonics in assembly language are
converted to machine language using a translator called Assembler.
Advantages
• It is user friendly as compared to Machine Language.
• Programs written in Machine Language are replaceable by Mnemonics which are
easier to remember.
• Faster in program development.
• Requires fewer instructions as compared to Machine Language to accomplish the
same result.
Disadvantages
• Long programs written in such languages cannot be executed on small sized
computers.
• It takes lot of time to code or write the program, as it is more complex in nature.
• Difficult to remember the syntax.
• Lack of portability of program between computers of different makes.
High-Level Languages
• High-level computer languages use formats that are similar to English.
• The purpose of developing high-level languages was to enable people to write
programs easily.
• High-level languages are basically symbolic languages that use English words and/or
mathematical symbols rather than mnemonic codes.
• Each instruction in the high-level language is translated into many machine language
instructions that the computer can understand.
• Either compiler or interpreter is used to convert the hign- level language program to
machine understandable form.
Advantages
• Easy to write, debug and test the program because hign level language are English like
languages.
• No need to remember assembly language code (Mnemonics).
• These languages are machine independent languages.
Disadvantages
• Execution of program is slower.
• Every high level language program has it own translator because it cannot generate
executable code.
• Conversion time to machine language is more as compared to assembly language.
Compiler and Interpreter
• We generally write a computer program using a high-level language.
• A computer does not understand high-level language.
• A program written in high-level language is called a source code.
• We need to convert the source code into machine code and this is accomplished by
compilers and interpreters.
• Hence, a compiler or an interpreter is a program that converts program written in
high-level language into machine code.
Difference between Interpreter and Compiler

BASIS FOR COMPILER INTERPRETER


COMPARISON

Input It takes an entire program at It takes a single line of code or


a time. instruction at a time.

Output It generates intermediate It does not produce any


object code. intermediate object code.

Working mechanism The compilation is done Compilation and execution take


before execution. place simultaneously.

Speed Comparatively faster Slower

Memory Memory requirement is It requires less memory as it


more due to the creation of does not create intermediate
object code. object code.

Errors Display all errors after Displays error of each line one
compilation, all at the same by one.
time.

Error detection Difficult Easier comparatively

Pertaining C, C++ uses compiler. PHP, Perl, Python uses


Programming interpreter.
languages

== x ==

Character Set
➢ Character set means it is a set of alphabets, letters and some special characters that are valid
in Java language.
➢ The smallest unit of Java language is the characters need to write java tokens.
➢ These character set are defined by Unicode character set.
Unicode System
Unicode is a universal international standard character encoding that is capable of
representing most of the world's written languages.
Why java uses Unicode System?
Before Unicode, there were many language standards:
o ASCII (American Standard Code for Information Interchange) for the United
States.
o ISO 8859-1 for Western European Language.
o KOI-8 for Russian.
o GB18030 and BIG-5 for chinese, and so on.
Problem
This caused two problems:
1. A particular code value corresponds to different letters in the various language
standards.
2. The encodings for languages with large character sets have variable length.
Some common characters are encoded as single bytes, other require two or
more byte.
Solution
To solve these problems, a new language standard was developed i.e. Unicode System.
In unicode, character holds 2 byte, so java also uses 2 byte for characters.
lowest value:\u0000
highest value:\uFFFF

➢ Whenever we write any Java program then it consists of different statements.


➢ Each Java Program is set of statements and each statement is set of different Java
programming lexemes.
➢ In Java Programming each and every character is considered as a single lexeme.
➢ Character Set Consists Of

Alphabets
Uppercase: A B C ................................... X Y Z
Lowercase: a b c ...................................... x y z
Digits
0123456789
Special Characters
+ _ ( ) { } [ ] \ | / > < ; etc.
White Spaces
Tab Or New line Or Space

Tokens

You might also like