Programming Language (PL): A formal nota...

by Unattributed

Audio version created with Paper2Audio.

Listen on Paper2Audio

Audio by Paper2Audio

Programming Language (P.L): A formal notation for describing algorithms for execution by a computer, a convention for communicating algorithms, and a system for specifying, organizing, and reasoning about computation.

Twin Goals of Language Designers:

Making computing convenient for people.

Making efficient use of computing machines.

6 Reasons to Study Programming Languages:

Improve ability to develop effective algorithms: Increases the capacity to express computational ideas and maximize language capabilities.

Improve use of existing languages: Understanding underlying implementation details enables writing more efficient code.

Increase vocabulary of useful programming constructs: Enables selecting appropriate language constructs for specific tasks.

Allow better choice of programming language: Evaluates languages to select the optimal tool for a project.

Make it easier to learn new languages: Builds a foundation of core concepts applicable across all languages.

Make it easier to design new languages: Provides insight into trade-offs and design choices required to build a language.

Module 2: Language Evaluation & Design Characteristics

Characteristics of a Good Language

Clarity, Simplicity, and Unity:

Clarity: How easily source code can be read and understood.

Simplicity: Having a straightforward, uncomplicated syntax.

Unity: Maintaining a cohesive and consistent overall design structure.

Orthogonality: The ability to combine a small set of primitive constructs systematically in a relatively small number of ways to build control and data structures.

Naturalness for the Application: Providing appropriate data structures, operations, control structures, and syntax for the specific problem domain.

Support for Abstraction: Enabling high-level solution designs that can be implemented directly within the language.

Ease of Program Verification (Reliability): Ability to perform according to specifications under all operating conditions. Key mechanisms include:

Type Checking: Testing for type errors during compilation or execution.

Exception Handling: Intercepting runtime errors to execute corrective measures.

Aliasing Control: Minimizing instances where two or more distinct referencing methods (variables) refer to the exact same memory location.

Programming Environment: Availability of a supportive ecosystem, including robust libraries, developer tools, and an active user community.

Portability: Writing programs that execute across different hardware platform environments with minimal modification (for example, C).

Cost: Major evaluation factor encompassing training programmers, writing programs, compiling, executing, maintenance, and optimization.

Module 3: Programming Environments

The host environment (where code is designed, compiled, and debugged) often differs from the operating environment (where the application ultimately executes).

4 Classes of Programming Environments:

Batch Processing Environment: Processes non-interactive jobs sequentially without real-time user interaction.

Interactive Environment: Provides real-time execution and feedback between the user/programmer and the program.

Embedded System Environment: Operates within specialized hardware devices with strict execution constraints.

Programming Environment: Integrates dedicated tools, editors, compilers, and debuggers to facilitate software development.

Module 4: Bindings and Binding Times

Binding & Classifications

Binding: An association between an entity and an attribute (such as between a variable and its data type/value, or an operation and its symbol).

Classification

Timing

Execution Speed

Key Mechanisms / Features

Static Binding (Early Binding)

Occurs before runtime (compile time) and remains unchanged during execution.

High

Method Overloading, Operator Overloading, Method Hiding (new).

Dynamic Binding (Late Binding)

Occurs or can change during program execution (runtime).

Low

Method Overriding (virtual / override), Dynamic Storage/Value Allocation.

Binding Mechanisms in Polymorphism

Method Overloading: Defining multiple functions with the same name but different signatures within the same scope; resolved via static binding.

Method Overriding: A subclass re-implementing a base class method; uses dynamic binding.

virtual (Base Class): Grants permission for a method to be replaced by a child class implementation.

override (Child Class): Explicitly replaces the base class method implementation.

new (Child Class): Hides the base class method without overriding it, forcing static binding through base class references.

Classes of Binding Times

Execution Time (Runtime): Bindings performed during program execution (for example, variable values, storage location allocations, dynamic binding).

Translation Time (Compile Time): Bindings established before loading the program into memory. Divided into three sub-classes:

Programmer: Bindings explicitly written into data structures and code by the programmer.

Translator: Bindings generated automatically by the compiler or assembler without programmer intervention.

Loader: Mapping memory references to actual physical memory addresses in the target machine.

Module 5: Syntax and Semantics Fundamentals

Core Definitions

Syntax: The formal structure, arrangement, and layout of statements in a programming language.

Semantics: The operational meaning or evaluation of syntactically valid constructs.

Language Users: Designers, implementers (compiler writers), and programmers.

Sentence / String: A sequence of characters chosen from a defined alphabet.

Language: A set of valid sentences.

Lexeme: The lowest-level syntactic unit of a language (for example, index, =, 2, *, count, +, 17, ;).

Token: A category or class of lexemes sharing identical syntactic roles (for example, identifier, equal sign, int literal, mult op, plus op, semicolon).

Formal Mechanics & Criteria

Language Recognizers: Tools (like syntax analyzers in compilers) that read input strings and verify whether they belong to a language.

Language Generators: Devices that produce valid sentences of a language to verify structural correctness.

Module 6: Formal Syntax Description & Semantics Analysis

Context-Free Grammars & Backus-Naur Form (B.N.F)

Developed by Noam Chomsky in the mid-1950s. B.N.F is a notation equivalent to context-free grammars used to specify syntax rules, build parsers, and generate valid code.

Production Rules & Components:

Non-Terminals (< >): Syntactic abstractions defining structural parts of the grammar.

Terminals: Fixed symbols, tokens, or lexemes that cannot be expanded further.

Operators: ::= means "is defined as"; | means "or".

Recursion: Used in rules to generate arbitrary lengths (for example, <natnum> ::= <digit> | <digit><natnum greater than ).

Parse Tree: A hierarchical structure representing how non-terminals derive a string.