csc chp 1
1. Introduction to Programming Languages
1.1 Reasons for Studying Concepts of Programming Languages
Increased capacity to express ideas
Features such as control structures and data structures can limit expression in a programming language.
Awareness of diverse programming features enhances software development capabilities.
Studying programming concepts promotes appreciation for valuable language features.
Improved background for choosing appropriate languages
Knowledge from experience in various languages aids in selecting suitable languages for new projects.
Increased ability to learn new languages
Programming languages evolve continuously, necessitating familiarity with fundamental concepts to ease the learning process.
Better understanding of implementation significance
Using a language intelligently involves understanding its design and available constructs, enhancing programming proficiency.
Overall advancement in computing
1.2 A Brief History of Programming Languages
Origins
Machine languages of the 1940s were the first programming languages.
Hundreds of languages have emerged since, with varying lifespan and impact.
Some languages have significantly influenced future designs.
Key Programming Languages Over Time
Machine Language - 1940s
Fortran - Late 1950s
Cobol - Late 1950s
Algol - 1960s
PL/I - 1960s
Pascal - 1970s
C - 1970s
C++ - 1980s
Java - 1990s
1.3 Introduction to Language Paradigms
Programming Languages - Tools for expressing algorithms between humans and computers.
Programming Paradigm - Method for representing algorithmic expressions suited for specific application domains.
Major Programming Paradigms
Imperative Programming
Programs are sequences of steps executing calculations, retrieving inputs, or producing outputs.
Core constructs include assignments, loops, sequences, and conditionals.
Representative languages: Cobol, Fortran, C, C++.
Object-Oriented Programming
Programs modeled as collections of interacting objects.
Fundamental concepts include object modeling, classification, and inheritance.
Representative languages: Smalltalk, Java, C++, Eiffel.
Functional Programming
Programs consist of mathematical functions with defined inputs and results.
Interaction through functional composition, conditionals, and recursion.
Representative languages: Lisp, Scheme, Haskell, ML.
Logic Programming
Programs declare logical outcomes, focusing on what rather than how.
Representative language: Prolog.
Event-Driven Programming
Programs operate in continuous loops responding to unpredictable events.
Representative languages: Visual Basic, Java.
Concurrent Programming/Parallel Programming
Programs consist of cooperating processes sharing information.
Representative languages: SR, High-Performance Fortran.
Multi-Paradigm Languages
Some languages support multiple paradigms (e.g., C++ is imperative and object-oriented).
1.4 Application Domains/Programming Domains
Scientific Computing
Focuses on fast, accurate calculations, typically using imperative programming. Common structures: arrays and matrices.
Modern languages: Fortran 90, C, High-Performance Fortran.
Business Applications
Includes payroll, accounting, and inventory systems.
Historically developed in Cobol, RPG, SQL; modern systems often use event-driven languages like Java.
Artificial Intelligence
Develops models for human-like intelligence and logical reasoning.
Languages: Lisp, Scheme, Haskell (Functional), Prolog (Logic).
Systems Programming
Designs and maintains core software, including operating systems and compilers.
Commonly employs imperative, parallel, and event-driven paradigms; C is predominant in Unix systems.
Web Software
Rapidly expanding area involving e-commerce and online systems.
Often employs object-oriented and event-driven paradigms, utilizing languages like Perl, JavaScript, PHP.
1.5 Language Evaluation Criteria
Readability
Ease of understanding programs, influenced by simplicity, orthogonality, control structures, and syntax.
Writability
Measure of how easily programs can be created; depends on language characteristics like abstraction and expressivity.
Reliability
Ability of a program to function as intended under all conditions. Language features contributing include type checking and exception handling.
Cost
Factors: programmer training, program writing, compilation, execution costs, and reliability costs.
Example: Java's rapid adoption due to free compiler availability.
1.6 Compilation Process
Overview
Compilation involves phases from source code to machine language execution.
Includes lexical analyzing, syntax analyzing, intermediate code generation, semantic analyzing, optimization, and code generation.
Phases
Lexical Analyzer: Segments the source code into units.
Syntax Analyzer: Constructs parse trees from lexical units.
Intermediate Code Generator: Converts to an intermediate representation.
Semantic Analyzer: Checks for type inconsistencies and other semantic errors.
Code Generator: Turns optimized intermediate code into machine language.
Linking: Combines user programs with necessary operating system components before execution.