Wednesday, January 30, 2013


Questions:
  1. What are the benefits of the following languages:
    1. Data Oriented Language

Answer:
Data oriented programming is simply a programming language with database, you can create tables and queries, and program to manipulate the stored data on it, example of data oriented language are SQL, DBase and Visual Foxpro.
The benefits of data oriented language are languages provide powerful ways of searching and manipulating the relations that have been described as entity relationship tables which map one set of things into other sets.

    1. Object Oriented Language

Answer:
Object-oriented languages help to manage complexity in large programs. Objects package data and the operations on them so that only the operations are publicly accessible and internal details of the data structures are hidden. This information hiding made large-scale programming easier by allowing a programmer to think about each part of the program in isolation
The benefits of object oriented language are object inheritance, Encapsulation, Polymorphism, and Simulation.

    1. Event-driven Language

Answer:
Event-driven programming or event-based programming is a programming paradigm in which the flow of the program is determined by events. For example sensor outputs or user actions  such as mouse clicks or key presses or messages from other programs or threads. Event driven programming is greatly beneficial because of how user friendly it makes computer applications. It means that almost everyone can operate these systems without the need for expert knowledge on computer programming code such as SQL and Visual Basic.

    1. Logical Language

Answer:

Abductive Logic Programming is an extension of normal Logic Programming that allows some predicates, declared as adducible predicates, to be incompletely defined. Problem solving is achieved by deriving hypotheses expressed in terms of the adducible predicates as solutions of problems to be solved. Because mathematical logic has a long tradition of distinguishing between object language and meta   language, logic programming also allows meta   level programming. Constraint logic programming is an extension of normal Logic Programming that allows some predicates, declared as constraint predicates, to occur as literals in the body of clauses. Concurrent constraint logic programming combines concurrent logic programming and constraint logic programming, using constraints to control concurrency. Basing logic programming within linear logic has resulted in the design of logic programming languages that are considerably more expressive than those based on classical logic.

  1. Give at least three programming language used for the following paradigms:
    1. Procedural Programming

                        Answer:
                        A list of instructions telling a computer, step-by-step, what to do,                                        usually having a linear order of execution from the first statement                                        to the second and so forth with occasional loops and branches. Procedural                             programming languages include C, C++, Fortran, Pascal, and BASIC.

    1. Functional Programming
           
                        Answer:
                        functional programming is a programming paradigm that treats                                            computation as the evaluation of mathematical functions and avoids state                           and mutable data. The prominent                         functional programming                                  languages such as Common Lisp,                                                                                           Scheme, ISLISP, Clojure, Racket, Erlang, OCaml, Haskell, Scala and F#.                         

    1. Object Oriented Programming

      Answer:
      Some of the most commercially important object-oriented    languages are   Visual Basic.NET (VB.NET) and C#, both   designed for    Microsoft's      .NET platform, and Java, developed by Sun       Microsystems.

    1. Logic Programming
     
      Answer:
      Prolog is a general purpose logic programming language       associated        with artificial intelligence and computational linguistics.      Datalog is a     truly declarative logic programming language that       syntactically is a          subset of Prolog. It is often used as a query language for      deductive       databases : it has a cleaner syntax and is more expressive than          SQL.

  1. Give at least five reasons of using the following paradigms:
    1. Procedural Programming
Answer:
Procedures, also known as routines, subroutines, methods, or functions (not to be confused with mathematical functions, but similar to those used in functional programming), simply contain a series of computational steps to be carried out. Any given procedure might be called at any point during a program's execution, including by other procedures or itself. A list of instructions telling a computer, step-by-step, what to do, usually having a linear order of execution from the first statement to the second and so forth with occasional loops and branches.

    1. Functional Programming
                       
                        Answer:
                        Functional programming has long been popular in academia, but with few                          industrial applications. However, recently several prominent functional                                   programming               languages have been used in commercial or                                            industrial systems. For example, the Erlang programming language, which                      was developed by the Swedish company Ericsson in the late 1980s, was                             originally used to implement fault-tolerant telecommunications systems. It              has since become popular for building a range of applications at                                                companies such as T-Mobile, Nortel, Facebook and EDF

    1. Object Oriented Programming
     
      Answer:
      In OOP, each object is capable of receiving messages,          processing       data, and sending messages to other objects. Each object can be viewed as             an independent "machine" with a distinct role or responsibility. The actions (or "methods") on these objects are closely associated with the       object. For example, OOP data structures tend to "carry their own   operators around with them" (or at least "inherit" them from a similar         object or class) - except when they have to be serialized. object-oriented     programming has become especially popular in dynamic programming         languages. Python, Ruby and Groovy are dynamic languages built on OOP             principles, while Perl and PHP have been adding object oriented features    since Perl 5 and PHP 4, and ColdFusion since version 5. Objects are key         to understanding object-oriented technology. Look around right          now and you'll find many examples of real-world objects: your dog, your desk, your television set, your bicycle.

    1. Logic Programming
      Answer:
Logic languages, as their name suggests, rely on logic to provide the framework for their meaning. Logic itself was invented as an aid to human thought, allowing knowledge to be set out and reasoned about. It would therefore seem natural to attempt to use it in programming computers. In practice, first order predicate calculus is used, or at least a subset of it. It is not necessary to understand predicate calculus before learning a logic programming language. Indeed, this course takes the view that it is better to learn Prolog, a practical example of a logic programming language, before learning about the underpinning of theory.
                        Logic programming has many application areas:
·         Relational Data Bases
·         Natural Language Interfaces
·         Expert Systems
·         Symbolic Equation solving
·         Planning
·         Prototyping
·         Simulation
·         Programming Language Implementation

     


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-deļ¬ned 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.
.