230 likes | 581 Views
High-level Programming Languages. Joshua 5D(9). Advantages for using high-level Programming Languages. Instructions are more English-like (Easier for human to understand and learn) A single instruction can define many operation at the machine level (Shorten the length of code to type).
E N D
High-level Programming Languages Joshua 5D(9)
Advantages for using high-level Programming Languages • Instructions are more English-like(Easier for human to understand and learn) • A single instruction can define many operation at the machine level(Shorten the length of code to type)
Disadvantages for using high-level Programming Languages • Required to converted to machine languages before execution
Third-generation Languages(3GL) • 3GLs are procedural languages (step-by-step ) • For business (COBOL) • For beginners (BASIC, Pascal) • For scientific purpose (FORTRAN) • For Server-side program (PHP) • Most popular and multipurpose (C language)
Third-generation Languages(3GL) • COBOLADD YEARS TO AGE • Pascalage := age + years • C languageage += years
Fourth-generation Languages(4GL) • 4GLs are declarative languages(Much closer to the natural languages) • Designed for solving specific problems • For Database management system (DBMS) :FoxPro, DBase, Structured Query Language (SQL)
Fourth-generation Languages(4GL) More English like DBMS platform is provided and so 4GL can be easily written and run on it
3GL and 4GL • 3GL development methods are slow and error-prone (easy to make error) • Some applications could be developed more rapidly by adding a higher-level programming language and methodology which would generate the equivalent of very complicated 3GL instructions with fewer errors • 4GL projects are more oriented toward problem solving and systems engineering
3GL and 4GL • All 4GLs are designed to reduce programming effort, the time it takes to develop software • Also, 4GL is design for people with little programming knowledge instead of a programmer to write the program • it is impossible to frequently ask for a programmer to develop a function for a specific searching purpose
3GL and 4GL • 4GL are not always successful in this task, sometimes resulting in worse code • Like using SQL for calculating complex number • However, given the right problem, the use of an appropriate 4GL can be successful
Fifth-generation Languages(5GLs) • Logic programming • A declarative language to develop artificial intelligence (AI) programs and expert systems • Prolog, LISP
Fifth-generation Languages(5GLs) • Example: Prolog • Two types of clauses: Facts and Rules • Facts: cat(tom). There is a cat call Tom. • Rule: cat(tom) :- true. There is a cat call Tom is ture.
Fifth-generation Languages(5GLs) • Given the above fact, one can ask:is tom a cat??- cat(tom). Yes • what things are cats??- cat(X). X = tom
Compiler • A program that translates the whole high-level program into a machine program, which can be executed independently. • Different programming language have different compiler.
Compiler Compiler Editor Analyzes the language statements syntactically one by one Enter the codes Build the output code (object code /object module) in machine language Save the file (Source Program)
Interpreter • Translates and executes one instruction at a time • Execution speed is slower because it takes time to translate the instruction during execution • No object program is generated. The source is needed every time for execution.
Interpreter • Can immediately execute high-level program • Test the part of program you wants quickly without compilation of the whole program
Interpreter Translates one instruction from source file executes the instruction
Java • If a Java .class program (compiled) is downloaded from a web page, it will be interpreted by the virtual machine (a plug-in installed in the browser as an interpreter) • This can make Java cross platform
Java Server client Enter the Java codes Download the Java .class program Compiled it to a Java .class program Interpreted by virtual machine (Different OS, different plug-in ) Execute the interpreted program