Sunteți pe pagina 1din 15

Overview of Programming Languages

COMPUTER LANGUAGE

A language is a system of communication. computer language is a means of communication used to communicate between the people and the computer. Computer programmer uses the computer language to tell the computer what to do.

BROAD CATEGORIES OF COMPUTER LANGUAGES


There

are three categories of programming languages:

Machine language: language of 0 and 1 Assembly language: language of mnemonics High-Level language: language of English words and mathematical symbols.

Machine languages and assembly languages are also called low-level languages

PROGRAMMING LANGUAGES
Machine Language

Natural language of a particular computer.

Consists of strings of numbers(1s, 0s)

Instruct computer to perform elementary operations one at a time. Machine dependant.

Machine Language
Advantages

: Fast and efficient Machine oriented No translation required :

Disadvantages

Not portable Not programmer friendly

PROGRAMMING LANGUAGES
Assembly Language

Assembly language programs use mnemonics to represent machine instructions. Translators programs called Assemblers to convert assembly language programs to machine language. E.g. add overtime to base pay and store result in gross pay
LOAD ADD BASEPAY OVERPAY

STORE

GROSSPAY

MACHINE LANGUAGE AND ASSEMBLY


LANGUAGE Compare the following codes : Assembly code: MOV AX , var1 ADD AX , var2 MOV var1 , AX

Machine Code: 1010 0001 0000 0000 0000 0000 0000 0011 0000 0110 0000 0000 0000 0010 1010 0011 0000 0000 0000 0000 Which one is easy to understand/remember?

PROGRAMMING LANGUAGES
High-level

languages To speed up programming even further. Single statements for accomplishing substantial tasks. Translator programs called Compilers to convert high-level programs into machine language. E.g. add overtime to base pay and store result in gross pay grossPay = basePay + overtimePay

HIGH-LEVEL LANGUAGES
Advantages

: Portable or machine independent Programmer-friendly : Not as efficient as low-level languages Need to be translated Examples : C, C++, Java, FORTRAN, Visual Basic

Disadvantages

COMPILER

A compiler is a computer program that transforms human readable source code of another computer program into the machine readable code that a CPU can execute. act of transforming source code into machine code is called "compilation". converts all the files of a given project

The

Compiler

at once.

INTERPRETER

This is a software tool which interprets the user written code line by line, unlike compiler, which processes everything at once.

In

this case a single line is executed at a time. It is time consuming and not used in real-time applications.

LINKER

Linker uses the object files created by the compiler and then uses the predefined library objects to create an executable.

This

executable is the one which is seen by the common user .

ASSEMBLER
While

compiler processes high level languages, assembler has the capability of processing only the low level assembly language.

This

assembly language is extremely core (microprocessor/platform) specific.

COMPILATION/LINKING

A C program consists of source code in one or more files Each source file is run through the preprocessor and compiler, resulting in a file containing object code Object files are tied together by the linker to form a single executable program
Source code file1.c Source code file2.c Libraries
Preprocessor/ Compiler

Object code file1.o Object code file2.o

Preprocessor/ Compiler

Linker

Executable code a.out

HOW TO COMPILE

To compile and link a C program that is contained entirely in one source file: cc program.c The executable program is called a.out by default. If you dont like this name, choose another using the o option: cc program.c o newname

To compile and link several C source files: cc main.c extra.c more.c This will produce object (.o) files, that you can use in a later compilation: cc main.o extra.o more.c Here, only more.c will be compiled the main.o and extra.o files will be used for linking. To produce object files, without linking, use -c: cc c main.c extra.c more.c

S-ar putea să vă placă și