0% found this document useful (0 votes)
130 views9 pages

PPL Assignment 1

The document contains answers to multiple questions about programming language concepts. It discusses language evaluation criteria including readability, writability, and reliability. It explains characteristics of programming languages such as simplicity, naturalness, abstraction, efficiency, and structuredness. It lists categories of programming languages including scripting, programmer's scripting, application development, low-level, pure functional, and complete core. Finally, it outlines the stages in the translation process performed by a compiler, including preprocessing, parsing, semantic analysis, intermediate code generation, code optimization, and code generation.

Uploaded by

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

PPL Assignment 1

The document contains answers to multiple questions about programming language concepts. It discusses language evaluation criteria including readability, writability, and reliability. It explains characteristics of programming languages such as simplicity, naturalness, abstraction, efficiency, and structuredness. It lists categories of programming languages including scripting, programmer's scripting, application development, low-level, pure functional, and complete core. Finally, it outlines the stages in the translation process performed by a compiler, including preprocessing, parsing, semantic analysis, intermediate code generation, code optimization, and code generation.

Uploaded by

Pritesh Pawar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

INSTITUTE OF ENGINEERING

JIWAJI UNIVERSITY

PRINCIPLES OF
PROGRAMMING
LANGUAGE
CS-602 ASSIGNMENT 1

Priyanka Pawar
3RD Year (CSE)
171489954
Ques1: Explain language evaluation criteria?

Answer:

1. Readability:

• Overall simplicity

– A manageable set of features and constructs

– Minimal feature multiplicity (e.g., a=a+1, a+=1, a++, ++a)

– Minimal operator overloading (e.g., + for both integer and floating


point)

• Orthogonality

– A relatively small set of primitive constructs can be combined in a


relatively small number of ways to build the control and data
structure of the language

– Every possible combination is legal

Example: a language has 4 primitive data types, and 2 operators (array and
pointer), a large number of data structures can be defined.

• Data types

– Presence of adequate predefined data types.

• Syntax considerations

– Identifier forms: flexible composition

– Special words and methods of forming compound statements (e.g.,


while, class, for)

– Form and meaning: self-descriptive constructs, meaningful keywords.


2. Writability:

• Simplicity and orthogonality

– Few constructs, a small number of primitives, a small set of rules for


combining them

• Support for abstraction

– The ability to define and use complicated structures or operations in


ways that allow details to be ignored

Example: a subprogram to implement a sort program. Without abstraction,


the sort code have to be replicated in all places where it was needed.

• Expressivity

– A language has relatively convenient ways of specifying


computations, e.g., a++ is more convenient that a=a+1 in C.

3. Reliability:

• Type checking

– Testing for type errors in a given program, either by the compiler or


during program execution.

• Exception handling

– Intercept run-time errors and take corrective measures, and then


continue.

• Aliasing

– Having two or more distinct names that can be used to access the
same memory cell.

Example: two pointers set to point to the same variable.

• Readability and Writability


– A language that does not support “natural” ways of expressing an
algorithm will require the use of “unnatural” approaches, and hence
reduced reliability

– The easier a program is to write, the more likely it is to be correct

4. Cost:

• Training programmers to use the language

• Writing programs (closeness to particular applications)

• Compiling programs

• Executing programs

• Language implementation system: availability of free compilers

• Reliability: poor reliability leads to high costs

• Maintaining program.

Others:

• Portability:

– The ease with which programs can be moved from one


implementation to another

• Generality:

– The applicability to a wide range of applications

• Well-defined ness:

– The completeness and precision of the language’s official definition


Ques2: Explain characteristics of Programming language?

Answer:

 Simplicity: A good programming language must be simple and easy to learn and
use. It should provide a programmer with a clear, simple and unified set of
concepts, which can be easily grasped. The overall simplicity of a programming
language strongly affects the readability of the programs written in that language,
and programs, which are easier to read and understand, are also easier to
maintain. It is also easy to develop and implement a compiler or an interpreter for
a programming language, which is simple. However, the power needed for the
language should not be sacrificed for simplicity.
 Naturalness: A good language should be natural for the application area, for
which it has been designed. That is, it should provide appropriate operators, data
structures, control structures, and a natural syntax to facilitate the users to code
their problem easily and efficiently.
 Abstraction: Abstraction means the ability to define and then use complicated
structures or operations in ways that allow many of the details to be ignored. The
degree of abstraction allowed by a programming language directly effects its writ
ability. Object oriented language support high degree of abstraction. Hence,
writing programs in object oriented language is much easier. Object oriented
language also support re usability of program segments due to this features.
 Efficiency: Programs written in a good programming language are efficiently
