Difference between revisions of "Multi-Paradigm Programming and Scripting"

From Sinfronteras
Jump to: navigation, search
(Languages evaluation Criteria)
(Languages evaluation Criteria)
Line 65: Line 65:
 
|- style="vertical-align:top;"
 
|- style="vertical-align:top;"
 
|
 
|
*This refers to the ease with which programs (in the language under consideration) can be understood. This is especially important for software maintenance.
+
This refers to the ease with which programs (in the language under consideration) can be understood. This is especially important for software maintenance.
  
:*Simplicity:
+
*Simplicity:
:*Orthogonality:
+
*Orthogonality:
:*Data Types:
+
*Data Types:
:*Syntax Design:
+
*Syntax Design:
  
  
 
|
 
|
*This is a measure of how easily a language can be used to develop programs for a chosen problem domain.
+
This is a measure of how easily a language can be used to develop programs for a chosen problem domain.
  
:*Simplicity and Orthogonality:
+
*Simplicity and Orthogonality:
:*Support for Abstraction:
+
*Support for Abstraction:
:*Expressivity:
+
*Expressivity:
  
  
 
|
 
|
*This is the property of performing to specifications under all conditions.
+
This is the property of performing to specifications under all conditions.
  
:*Type Checking:
+
*Type Checking:
:*Aliasing:
+
*Aliasing:
  
  
 
|
 
|
*The following contribute to the cost of using a particular language:
+
The following contribute to the cost of using a particular language:
  
:*Training programmers: cost is a function of simplicity of language
+
*Training programmers: cost is a function of simplicity of language
:*Writing and maintaining programs: cost is a function of readability and writability.
+
*Writing and maintaining programs: cost is a function of readability and writability.
:*Compiling programs: for very large systems, this can take a significant amount of time.
+
*Compiling programs: for very large systems, this can take a significant amount of time.
:*Executing programs: Having to do type checking and/or index-boundary checking at run-time is expensive. There is a tradeoff between this item and the previous one (compilation cost), because optimizing compilers take more time to work but yield programs that run more quickly.
+
*Executing programs: Having to do type checking and/or index-boundary checking at run-time is expensive. There is a tradeoff between this item and the previous one (compilation cost), because optimizing compilers take more time to work but yield programs that run more quickly.
:*Language Implementation System: e.g., Java is free, Ada not
+
*Language Implementation System: e.g., Java is free, Ada not
:*Lack of reliability: software failure could be expensive (e.g., loss of business, liability issues)
+
*Lack of reliability: software failure could be expensive (e.g., loss of business, liability issues)
  
  
 
|
 
|
:*Portability: the ease with which programs that work on one platform can be modified to work on another. This is strongly influenced by to what degree a language is standardized.
+
*Portability: the ease with which programs that work on one platform can be modified to work on another. This is strongly influenced by to what degree a language is standardized.
:*Generality: Applicability to a wide range of applications.
+
*Generality: Applicability to a wide range of applications.
:*Well-definedness: Completeness and precision of the language's official definition.
+
*Well-definedness: Completeness and precision of the language's official definition.
  
 
|}
 
|}

Revision as of 19:45, 2 November 2019


Why Multi-Paradigm Programming and Scripting?
  • Universal programming constructs (invariant of language), their functions, uses and how different paradigms/languages employ them.
  • Improved background for choosing appropriate languages:



Content of this course
Programming Constructs:
  • The compilation process
  • Data types (strongly-typed, weakly-typed)
  • Pointers
  • Variables and Invariants
  • Conditionals (Selection)
  • Sequence
  • Repetition
  • Routines
  • Concurrency
Programming Paradigms & Languages:
  • Abstraction (machine to very-high-level)
  • Mark-up
  • Imperative & Declarative
  • Procedural
  • Parallel & Concurrent
  • Functional
  • Event-Driven
  • Multi-Paradigm Languages
  • Interpreted Languages
  • Comparison of all to Object Oriented Paradigm
Scripting:
  • Interpreters and system commands
  • Shell Scripting (Linux/UNIX)
  • PowerShell Scripting (Windows)
  • System Programming & Scripting
Applications of Shell Scripting:
  • Job Control
  • Glue Code / Wrappers
  • Automating Tasks
  • Data Processing / Transformation
  • System uses
  • I/O tasks and functions



Languages evaluation Criteria

https://www.cs.scranton.edu/~mccloske/courses/cmps344/sebesta_chap1.html


Readability Writability Reliability Cost Other criteria

This refers to the ease with which programs (in the language under consideration) can be understood. This is especially important for software maintenance.

  • Simplicity:
  • Orthogonality:
  • Data Types:
  • Syntax Design:


This is a measure of how easily a language can be used to develop programs for a chosen problem domain.

  • Simplicity and Orthogonality:
  • Support for Abstraction:
  • Expressivity:


This is the property of performing to specifications under all conditions.

  • Type Checking:
  • Aliasing:


The following contribute to the cost of using a particular language:

  • Training programmers: cost is a function of simplicity of language
  • Writing and maintaining programs: cost is a function of readability and writability.
  • Compiling programs: for very large systems, this can take a significant amount of time.
  • Executing programs: Having to do type checking and/or index-boundary checking at run-time is expensive. There is a tradeoff between this item and the previous one (compilation cost), because optimizing compilers take more time to work but yield programs that run more quickly.
  • Language Implementation System: e.g., Java is free, Ada not
  • Lack of reliability: software failure could be expensive (e.g., loss of business, liability issues)


  • Portability: the ease with which programs that work on one platform can be modified to work on another. This is strongly influenced by to what degree a language is standardized.
  • Generality: Applicability to a wide range of applications.
  • Well-definedness: Completeness and precision of the language's official definition.


Compilation vs Interpretation


Phases of Compilation

Phases of compilation.png



Object-Oriented Paradigm


C++ Inheritance

https://www.w3schools.com/cpp/cpp_inheritance.asp

https://www.tutorialspoint.com/cplusplus/cpp_interfaces.htm



Difference Between Static and Dynamic Binding

https://techdifferences.com/difference-between-static-and-dynamic-binding.html



Reflection

A programming language that supports reflection allows its programs to have runtime access to their types and structure and to be able to dynamically modify their behavior

  • The types and structure of a program are called metadata
  • The process of a program examining its metadata is called introspection
  • Interceding in the execution of a program is called intercession


Uses of reflection for software tools:

  • Class browsers need to enumerate the classes of a program
  • Visual IDEs use type information to assist the developer in building type correct code
  • Debuggers need to examine private fields and methods of classes
  • Test systems need to know all of the methods of a class


Downsides of Reflection:

  • Performance costs
  • Exposes private fields and methods
  • Voids the advantages of early type checking
  • Some reflection code may not run under a security manager, making code nonportable



Reflection in Java

  • Limited support from java.lang.Class
  • Java runtime instantiates an instance of Class for each object in the program
  • The getClass method of Class returns the Class object of an object
float[] totals = new float[100];
Class fltlist = totals.getClass();
Class stg = "hello".getClass();
  • If there is no object, use class field:
Class stg = String.class;
  • Class has four useful methods:
getMethod searches for a specific public method of a class
getMethods returns an array of all public methods of a class
getDeclaredMethod searches for a specific method of a class
getDeclaredMethods returns an array of all methods of a class
The Method class defines the invoke method, which is used to execute the method found by getMethod



Some tutorials


Examples from Introduction to Programming Using Python 3

http://www.cs.armstrong.edu/liang/py/ExampleByChapters.html



C++ tutorial

http://www.cplusplus.com/doc/tutorial/program_structure/