Wednesday, January 30, 2013


Questions:
  1. What are the different types of language paradigms? Explain each.
           
            Answer:
                        There are four main paradigms: object-oriented, imperative, functional and logic programming.
a)      Object-oriented programming (OOP) is a programming paradigm that represents concepts as "objects" that have data fields (attributes that describe the   object) and associated procedures known as methods. Objects, which are          instances of classes, are used to interact with one another to design applications      and computer programs.

b)      Imperative programming is a programming paradigm that describes          computation in terms of statements that change a program state. In much the same    way that imperative mood in natural languages expresses commands to take          action, imperative programs define sequences of commands for the computer to           perform.

c)      Functional programming is a programming paradigm that treats computation       as the evaluation of mathematical functions and avoids state and mutable data. It      emphasizes the application of functions, in contrast to the imperative          programming style, which emphasizes changes in state.

d)     Logic programming is one of the 4 main programming paradigms. Its theory        of computation is based on first order logic. Programming languages such as   Prolog and Data log implement it.
           
  1. What are the different features of programming language? Explain each.
      Answer:
The different features of programming language are comments, statement and expression, Flow control, Explicit loops, Implied loops, Conditionals, Subprograms, Functions and subroutines, Global variables, Bit Functions, Exception Controls, Interface Prototype, Character and strings, User Defined Data types, Overloading Operators, User-defined Operators, Pointers and Targets, Pointer Type Declaration, Pointer Assignment, Using Pointers in Expressions, Pointers and Linked Lists, Accessing External Source Files and Functions, Procedural Applications, Fitting Curves to Data, Sorting.


Every programming language has core features. These features have evolved over a period, depending on the purpose the languages were created for and the market they targeted. All programming languages have common core set of common features. Implementation of these core set of features varies from language to language. The history of the language will give us an idea of the market the languages were intended for.


Here is a list of the common features:
·         A place for storing data. Arrays are advanced storing data facility. Also known as data structures.
·         Rules for writing programs in that programming language

·         Control statements – which are building blocks for logic implementation. (e.g. Repetition control, conditional statements)

·         Most programming languages of today support OOP. These are some of the features of OOP- Class declaration, objects, inheritance, polymorphism, overloading and constructors are included.

·         Every language has operators. Such as Mathematical operators and logic operators.

·         All languages include facility to write programs, functions and procedures.

·         Functions return values after execution, whereas procedures simply execute programs.

·         All programs include facility to write libraries. Libraries are themselves programs, which can be used in other programs.

·         All languages support exception handling. This feature is helpful to identify errors and generate appropriate messages.

·         All languages include built in functionalities, provided as classes and functions. These classes help to write better programs.

·         All languages include a compiler and memory handling features. These are implemented in different ways by the person (s) who have developed the language.

  1. What are the different criteria to be considered in choosing a programming language?
      Explain each?

            Answer:
In choosing a programming language to be used in development, a software developer must make several of decisions. Sometimes it’s about which language is best for a job. That is actually one of the most critical pieces of getting a project right. Too often, languages are applied to a problem space where another language would be better. I would say there is no definite one programming language that can be use, that depends on where to use the programming language. For example,
The financial sector benefits from a number of languages. One of the key features for calculations is functional programming characteristics. When processing math based on financial calculations, functional paradigms often provide substantive performance benefits. Another key need in the financial sector is languages that benefit from object-oriented paradigms with strong architectural patterns backed by a lot of guidance from the organizations around the languages. That's why a lot of financial institutions have the majority of their applications written in the Java and C# languages. These languages provide maintainable options that a lot of other languages can't do as well. On Scientific Research and academia require languages that support highly accurate mathematics, extremely fast execution, and a focus around the implementation of the language versus any specific organizational characteristics like object orientation. Because of these needs, the academic and scientific communities often use C/C++ for mathematical calculations, C++ for heavy processing, and even Python to accomplish their tasks. Since most of the tasks are much more focused around single outcomes, these languages are an easy choice in most of these environments.

  1. Compare and contrast primitive data types and structured data types.
Answer:

