(Week2) CSC423 - Programming
(Week2) CSC423 - Programming
L4 2
What is Programming
Language
Morris [6] studied the various levels at which a
description of a language can occur.
Grammar
Semantics
Pragmatics.
L4 3
What is Programming
Language
L4 4
What is Programming
Language
L4 5
What is Programming
Language
L4 6
What is Programming
Language
In the case of programming languages, we can add a fourth
level to the three classical ones: the implementation level.
Given that the languages that interest us are procedural
languages (that is, languages whose correct phrases specify
actions), it remains for us to describe “how to execute a
correct sentence, in such a way that we respect the
semantics”.
L4 7
What is Programming
Language
For example:
Consider the word “recipes” in cooking
Syntax determines the correct sentences with
which a recipe is expressed
The semantics is about explaining “what is” a
recipe,
L4 8
What is Programming
Language
Pragmatics studies how a cook (“that
cook”) interprets the various sentences of
the recipe
The implementation describes the way
(where, and with what ingredients) the
kitchen recipe transforms into the dish
that the semantics prescribes.
L4 9
History and Evolution of Programming
Languages
L4 10
History and Evolution of Programming
Languages
L4 11
History and Evolution of Programming
Languages
L4 12
History and Evolution of Programming
Languages
L4 13
History and Evolution of Programming
Languages
L4 14
Why Are There So Many Programming
Languages?
L4 15
Why Are There So Many Programming
Languages?
L4 16
Why Are There So Many Programming
Languages?
• Community support and ecosystem: A strong
developer community leads to continuous
improvement, evolution, and widespread adoption of
certain languages (e.g., Java, JavaScript, Python).
• New computing paradigms: Advances in cloud
computing, IoT, and quantum computing have
driven the creation of specialized languages like
Swift, Go, and Q#.
L4 17
Why Are There So Many Programming
Languages?
• Community support and ecosystem: A strong
developer community leads to continuous
improvement, evolution, and widespread adoption of
certain languages (e.g., Java, JavaScript, Python).
• New computing paradigms: Advances in cloud
computing, IoT, and quantum computing have
driven the creation of specialized languages like
Swift, Go, and Q#.
L4 18
Application Domains
Programming languages are tailored to different
domains:
• System Programming: C, Rust, Assembly
• Web Development: JavaScript, PHP, Ruby
• Data Science & AI: Python, R, Julia
• Mobile App Development: Swift (iOS), Kotlin
(Android)
• Game Development: C++, C#, Unity
• Embedded
L4 Systems: C, Assembly 19
Language Design Considerations
When designing a language, key considerations
include:
Readability: the ease with which programs can be
read and understood
Writability: the ease with which a language can be
used to create programs
Reliability: conformance to specifications
(i.e.,performs to its specifications)
L4 20
Cost: the ultimateDesign
Language total costConsiderations
Performance and efficiency: Execution speed and
memory usage are crucial for certain applications.
Portability: The ability to run on multiple platforms
(e.g., Java’s JVM allows cross-platform execution).
Security: Languages like Rust prioritize memory
safety.
Concurrency support: Modern languages like Go
and Erlang are designed for handling multiple tasks
simultaneously
L4 21
Evaluation Criteria: Readability
L4 22
Evaluation Criteria: Reliability
Type checking
Testing for type errors Readability and writability
Exception handling A language that does not support
“natural” ways of expressing an
Intercept run-time errors and take corrective
algorithm will require the use of
measures
“unnatural” approaches, and hence
Aliasing reduced reliability
Presence of two or more distinct referencing
methods for the same memory location
L4 23
Language Design Considerations
1. Computer Architecture
• Most programming languages have historically been designed around the von
Neumann architecture.
• In this architecture:
• Programs and data share the same memory.
• Instructions are executed sequentially via the fetch-decode-execute cycle.
• As a result:
• Languages often feature variables, assignment statements, and loops that mirror
hardware design.
• Imperative languages like C, Pascal, and Fortran align well with this model.
L4 25
von Neumann architecture
end repeat
L4 26
Influences on Language Design
L4 27
Programming Methodologies Influences
L4 28
Programming Methodologies Influences
L4 29
Programming Methodologies Influences
L4 30
Programming Methodologies Influences
L4 31
Language Categories
Programming languages can be grouped based on their computational model
and paradigm.
1. Imperative Languages
• Core Features:
• Use of variables, assignment statements, and iteration.
• Describe how a task is performed (step-by-step).
• Includes:
• Object-Oriented Languages: Java, C++, C#
• Scripting Languages: Python, JavaScript, Perl
• Visual Languages: Visual BASIC .NET
• 📌 Examples: C, Java, JavaScript, Perl, Visual BASIC .NET, C++
L4 32
Language Categories
🔹 2. Functional Languages
• Computation is based on function application.
• Focus on what to solve rather than how.
• Encourages immutability, recursion, and higher-order
functions.
• 📌 Examples: LISP, Scheme, ML, F#
L4 33
Language Categories
🔹 3. Logic Languages
• Rule-based: computation is performed by logical
inference from facts and rules.
• Rules are not ordered — declarative in nature.
• Used in AI, NLP, and knowledge-based systems.
• 📌 Example: Prolog
L4 34
Language Categories
L4 35
Layered View of Computer
The operating
system and
language
implementation
are layered over
machine interface
of a computer
L4 36
Program Execution Models (Compilation vs.
Interpretation)
Program Execution Models (Compilation vs.
Interpretation)
There are two primary execution models for
programming languages:
• Compiled Languages:
• Examples: C, C++, Rust, Go
• A compiler translates the source code into machine code
before execution.
• Offers faster execution but requires a separate compilation
step.
L4 37
Program Execution Models (Compilation vs.
Interpretation)
• Interpreted Languages:
• Examples: Python, JavaScript, Ruby
• Code is executed line-by-line by an interpreter.
• Slower execution but allows for dynamic behavior and
easier debugging.
L4 38
Program Execution Models (Compilation vs.
Interpretation)
Compilation
Compilation is the process of translating a high-
level program (written in a source language) into
machine code (target language), which a computer
can execute directly.
• Slow Translation, but Fast Execution
• Compilation takes time upfront.
• Once compiled, the program runs efficiently.
L4 39
Phases of the Compilation Process
1. Lexical Analysis 3. Semantic Analysis
•Scans the source code. •Verifies semantic consistency:
•Converts a stream of characters into lexical
• Type checking
tokens (identifiers, keywords, symbols).
•Example: int x = 5; → tokens: int, x, =, 5, ; • Scope resolution
2. Syntax Analysis (Parsing)
• Declaration-before-use rules
•Produces intermediate representation (IR) of
• Takes the tokens from lexical analysis.
the program.
• Builds a parse tree (or abstract
4. Code Generation
syntax tree) to represent the
syntactic structure of the code.
•Converts intermediate code into machine
code or assembly.
• Checks if the code follows the
grammar rules of the language.
•Performs optimizations to enhance
performance.
L4 40
The Compilation Process
L4 41
Pure Interpretation
L4 42
Pure Interpretation
L4 43
Pure Interpretation
🔹 Modern Usage
• Rare for traditional compiled languages (e.g., C, C+
+).
• Comeback with Web scripting and dynamic
languages:
• 📌 Examples: JavaScript, PHP, Python (to an extent)
L4 44
Program Execution Models (Compilation vs.
Interpretation)
• Hybrid Approach:
• Example: Java (compiles to bytecode, then executed
by the JVM)
• Balances performance and portability.
L4 45
Language Standardization
L4 46
Language Standardization
48