for Robot Artificial Inteligence

38. types of Programming Paradigms

|

types of Programming Paradigms

  • Depending upon the programming language features and a particular style, the programming paradigms are grouped / classified mainly in to two categories:
    • Imperative(必要的事) paradigm
      • the programming languages are divided into different paradigms. program written in traditional language like pascal or C are imperative program that contain instructions to change program state.
      • the program variable in such language point to the memory locations and programmer can modify the contents of these variables by using assignments.
      • AN imperative program contains commands in specific order that describe how to solve a particular set of problems by describing in detail the steps that are necessary to find a solution to the program
      • imperative language being low level provides low levels of abstraction and thus relatively difficult to program
      • the imperative style uses sequence of commands. the “first do this, next do that” is a short phrase which really in a nutshell describes the spirit of the imperative paradigm
      • the basic idea in imperative programming is the command, which has a measurable effect on the program state.
    • Declarative paradigm
      • A computer is an imperative machine. the CPU reads a list of instructions and perform one operation after another. each such operation modifies the state of its register and memory.
      • imperative language work, primarily by issuing a sequence of commands.
      • imperative programs are often too low-level and over specified therefore difficult to program
      • one interesting alternative is Declarative programming, where we focus on describing a problem instead of listing the steps required to take which leads to a solution
      • in computer science, the Declarative Programming is programming paradigm which represents a writing style which is focused on describing the program logic and presents high level of abstraction. Declarative programming language are relatively easier to program
  • the features of various programming languages determine which programming paradigms they belong to and as a result, some language fall into only one paradigm whereas others fall into multiple paradigms

  • Multi-paradigm programming is a natural approach to programming. it allows to use the concepts necessary and relevant for a program.

  • there are many programming paradigms out of which the two most important programming paradigms are the procedural paradigm(Object Oriented paradigm(OOP)) and the functional programming

  • in procedural programming the problem is bifurcated(分支) in to number of small problems known as procedures/functions/methods. each of these procedures provide solution to part of the problem. these procedures can be called many times depending upon the algorithm of the program to solve a particular problem.

  • the procedural programming language are generally the first preferred choice for students to learn the computer programming.

  • some of the most popular procedural language include C, C++

  • A procedural program is written as a list of instructions, directing the computer hardware to step by step what to do

  • the program consist of the main function or program block, subroutines, functions, procedures, header files, include/modules, libraries.

  • Large programs are divided in to small function / methods procedure.
  • Uses Top-Down programming approach.
  • Data moves freely from one function to another.
  • Most of the function share common data.
  • Emphasis is given for algorithms.
  • Disadvantage
    • very difficult identify which data is used by which function. Error Correction is difficult.

  • in computer science, the functional programming is a Declarative programming paradigm. the functional programming is a style of building a structure and elements of computer program that treats computer program as evaluation of mathematical functions and avoid changing the state and mutable data.

Comments