Professional Documents
Culture Documents
PRAGMATICS(PLP)
CHAPTER 1
INTRODUCTION
Introduction
• Uses of Languages
a) How to use languages in practical solutions
b) What are the reasons
Why are there so many programming languages?
a)evolution
we've learned better ways of doing things over time In 1960
& 1970 fotran,cobol,pascal…
In 1980 smalltalk,c++
b)special purposes:
Many languages are designed for specific problem domain
Icon ,awk is good for scripting languages.
C is good for low level programming
c)Personal Preferences
Different people like different things
What makes a language successful?
– Expressive power:
easy to express things, easy use once fluent, "powerful” (C, Common
Lisp, APL, Algol-68, Perl)
– easy to learn ( LOGO, Scheme,Java)
– easy to implement (BASIC, Forth,Pascal)
Basic was implemented in tiny machines
Pascal was successful due to simple,portable
---Standardization
--Open Source
– Excellent Complier
possible to compile to very good (fast/small) code (Fortran)
---Economics,Patronage and Inertia
backing of a powerful sponsor ( PL/1,COBOL, C#)
Why study programming languages?
a) Understand Obscure features:
The typical C++ programmer uses the unions, multiple inheritance,
variable no of arguments
The understanding of basic concepts makes its easier to understand
these features.
• Group languages as
– Imperative (performance)
• von Neumann (Fortran, Pascal, Basic, C)
• object-oriented (Smalltalk, Eiffel, C++?)
• scripting languages (Perl, Python, JavaScript, PHP)
– Declarative (higher level) (programmer point )
• functional (Scheme, ML, pure Lisp, FP)
• Data flow (id and val)
• logic, constraint-based (Prolog, VisiCalc, RPG)
Declarative languages
a)Functional Languages:
•Employ a computational model based on the recursive definition of
functions.
•They take inspiration from the lamda calculus a formal computational
model
•Eg LISP,ML
b)Data flow Languages:
•They form the model computation as the flow of information among
primitive functional nodes
•Eg; id and val
Declarative languages
a) Von-nueman Languages:
• They are most familiar and successful
• They are based on statements
• The basic means of computation is modification of variables
Eg:Fotran,ADA83,C
b)Scripting languages:
• There are subset of von nueman languages
• Several scripting languages were developed for a purpose
• Eg:csh,bsh,awk
Imperative languages
• Pure Interpretation
– Interpreter stays around for the execution of the
program
– Interpreter is the locus of control during
execution
Compilation vs. Interpretation
• Interpretation:
– Greater flexibility
– Better diagnostics (error messages)
• Compilation
– Better performance
Compilation vs. Interpretation
• Common case is compilation or simple pre-
processing, followed by interpretation
• Most language implementations include a
mixture of both compilation and interpretation
Compilation vs. Interpretation
• Implementation strategies:
– Preprocessor
• Removes comments and white space
• Groups characters into tokens (keywords,
identifiers, numbers, symbols)
• Expands abbreviations in the style of a macro
assembler
• Identifies higher-level syntactic structures (loops,
subroutines)
Compilation vs. Interpretation
• Implementation strategies:
– Library of Routines and Linking
• Compiler uses a linker program to merge the appropriate
library of subroutines (e.g., math functions such as sin,
cos, log, etc.) into the final program:
Compilation vs. Interpretation
• Implementation strategies:
– Post-compilation Assembly
• Facilitates debugging (assembly language easier for
people to read)
• Isolates the compiler from changes in the format of
machine language files (only assembler must be
changed, is shared by many compilers)
Compilation vs. Interpretation
• Implementation strategies:
– The C Preprocessor (conditional compilation)
• Preprocessor deletes portions of code, which allows
several versions of a program to be built from the
same source
Compilation vs. Interpretation
• Implementation strategies:
– Source-to-Source Translation (C++)
• C++ implementations based on the early AT&T
compiler generated an intermediate program in C,
instead of an assembly language:
Compilation vs. Interpretation
• Implementation strategies:
– Bootstrapping
– A techinique to compile the compiler for the first place one need to start with a
simple implementation of a interpreter
– Uses it to build the more sophistated versions
Compilation vs. Interpretation
• Implementation strategies:
– Dynamic and Just-in-Time Compilation
• In some cases a programming system may deliberately
delay compilation until the last possible moment.
– The Java language definition defines a machine-independent
intermediate form known as byte code. Byte code is the
standard format for distribution of Java programs.
– The main C# compiler produces .NET Common
Intermediate Language (CIL), which is then translated into
machine code immediately prior to execution.
Compilation vs. Interpretation
• Implementation strategies:
– Microcode
• Assembly-level instruction set is not implemented
in hardware; it runs on an interpreter.
• Interpreter is written in low-level instructions
(microcode or firmware), which are stored in read-
only memory and executed by the hardware.
Programming Environment Tools