language evaluation
play

Language Evaluation Writability Reliability Cost COS 301 Summary - PowerPoint PPT Presentation

P rogramming L anguages Language Evaluation COS 301 Readability Language Evaluation Writability Reliability Cost COS 301 Summary School of Computing and Information Science University of Maine Fall 2018 COS 301 Language Evaluation


  1. P rogramming L anguages Language Evaluation COS 301 Readability Language Evaluation Writability Reliability Cost COS 301 Summary School of Computing and Information Science University of Maine Fall 2018 COS 301 Language Evaluation

  2. P rogramming Outline L anguages Language Evaluation COS 301 Readability 1 Readability Writability Writability 2 Reliability Cost Summary Reliability 3 Cost 4 Summary 5 COS 301 Language Evaluation

  3. P rogramming Language evaluation criteria L anguages Language Evaluation Readability COS 301 Writability Readability Writability Reliability Reliability Cost Cost Summary COS 301 Language Evaluation

  4. P rogramming L anguages Language Evaluation COS 301 Readability Writability Reliability Readability Cost Summary COS 301 Language Evaluation

  5. P rogramming Readability L anguages Language Evaluation Early (pre-1970s): more important for machine to “read” COS 301 code easily Readability After: realized SW maintenance cost ≫ development cost Writability ↑ Memory helped ↑ readability: Reliability Cost Compilers/interpreters need system memory Summary Ones for more readable languages can be large Aspects of readability: Simplicity Orthogonaility Syntax COS 301 Language Evaluation

  6. P rogramming Simplicity L anguages Language Evaluation ↑ Size of language feature set ⇒ ↓ readability COS 301 Subsets: Readability Can ↓ readability Writability E.g., writer & reader familiar with different ones Reliability Cost Canonical features vs feature multiplicity: Summary i=i+1; i++; ++i; i+=1; i=+1; Operator overloading ⇒ ↓ readability E.g., + for floating point, integer, string concatenation ⇒ j = "hi" + 4; Especially confusing: user-defined overloading COS 301 Language Evaluation

  7. P rogramming Orthogonality L anguages Large feature set or small “primitive” constructs that can be Language Evaluation combined? COS 301 Canonical: one and only one way to express something Primitive constructs all treated alike Readability All combinations legal with all constructs Writability All combinations behave same way Reliability More canonical ⇒ ↑ readability Cost Example: Summary IBM instruction set had 2 opcodes for addition (reg–reg, reg–mem) DEC VAX had one Non-orthogonality in C C functions: can return struct but not array Struct member: can be anything except void or struct of same type Array elements: can be any data type except void or function Parameters: passed by value. . . except arrays COS 301 Language Evaluation

  8. P rogramming Syntax L anguages Language Evaluation Identifiers impact readability COS 301 Length Readability Characters allowed Writability Compound statement syntax: Reliability Cost Deeply-nested {} (C-like) or () (Lisp-like) Summary Deeply-indented Python code Choice of delimiters (spaces in Python, e.g.) Different meaning for same keyword ⇒ ↓ readability static used inside C function → variable retains memory/value across function invocations static used outside C function → variable/function visible only within same file COS 301 Language Evaluation

  9. P rogramming L anguages Language Evaluation COS 301 Readability Writability Reliability Writability Cost Summary COS 301 Language Evaluation

  10. P rogramming Writability L anguages Language Evaluation How easy is it for a programmer to write a program? COS 301 Could depend on purpose, level of language: e.g., C vs Readability Python for Writability writing a graphics-intensive game Reliability writing an embedded controller Cost Summary Also depends on: Simplicity and orthogonality Support for abstraction Expressivity COS 301 Language Evaluation

  11. P rogramming Simplicity/orthogonality L anguages Language Evaluation Generally ↑ writability COS 301 Large feature set, non-orthogonality may ⇒ accidental use Readability of unknown/inappropriate features Writability E.g., C++ Reliability Cost cout « (1 «2); Summary cout « 1 « 2; COS 301 Language Evaluation

  12. P rogramming Simplicity/orthogonality L anguages Language Evaluation Generally ↑ writability COS 301 Large feature set, non-orthogonality may ⇒ accidental use Readability of unknown/inappropriate features Writability E.g., C++ Reliability Cost cout « (1 «2); ⇒ prints 4 (2 0 shifted 2 times = 2 2 ) Summary cout « 1 « 2; COS 301 Language Evaluation

  13. P rogramming Simplicity/orthogonality L anguages Language Evaluation Generally ↑ writability COS 301 Large feature set, non-orthogonality may ⇒ accidental use Readability of unknown/inappropriate features Writability E.g., C++ Reliability Cost cout « (1 «2); ⇒ prints 4 (2 0 shifted 2 times = 2 2 ) Summary cout « 1 « 2; ⇒ prints 12 COS 301 Language Evaluation

  14. P rogramming Abstraction L anguages Abstraction allows treating complex structures/operations as Language Evaluation “black boxes” COS 301 Support for abstraction ⇒ ↑ writability Readability Procedural abstraction: Writability Output specified in terms of its relationship to inputs Reliability only Cost Internals of procedure are opaque Summary E.g.: sin() , cos() , user-defined procedures, etc. Data abstraction: Use representation of data appropriate for problem, regardless of implementation An interpretation of the underlying bits E.g.: floating point instead of bits arrays instead of contiguous integers objects user-defined data types COS 301 Language Evaluation

  15. P rogramming Expressivity L anguages Language Evaluation Can language express what is needed for problem? COS 301 Does language have convenient ways to specify operations? Readability Writability ↑ Number, power of operators ⇒ ↑ expressivity Reliability ↑ Number predefined functions ⇒ ↑ expressivity Cost E.g.: Summary COBOL: lots of operations for different file types APL: lots of math operations, convenient for mathematicians COS 301 Language Evaluation

  16. P rogramming L anguages Language Evaluation COS 301 Readability Writability Reliability Reliability Cost Summary COS 301 Language Evaluation

  17. P rogramming Reliability L anguages Language Evaluation Is the program produced by the language reliable? COS 301 Reliability: Readability safety Writability correctness Reliability Cost Language features: Summary type checking exception handling aliasing readability/writability interactions COS 301 Language Evaluation

  18. P rogramming Type checking L anguages Language Evaluation Type checking: insuring that COS 301 operands compatible with operator Readability data compatible with variables Writability variables compatible with variables Reliability arguments compatible with formal parameters Cost Compile-time or runtime? Summary Runtime checking: expensive (e.g., C, etc.: none) Compile-time checking: may ↓ writability (e.g., Python, Lisp: little → none) Strong, compile-time type checking ⇒ ↑ reliability, ↑ readability Runtime type casting (Python, Lisp, others) ⇒ ↑ writability, ↓ reliability COS 301 Language Evaluation

  19. P rogramming Exception handling L anguages Language Evaluation Ways to handle runtime errors COS 301 Most languages have some way of handling exceptions Readability Writability Some don’t (e.g., C) Reliability Security, correctness impacted by lack of exception handling Cost Summary COS 301 Language Evaluation

  20. P rogramming Aliasing L anguages Language Two more more names for or pointers to same thing Evaluation COS 301 memory location (e.g., pointer, name) object (reference, name) Readability Writability Aliasing ⇒ ↓ reliability Reliability Most languages suffer from this Cost pass-by-reference parameters Summary assigning references to multiple variables assigning pointers to multiple variables pointer computation arriving at same values Problem: multiple accesses to same location/object May not be obvious: change one, other “magically” changes Could lead to race conditions (in shared, multiprogramming environment) COS 301 Language Evaluation

  21. P rogramming Readability/writability interactions L anguages Language Evaluation Lack of expressiveness in language ⇒ unnatural/convoluted COS 301 algorithms and programming Readability Leads to ↓ reliability, ↓ readability Writability Poor readability itself ⇒ ↓ reliability Reliability Cost ↓ readability makes it hard to catch/fix bugs, logic errors Summary E.g.: APL, Perl – facetiously: “write-only” languages C: “R2D2’s diary” COS 301 Language Evaluation

  22. P rogramming L anguages Language Evaluation COS 301 Readability Writability Reliability Cost Cost Summary COS 301 Language Evaluation

  23. P rogramming Cost L anguages Not what a compiler costs – most are free anyway Language Evaluation Cost includes COS 301 Time costs Readability Writability Reliability Cost Summary Direct monetary costs Other COS 301 Language Evaluation

Recommend


More recommend