You are on page 1of 27

PROGRAMMING LANGAUGE

PRAGMATICS(PLP)

CHAPTER 1
INTRODUCTION
Introduction

• A Programming language is a formal language that


specifies a set of instructions that can be used to produce a
set of outputs.
• Pragmatics is a study of how language is used and how the
different uses of languages determine syntax and
semantics.

• 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.

b)Choose among alternatives way to express things


• In c++,programmer needs to avoid the unneccasary temporary
variables and copy constructor
• In java they wish to use Executor objects rather then creating threads
Why study programming languages?
c)Make good use of debuggers,assemblers,linkers & related tools
•In general high level languages programmer should not need to bother
about the implementation details.
•The bug or unsual system building problem is sometime a lot easier to
handle if one is willing to peek at the bits.

d)Simulate useful features in languages that lacks them


•In older version of fotran,programmer familiar with model constructs can
use comments and self discipline
•In languages without named constants or enumeration types, variable that
are initialized once and never changed .
Why study programming languages?
e) Make better use of technology wherever it appears
•Most programmers will never design or implement a conventional
programming langauge,but most will need language technology for
programming tasks
•Files can in various structure formats like
wordprocessing,spreadsheet,web content ,music,video and so on..
•Code to manipulate these data in based n language technology
Imperative languages

• 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

c)Logic or constrained based Languages:


•They model computation as an attempt to find values
•They specify a certain relationship using a list of logic
rule
•Eg: prolog ,XSLT
Imperative 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

C)Object Oriented languages:


•Most are closely related to von numen languages
•They have a more structured and distributed model of memory and
computation
•It has interactions on semi independent objects
Eg:Small talk,C++,Java
Compilation vs. Interpretation
• Compilation vs. interpretation
– not opposites
– not a clear-cut distinction
• Pure Compilation
– The compiler translates the high-level source
program into an equivalent target program
(typically in machine language), and then goes
away:
Compilation vs. Interpretation

• 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

• Many compiled languages have interpreted


pieces, e.g., formats in Fortran or C
• Some compilers produce nothing but virtual
instructions, e.g., Pascal P-code, Java byte
code, Microsoft COM+
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

• Compilers and Interpreters does not exist in isolation


• In older programmers all these tools may be executed
individually
• Most recent environments provide much more integrated tools
with an ide
• Programmers are assisted in their work by a host of other tools
• -Assembler,Debuggers,linkers,editors
• Pretty printer(formatting convention)
• Style checkers(syntax and semantics)
• Configuration management tools
• Profilers and other performance analysis tools
Questions Covered on Todays Session

1.Why are there so many programming langauges?Explain 6M


2.What makes a language Successful? Explain 10M
3.Explain the Programming Language Spectrum 6M
4.Why to study programming Langauges?explain 10M
5.Explain Compilation and Interpretation 10M
6.Write a short note on Programming Environment 4M

You might also like