Preliminaries
Why Study Programming Languages?
- Increased ability to express ideas.
- Improved background for choosing appropriate languages.
- Increased ability to learn new languages.
- Better understanding of significance of implementation.
- Better use of languages that are already known.
Programming Domains
- Scientific
- Floating Point
- Arrays
- Fortran
- Business
- Fixed Point
- Characters
- Reports
- COBOL
- AI
- Symbol Manipulation
- Linked Lists
- LISP
- Systems
- Efficiency
- Direct Memory Access
- C
- Web
- Markup (HTML, CSS)
- Client Side (Javascript)
- Server Side (PHP)
- Java
Language Evaluation
- Readability
- Simplicity
- Orthogonality
- Data Types
- Syntax
- Meaningful keywords
- Writeability
- Simplicity & Orthogonality
- Support for Abstraction
- Expressivity
- Reliability
- Type Checking
- Exception Handling
- Aliasing
- Cost
- Training
- Reliability
- Maintenance
- Others
- Portability
- Generality
- Well-Definedness
Influences on Language Design
Computer Architecture
- Data and programs stored.
- Basis for imperative languages.
- Variables are memory cells.
- Code is instructions.
- Fetch-execute Cycle:
- Initialize program counter.
- Repeat Forever:
- Fetch instruction at counter.
- Increment counter.
- Decode the instruction.
- Execute the instruction.
Programming Methodologies
- Earliest languages were for simple programs that had to be efficient.
- In 1960s readability was stressed, structured programs.
- In 1970s data-oriented programming and abstraction.
- In 1980s object-oriented programming: inheritance, polymorphism.
- In 2000s, dynamic programming and rapid development.
Language Categories
- Imperative
- Variables, assignment, iteration are key.
- Computation done by updating variables.
- Examples: C, C++, Java, Python, PHP, Basic
- Most common type.
- Functional
- Computation done by applying functions to parameters.
- Based on Lambda Calculus.
- Does not rely on modifying variables.
- Recursion more common than iteration.
- Examples: LISP, Haskell, ML
- Logic
- Rule-based.
- Specifies rules in any order, and computation follows the rules.
- Prolog.
- Markup Hybrids.
- Languages for encoding data with programming features.
- HTML not a programming language.
- Examples: JSTL, XSLT, Postscript, TeX
- Domain-Specific
- Languages developed for a particular use.
- Examples: SQL, Lex & Yacc, Awk, Makefile
Design Trade-Offs
- Reliability vs. Efficiency
- Checking array bounds.
- Checking for exceptions.
- Readability vs. Writability
- Flexibility vs. Reliability
Implementation Methods
Different programming languages expose the underlying machine in different ways.
Compilation
- Programs are translated into machine language.
- Faster execution.
- Takes time to compile.
- Can be less flexible.
Phases:
- Lexical Analysis
- Syntax Analysis
- Intermediate Code Generation
- General Optimizations
- Machine Code
- Specific Optimizations
Interpretation
- An interpreter program runs the code.
- Less efficient.
- Very flexible.
- Easier to implement.
Hybrid Systems
- Compromise between compilation and interpretation.
- Compiles down to "bytecode" which is interpreted.
- Just in Time Compilation.
- Faster than pure interpretation.
Summary
- There are different types of programming languages.
- Knowing more languages makes you a better programmer.
- Languages have different goals and uses.
- Programming languages are also determined by their tools and environments.
Copyright ©
2022
Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.