1 / 24

Lecture 2 Concepts of Programming Languages

Lecture 2 Concepts of Programming Languages. Arne Kutzner Hanyang University / Seoul Korea. Topics. Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language Design Trade-Offs

wberger
Download Presentation

Lecture 2 Concepts of Programming Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 2Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea

  2. Topics • Reasons for Studying Concepts of Programming Languages • Programming Domains • Language Evaluation Criteria • Influences on Language Design • Language Categories • Language Design Trade-Offs • Implementation Characteristics of Languages • Significance of individual languages in 2019 Concepts of Programming Languages

  3. Reasons for Studying Concepts of Programming Languages • Improved background for choosing appropriate languages • Reduction of the risk of wrong decisions • Better use of languages that are already known • Better understanding of significance of language implementations Concepts of Programming Languages

  4. Programming Domains • Business applications • E.g. Middleware that implements some business process • Java, C++, C#, COBOL (still popular here!) • Web programming • Markup (HTML), Scripting (JavaScript (TypeScript), PHP etc.), general-purpose (e.g., Java), • General purpose applications like Photoshop, Autocad, Word etc. • Efficiency is important here • C++, C, Delphi • Systems programming / Operating System implementation • Low level, code efficiency is very important • C, Assembler • Scientific applications • E.g. Simulations; computational expensive tasks • Python, R, Fortran, (C, C++) • Artificial intelligence • C++, Python: Deep learning, TensorFlow, etc. • Older: Experimental work with languages like LISP (Scheme) and Prolog • Gaming, Embedded Systems, IoT … Concepts of Programming Languages

  5. Language Evaluation Criteria • Readability: Is this code easily readable? • Writability: Do you like this coding?++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++. • Hello World in Brainfuck (http://esolangs.org/wiki/Brainfuck) • Reliability: unexpected crashes, blue screen of death • Cost: $, €, £ … Concepts of Programming Languages

  6. Evaluation Criteria: Readability / Writability • Overall readability/writability • Are the constructs of the language self describing/intuitive/well human readable … • Syntax considerations • Special symbols and their meaning (e.g. creation of compound statements) • Special words, meaningful keywords • Data types and structures • Adequate predefined data types and structures • The presence of adequate facilities for defining new data structures Concepts of Programming Languages

  7. Evaluation Criteria: Readability / Writability • Support for abstraction • The ability to define and use complex structures or operations in ways that allow details to be ignored • Expressivity • List comprehensions (Python, Haskell) etc. • Range-based for loops Concepts of Programming Languages

  8. Evaluation Criteria: Reliability • Static type checking vs. dynamic type checking • Recognition of type errors during compile time / runtime • Exception handling • Intercept run-time errors and take corrective measures Concepts of Programming Languages

  9. Evaluation Criteria: Cost • Training programmers to use the language • Language implementation system: Costs for compilers • Reliability: poor reliability leads to high costs • Maintenance costs • Deployment costs Concepts of Programming Languages

  10. Further Evaluation Criteria … • Portability • The ease with which programs can be moved from one implementation to another • Generality • The applicability to a wide range of applications • Well-definedness • The completeness and precision of the language’s official definition Concepts of Programming Languages

  11. Influences on Language Design • Computer Architecture • Architecture as driving factor of language design. • E.g. Von Neumann Architecture • OpenCL/CUDA for computing on GPUs • Programming Methodologies • Abstract data types • Concept of object orientation • Computational models / Mathematical models for computation • Lambda Calculus, Predicate Logic Concepts of Programming Languages

  12. Von Neumann Architecture Concepts of Programming Languages

  13. Programming Methodologies History / Mainstream developments • 1950s and early 1960s: Simple applications; worry about machine efficiency • Late 1960s: People efficiency became more important; readability, better control structures • structured programming • top-down design and step-wise refinement • Late 1970s: Process-oriented to data-oriented • data abstraction • Middle 1980s: Object-oriented programming • Data abstraction + Inheritance + Polymorphism • Appearance of C++, Eiffel … Concepts of Programming Languages

  14. Imperative Languages • Characteristics: • Variables model memory cells • Assignment statements used for assigning values to memory cells • Iteration represents central concept • Inspired by von Neumann computers • Data and programs stored in memory • Memory is separate from CPU • Instructions and data are piped from memory to CPU Concepts of Programming Languages

  15. Language Categories / Families • Imperative / Object Oriented • Comprises languages that support object-oriented programming • Comprises scripting languages • Examples: C++, C, Java, C#, Python, JavaScript (TypeScript) • Markup and related • No logic, only pure descriptive: HTML, CSS, XML • Hybrids: PHP (Visualization plus logic), XSLT (XML plus logic) • Functional • Motivated by Lambda Calculus • Examples: LISP, Scheme, Haskell • Logic • Rule-based (rules are specified in no particular order) • Example: Prolog Concepts of Programming Languages

  16. Language Design Trade-Offs • Reliability vs. Cost of execution • Example: Java demands all references to array elements be checked for proper indexing, which leads to increased execution costs • Writability (flexibility) vs. Reliability • Example: C pointers are powerful and very flexible but they are unreliable Concepts of Programming Languages

  17. Implementation Characteristics of languages • Compilation • Programs are translated directly into machine language • Pure Interpretation • Programs are interpreted by an execution context known as an interpreter • Hybrids (Bytecode-based) • A compromise between compilers and pure interpreters Concepts of Programming Languages

  18. Compilation • Translate high-level program (source code) into machine code (executable file) • Phases of compilation process: • Lexical analysis: converts characters in the source program into lexical units • Syntax analysis: transforms lexical units into parse trees which represent the syntactic structure of program • Semantics analysis: generate intermediate code • Optimization: automatically apply improvements • Code generation: machine code is generated and written to "objects files" • Linking: collect "objects files" for creating an executable Concepts of Programming Languages

  19. Interpretation • Advantages: • No compilation involved • Boost portability! • Disadvantages: • Errors are recognized during runtime • No static type-check, because of the absence of compilation • Slow execution speed, if no clever just-in-time compilation is involved. • Significant in the area of Web programming: JavaScript, PHP Concepts of Programming Languages

  20. Bytecode-based Systems • A compromise between platform-specific compilation (e.g. C++) and pure interpretation • Program code is first translated to an intermediate code (called byte code) for later execution on a virtual machine • Much Faster than pure interpretation • Advantage: Portability • Examples • Java, C# Concepts of Programming Languages

  21. Bytecode-based Systems -Programming Workflow Write Source Code program text in human readable form Source Code all 5 steps of compilation Compile Source Code represents anintermediate code Byte Code using a byte-code interpreter Execute Byte Code Concepts of Programming Languages

  22. Just-in-Time Compilation • Optimization for byte-code interpretation • Instead of interpreting the byte-code the byte-code is first compiled into machine code and this machine code is executed directly on processor level • Higher performance compared to pure interpretation • JIT-compilation requires initially extra time. So, it delays code execution / program start. Concepts of Programming Languages

  23. Preprocessors • A preprocessor processes/changes source code before it is compiled • Works like a macro mechanism and implements a text to text transformation • C, C++ preprocessor • expands #include, #define, and similar macros • Not popular outside C and C++ • Main disadvantage: Compiler error messages can become quite cryptic/strange Concepts of Programming Languages

  24. Significance of individual languages in 2019 2019 Java Programming

More Related