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.

Comment  Read more

37.Programming Paradigms

|

Defining a program

  • paradigm : approach to solve the program
  • algorithm : step by step methodology to solve the problem
  • Semantics : Meaning of the program
  • Syntax : programming language rules to construct the program statements.

  • the software applications are designed to solve a particular problem
  • For example : A railway reservation system is designed to solve the railway ticket reservation problem for the customers and for the railway administration. the problem solved are :
    • ticket reservation by customers.
    • ticket rescheduling & Cancellation
    • Railway Resources Managements
  • A program is a set of instructions that directs a computer in terms of sequential programming instructions to execute specific operations and provide a desired output as a solution to a particular problem.

  • A computer software can be designed using any programming language. the choice of programming language depending upon the solution requirements.

  • A programming paradigm is a framework that defines how the programmer can conceptualize and interpret complex problem to be solved.

  • A programming paradigm is a particular style or “way” of writing and organizing a program code

  • there are a number of alternative approaches to the programming process and these approaches are referred to as programming paradigms

  • Different paradigms represent fundamentally different approaches to building solution to specific types of problems using programming as a tool.

  • most programming languages fall under one paradigm, but some programming language have elements of multiple paradigms

  • in general, the programming paradigms influence language design especially the manner in which program code is organized.

  • the features of various programming languages determine which programming paradigms they belong to and as a result, some language fall into only one paradigm, while other fall into multiple paradigms.

  • Multi-paradigm programming supports core concepts of more than one paradigm and therefore offers more functional convenience to the programmer while coding a program.

Comment  Read more

36. Platform in Computer Science

|

Platform in Computer Science

  • the compiler produces an executable file as an output which can be executed by the computer’s CPU. however, an executable file can run only on certain combination of operating system and processor’s inbuilt instruction set architecture for which the program has been compiled. that is the reason why we need to choose the operating system (32bit or 64bit) when we install a language compiler on the computer system.

  • A CPU is the brain of the computer system. the microprocessor can interpret and execute the program instructions only in binary code as per the instruction set architecture of the processor.

  • therefore, A microprocessor specific compiler is required to compile the program written in any higher level language which generates the executable code for a specific computer system configurations.

  • Each CPU’s internal design is based on some standard micro architecture which is implemented by the processor manufacturing companies which is known as “Instruction Set Architecture(ISA)”

  • AN instruction is a binary pattern design inside a CPU to perform a specific operation.

  • the entire group of instruction that is implemented and supported by the microprocessor is called as “Instruction Set”. for example ISA 8085 has 246 instructions.

<a href=https://postimg.cc/XpSTBP6D”>

  • Each program must be first compiled to generate a machine code in binary which computer’s CPU can interpret and execute as per the CPU’s instruction set architecture.

  • the compiler generates an executable machine code which can be executed only on certain combination of operating system and the processor architecture. this combination of operating system and processor is jointly referred as platform. therefore, a compiler always generates a platform specific machine code.

  • A platform is defined as a runtime environment jointly provided by the computer hardware(processor) and the operating system on which a applications / process can run

  • the application programs are developed and compiled to create an executable file which is a platform dependent. such application program will run only on computer systems which represents the same platform configuration for which the application program has been compiled.

Comment  Read more

35. Program Compilation Step by step

|

Program Compilation Step by step

Assembly Language - Mnemonic(助记符号)

Comment  Read more

34. Machine code instruction and linking

|

Machine code instruction.

  • A modern-day computers are “digital machines” and computer hardware has been designed to handle and process data only in digital form. Every computer system has a microprocessor which acts as brain of computer system. the processor is the main components in computer system which performs all the calculations and logical operations.

  • the program code which computer’s CPU can directly interpret and execute without any need for conversion or translation is referred as machine code or machine language. A CPU can understand and execute instructions only in machine langue.

  • A machine code is not considered to be human readable but it is considered as machine readable because it only contains sequence or patterns in binary

  • A compiler convert the program source doe into its equivalent machine code in binary which is referred as object code.

  • the main purpose of the compilation process is to create a stand alone executable file which can run on a specific platform for which it has been compiled.

Program compilation

  • the process of converting the program source code written in high level programming language into the machine code executable file is generally referred as compilation. however, the compiler only converts source code in to Object code which consist of machine instructions in binary. A compiler may produce more than one object code files after the compilation.

  • the compiler only convert the source code into the Object code. the Object code cannot be directly executed by the operating system. the Object code file needs to be further processed by another program called “Linker” which is built into the compiler.

  • the compiler may produce number of object code files for a single source code file. the object code consist of machine code instructions in binary which is equivalent of corresponding high level program instructions in program source file. therefore, linking is need to link all object code files and other files together to create an “Executable” file.

Linking

  • the large computer programs are organized in number of files. the user defined functions are written in a separate files. the files are tied to the main program file in the header section such as #include in C langue.

  • Similarly, the programming language also provides library of standard functions in precompiled object code format which programmer can readily use to simplify the programming jobs.

  • the programmer can use these user defined functions and standard function library by simply including these files in the beginning of the program header section. since the standard library code is in the object code form which is a precompiled format and can be directly included in the linking stage by the linker while creating an executable file during the program compilation process.

  • the Linker plays a crucial role in software development because it allows sperate compilation of program modules. instead of organizing a large application as one monolithic source file, we can split the program it into smaller files which are more manageable modules that can be easily modified and compiled separately.

  • the modular approach has many advantages. if we change one of these module, we need to simply recompile and re-link only one module that has changed. No need to recompile the entire program.

  • the linking is a final stage of the compilation process in which multiple Object code files, other reference and library references are linked together to create a single “Executable” file.

  • the linker is also just another program. Linker reads in several files, the object file that was generated by the compiler and one or more library files. in the linking step the library references are taken care of

  • the compiler while compiling doesn’t resolve the library references. all the library references are resolved at the linking stage by the linker.

  • Every time linker finds a reference to a library routine in the object file, it reads the library files, then find that routine and replaces the programmer’s reference with the actual code for the routine from the library file. after it has replaced all the references with actual code from the library, the linker then creates an executable binary file which can be executed by OS

Comment  Read more