Chapter 1: Preliminaries

1.1 What is a Language?

  • Programming Languages: Special types of languages used to communicate with computers. They have formal structures and specific rules.
  • Comparison with Natural Languages: Both types can be formally described using similar attributes.
    • Significant Differences:
    • Natural human languages often have ambiguous grammars.
    • Programming languages are designed to have unambiguous grammars.

1.2 Ambiguous Grammars

  • Examples of ambiguous phrases in natural languages:
    • "I saw her duck": This can mean either
    • Observing a duck owned by the person.
    • Seeing a woman retrieve a duck.
    • "The man saw a boy in the park with a telescope": This can mean either
    • The man has a telescope, or
    • The boy has a telescope.

1.3 Attributes of Languages

  • Important characteristics that describe languages:
    • Grammar: Rules defining a language's syntax.
    • Syntax: The structure of expressions in the language.
    • Semantics: The meanings of expressions.
    • Lexicon: The vocabulary of the language.
    • Alphabet: The set of symbols used in the language.
    • Typology: The classification of languages based on structural features.
    • Orthography: The writing system of the language.
    • Morphology: The structure of words.
    • Phonology: The sound system of the language.

1.4 Linguistics and Language

  • Natural Languages: Examples include English, French, Chinese, etc. They are used for human communication.
  • Constructed Languages (ConLangs): Includes:
    • Sociopolitical: Esperanto, Toki Pona.
    • Fictional: Klingon, Sindarin, Dothraki.
    • Research: LOGLAN, Lojban.
    • Sign Languages: ASL, LSF, etc.

1.5 Turing Completeness

  • Definition: A system of data-manipulation rules is Turing Complete if it can simulate any single-taped Turing machine. Examples of such systems include:
    • A computer’s instruction set.
    • A programming language.
    • Cellular automata.

1.6 Complexity Theory

  • Asymptotic Running Time: Refers to the manner in which the running time of an algorithm increases relative to the input size.
  • Big-O Notation: Describes the upper limit of the running time.
    • Types:
    • O(1): Constant Time
    • O(n): Linear Time
    • O(n log n): Log-linear Time
    • O(n^k): Polynomial Time
  • P vs NP: Classification of problems in computer science, with P representing problems solvable in polynomial time and NP representing problems verifiable in polynomial time.

1.7 One or Many Languages?

  • Discussion on the number of programming languages: The desire for a singular universal programming language vs. the proliferation of multiple languages due to various needs and specifications.
1.7.1 Standards Proliferation
  • Example given of competing standards leading to an increase instead of a consolidation of programming languages and coding standards.

1.8 Historical Context

  • First Programming Language: Computation of Bernoulli Numbers in 1843 on Charles Babbage's Analytical Engine by programmer Ada Lovelace. The significance of this event marks a pivotal moment in programming history.

1.9 Plankalkül as a Language

  • First High-level Programming Language: Developed by Konrad Zuse in 1945 but published in 1972. Notable features included:
    • Advanced data structures.
    • Floating-point data types.
    • Arrays and records.
    • Invariants for maintaining data integrity.

1.10 File Management

  • Source Code Files: Stored in files with specific extensions indicating the associated languages and compilers. These files may include:
    • Text files: Contain human-readable code.
    • Binary files: Include executable code and other formats like audio and video files.
  • Structure: Source code is created and manipulated using an Integrated Development Environment (IDE) which includes editors, parsers, compilers, linkers, and debuggers.

1.11 Esoteric Languages

  • Also known as Esolangs, these are often joke languages created for amusement. Notable examples include:
    • Shakespeare language
    • LOLCODE
    • Chef
    • Malbolge
1.11.1 Whitespace Language
  • Created by Edwin Brady and Chris Morris, it only recognizes whitespace characters (spaces, tabs, linefeeds). Any non-whitespace characters are ignored, making it possible for a Whitespace program to be hidden inside another program's whitespace.

1.12 Course Structure

  • Chapters 1-2: Introduction to high-level background topics.
  • Chapters 3-4: Cover Syntax and Semantics.
  • Chapters 5-6: Discuss language features such as binding, scope, and control structures.
  • Chapters 15-16: Explore different programming paradigms.

1.13 Properties of Programming Languages

  • Key properties evaluated from chapters 3-9 highlight various design features and their implications, including:
    • Security considerations: Explores how design can affect security through concepts like Language-Based Security and Common Weakness Enumeration.

1.14 Language Evaluation Criteria

  • Critical factors for evaluating programming languages include:
    • Readability: Ease of understanding program code.
    • Writability: How easily a language allows the creation of programs.
    • Reliability: Adherence to specifications and performance.
    • Cost: Total cost considerations, including training, maintenance, and compiling.

1.15 Influences on Language Design

  • Major influences include:
    • Computer Architecture: Languages often reflect prevalent architectures, notably the von Neumann architecture where programs and data are stored in memory.
    • Programming Methodologies: Advances in software development methodologies have spurred the development of new language paradigms.