translated into machine code, are efficiently executed, and acquire as little space
in the memory as possible. That is a good programming language is supported
with a good language translator which gives due consideration to space and time
efficiency.
 Structured: Structured means that the language should have necessary features
to allow its users to write their programs based on the concepts of structured
programming. This property of a moreover, it forces a programmer to look at a
problem in a logical way, so that fewer errors are created while writing a program
for the problem.
 Compactness: In a good programming language, programmers should be able
to express intended operations concisely. A verbose language is generally not
liked by programmers, because they need to write too much.
 Locality: A good programming language should be such that while writing a
programmer concentrate almost solely on the part of the program around the
statement currently being worked with.
Ques3: What are the different programming language categories?

Answer:

 Scripting:

The most basic need of for scripting languages is one which is simple to use because it
will be used by those with a minimum of programming knowledge or in situations where
cranking out code which does the job is all the matters. An example of where this
language might be used by people with more of a programming background is in web
scripting. Examples of languages that might fall into this category are PHP, JavaScript,
Perl, and Python. VB could also be considered in this family but it is too frequently used
for application development today.

There is currently no outstanding candidate language for this category. When one
is chosen I believe it should bare resemblance to the Application development language
but with more bells and whistles to let one crank things out and make it easier.

 Programmer's scripting:

Real programmers also often have a need for scripting capabilities. However, they need
a language which is simple and complete. It must never stand in there way as is all to
often the case with standard scripting languages. It must be able to easily integrate into
other languages.

Better Scheme is an excellent language for use in Programmer's Scripting. It is


simple, complete, powerful and concise. In addition many programmers are exposed to
Scheme or Lisp during their education and so are already familiar with it. One thing
which will most likely be needed is a good extension to Better Scheme which provides
solid support for object oriented programming because Better Scheme scripts will
frequently need to interact with objects created in other languages.

 Application Development:

To develop applications a language is needed which is complete and powerful but very
safe. The complexity of large application mandates a compile time safe language. It
should also be fairly high level and object oriented. The only languages which I believe
comes close to this today are Eiffel and Java.
 Low-level:

For the purpose of operating systems and other low level code we need a language
that operates fast and just above the machine level. Of course there will always be
occasion to slip into assembly but that is by its nature machine specific and so not
considered here.

Both C and C++ can be used for this. They provide the low level power needed
while giving a reasonable level of safety and abstraction.

 Pure Functional:

Certain tasks can best be done working in a purely function environment. And
these languages while not as widely used today are in many ways so distinct from
others that it is important to keep there legacy alive in the hopes that they may positively
influence more common languages. The only real example of this today is Haskell since
languages like ML are not purely functional..

 Complete Core:

This language may never be used for real programming but I still think it would be
important to have in mind. It would be a core language which the application, scripting
and pure functional languages could build on and modify. It would have everything truly
necessary and little more. One might think that the lambda calculus would be a minimal
example of this. However, it makes no provision for mutability which is clearly a key
concept to many languages. In addition the lambda calculus has no concept of types,
another important feature of modern languages. The are no examples of a complete
core language today.

Ques4: Explain stages in Translation Process?

Answer:

Language translation work done by compiler

 Structure of Compiler:

A compiler takes input as source program and produces as output an


equivalence sequence of machine instructions.

The compilation process is divided into a series of sub process called


phases. A phase is a logically cohesive operation that takes as input one
representation of source program and produce as output i.e; target
program in other representation.

 Phases of Compilation:

1. First Phase: lexical analyzer or scanner separate character of source language into a
group of logically belongs to each other. This group is called as tokens. The usual tokens
are keywords such as do or if, identifiers such as a or b, operator symbol as = + < > and
punctuation symbol as () and comma. The output is a stream of tokens pass to the rest
of phases.
2. Second Phase: the syntax analyzer or parser group tokens together into syntactic
structure for example 3 tokens as A+B group together into syntactic structure as
expression. Expression might further be combined into statement. We form a tree who's
leaf are tokens, an interior node represent string of token that logically belong together.
for example : the statement - if(5 equ max) goto 100 has 8 tokens.

3.Third Phase: intermediate code generator use the structure produced by syntax
analyzer to create a stream of simple instructions. Different style we are using like
MACROS.

4. Fourth Phase: code optimization is an optional phase design to improve the


intermediate code so that object program run faster and take less space. Its output is
also intermediate code but it saves time.

5. Fifth Phase: the final phase at code generation produce the object code by deciding
on memory location for data, selecting code and selecting register in which each
computation done.

The table management or book keeping keeps track of the name and record and all the
essential information about each of the data type. The data structure which is used to
record the information called the symbol table.

You might also like