IIntroduction to Programmming Language

25

description

IIntroduction to Programmming Language

Transcript of IIntroduction to Programmming Language

  • by Bernard D. Otero

  • is a set of rules that provides a way of telling a computer what operations to perform.is a set of rules for communicating an algorithmIt provides a linguistic framework for describing computations

  • A programming language is a notational system for describing computation in a machine-readable and human-readable form.

  • English is a natural language. It has words, symbols and grammatical rules.A programming language also has words, symbols and rules of grammar.The grammatical rules are called syntax.Each programming language has a different set of syntax rules.

  • Loops are used to repeat a block of codethe syntax for a for loop in C language is

  • Programming languages have evolved over time as better ways have been developed to design them.First programming languages were developed in the 1950sSince then thousands of languages have been developedDifferent programming languages are designed for different types of programs.

  • High-level programclass Triangle { ... float surface() return b*h/2; }Low-level programLOAD r1,bLOAD r2,hMUL r1,r2DIV r1,#2RETExecutable Machine code0001001001000101001001001110110010101101001...

  • First Generation LanguagesSecond Generation LanguagesThird Generation LanguagesFourth Generation LanguagesFifth Generation Languages

  • The first generation of programming language, or 1GL, is machine language.Machine language is a set of instructions and data that a computer's central processing unit can execute directly. Machine language statements are written in binary code, and each statement corresponds to one machine action.

  • The second generation programming language, or 2GL, is assembly language.Assembly language is the human-readable notation for the machine language used to control specific computer operations. An assembly language programmer writes instructions using symbolic instruction codes that are meaningful abbreviations or mnemonics.

  • An assembler is a program that translates assembly language into machine language.

  • Assembly language example

    When the above code is compiled and executed, it produces the following result:

  • Closer to English but included simple mathematical notation.Programs written in source code which must be translated into machine language programs called object code.The translation of source code to object code is accomplished by a machine language system program called a compiler.

  • Alternative to compilation is interpretation which is accomplished by a system program called an interpreter.Common third generation languagesFORTRANCOBOLC and C++Visual Basic

  • /* Hello World program in C Language*/

  • A high level language (4GL) that requires fewer instructions to accomplish a task than a third generation language.Used with databasesQuery languages (SQL,MYSQL,POSTRGRES)Report generatorsForms designersApplication generators

  • /* Query to display subjects from the database in MYSQL */

  • Declarative languagestelling the "machine"1 what you would like to happen, and let the computer figure out how to do it.Logic: PrologBased on mathematical logicRule- or Constraint-based

  • Family Example (descendants) in PrologThe goal descendant(X,Y) is true if Y is a descendant of X.descendant(X, Y) :- offspring(X, Y).descendant(X, Z) :- offspring(X, Y), descendant(Y, Z).offspring(abraham, ishmael).offspring(abraham, isaac).offspring(isaac, esau).offspring(isaac, jacob).

    If for example the query

    | ?- descendant(abraham, X).

    is executed, Prolog's backtracking results in different descendants of Abraham being returned as successive instances of the variable X, i.e.X = IshmaelX = IsaacX = esauX = jacob

  • Scripting LanguagesJavaScript and VBScriptPhp and ASPPerl and PythonCommand Languagessh, csh, bashText processing LanguagesLaTex, PostScript

  • HTMLHyperText Markup Language.Used on the Internet and the World Wide Web (WWW).Web page developer puts brief codes called tags in the page to indicate how the page should be formatted.

  • XMLExtensible Markup Language.A language for defining other languages.

    ******************