A data type tends to mean a primitive data type. Primitive data are built-in data types, such as integers, characters and Booleans. They are basic constructs of the language that is, they are built into the language. Primitive data also tends to be of a strict data type, meaning you can't treat characters like integers or Booleans like integers, etc., although some languages will support implicit casting of primitive data types  Abstract data types are generally constructed by the user or by a higher level language. For example, you might create a currency data type, which generally acts like a float but always has a precision of 2 decimal places and implements special rules about how to round off fractions of a cent. Abstract data types also often contain the ability to either be treated as a specific type of primitive data in certain circumstances (for example, many languages allow you to treat strings as character arrays); or contain certain rules / methods to manipulate their data (such as a programming language allowing you to cast a float as an integer).

A data structure is a gathering together of many different data types. For example, objects and arrays are data structures. Data structures usually can contain information of many different types (such as strings, integers, Booleans) at the same time, and in more complex structures -- namely, classes -- can contain specific methods, properties and events to manipulate that data, change its type.

  1. Compare and contrast imperative and declarative languages.
      Answer:    
Imperative programming is a programming paradigm that describes computation in terms of statements that change a program state. In much the same way that imperative mood in natural languages expresses commands to take action, imperative programs define sequences of commands for the computer to perform. Procedural programming is imperative programming in which the program is built from one or more procedures (also known as subroutines or functions). The terms are often used as synonyms, but the use of procedures has a dramatic effect on how imperative programs appear and how they are constructed. Heavily procedural programming, in which state changes are localized to procedures or restricted to explicit arguments and returns from procedures, is known as structured programming. From the 1960s onwards, structured programming and modular programming in general have been promoted as techniques to improve the maintainability and overall quality of imperative programs. Object-oriented programming extends this approach.

Declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow. Many languages applying this style attempt to minimize or eliminate side effects by describing what the program should accomplish, rather than describing how to go about accomplishing it. This is in contrast with imperative programming, in which algorithms are implemented in terms of explicit steps. Declarative programming is often defined as any style of programming that is not imperative. A number of other common definitions exist that attempt to give the term a definition other than simply contrasting it with imperative programming

  1. Give at least five examples for imperative languages and define its features.
               Answer:

All modern imperative languages can trace their origins back to three imperative languages: FORTRAN, ALGOL 60 and COBOL. Consequently these influential languages are often described as foundation languages.
FORTRAN The IBM Mathematical FORmula TRANslating system.
·         Designed circa 1955 (by, amongst others, Backus).
·         First successful attempt to improve on "assembly languages".
·         Still widely used for numerical applications.
·         Has been revised to take account of ideas on structured programming, however is decreasing in popularity.
ALGOL 60 ALGOrithmic Language 1960.
·         Developed in 1950s through a joint European-American committee.
·         First block structured language.
·         First language whose syntax was defined using BNF.
·         Direct ancestor of most modern imperative languages.
COBOL COmmon Business Oriented Language.
·         Developed in 1950s through a committee consisting mainly of US computer manufacturers.
·         Designed to process large data files and is therefore the most extensively used language for data processing.
·         Since its initial introduction the language has remained broadly unchanged.
Feature of Imperative languages
They are usually "typed". Broadly we can identify two categories of imperative data type:
Basic data types.
Compound data types.
Components comprise:
Data declarations.
Expressions which yield values.
statements which carry out some operation, e.g. assignment statements, conditional statements, program constructs.
I/O and error handling mechanisms.
A method of grouping all of the above into a complete program - (program composition).

  1. Give at least five examples for declarative languages and define its feature.
      Answer:
                  Declarative languages, also called nonprocedural or very high level, are programming languages                      in which (ideally) a program specifies what is to be done rather than how to do it. In such                                           languages there is less difference between the specification of a program and its implementation                             than in the procedural languages described so far. Common declarative languages include those                            of database query languages (e.g., SQL, XQuery),                      regular expressions, logic                                programming, and functional programming.

            Logic programming
                  Logic programming languages such as Prolog state and query relations. The specifics of how                           these queries are answered is up to the implementation and its theorem prover, but typically take                   the form of some sort of unification  
                   Domain-specific languages
            Some well-known examples of declarative domain-specific languages (DSLs) include the yacc             parser generator input language, the Make build specification language, Puppet's configuration             management language, regular expressions, and a subset of SQL (SELECT queries, for     example).
            Functional programming
            Functional programming, and in particular purely functional programming, attempts to minimize   or eliminate side effects, and is therefore considered declarative. Most functional languages, such     as Scheme, Clojure, OCaml, Standard ML, and Unlambda, however, do permit side effects in             practice.
.


No comments:

Post a Comment