Which concepts does the language offer to express computations?
Set of abstraction building in the syntax of the language.
Abstraction: A representation that highlights relevant aspects of a concept, object, or computation while omitting irrelevant details.
Linguistic Abstraction: The use of language constructs (syntax, symbols, or grammatical forms) to represent computational or conceptual abstractions.
Language Specification: : A formal or semiformal description of a programming language’s syntax, semantics, and behavior.
First-class citizens (abstraction toolbox) (yang) and implicit behaviors (yin) (internal implementation abstractions) are complementary and interdependent aspects of a programming language: first-class citizens are the visible, directly manipulable elements, while implicit behaviors are the often-hidden, essential mechanisms that support them.
Level | Example Constructs | Abstraction Role |
---|---|---|
Lexical | Keywords (if , while ), Identifiers, Literals (42 , "hello" ), Operators (+ , - ), Delimiters ({} , () ), Comments |
Primitive symbolic units; building blocks of program meaning |
Expression | Arithmetic/logical expressions (x + y , a && b ), Function/method calls (f(x) ), Variable assignment (x = y + 2 ), Type expressions (int , List[String] ), Lambda expressions (x => x * 2 ) |
Composable units of computation |
Statement / Instruction | Control flow (if , switch , for , while ), Block structures / Scope, Jump statements (break , return ), Declaration statements (variables, functions, classes) |
Structures controlling execution flow and logical sequencing |
Compound / Structural | Functions / Methods, Modules / Namespaces / Packages, Classes / Objects / Interfaces, Generics / Templates (List<T> ) |
Encapsulation, hierarchy, modularity, and code organization |
Pattern / Idiomatic | Design patterns (Singleton, Factory), Control flow idioms (recursion, for-each ), Resource management (with , RAII), Higher-order functions (map , filter , reduce ) |
Reusable computational patterns; makes design intent explicit |
Meta / DSL | Macros (macro_rules! ), Annotations / Decorators (@dataclass , @Override ), Embedded DSLs (LINQ, fluent interfaces), Reflection / Introspection |
Enables language extension, self-reflection, or compile-time computation |
Cross-Cutting | Immutability vs mutation, Typing (static vs dynamic), Concurrency / Parallelism (async/await , threads, actors), Error handling (try/catch ) |
Semantics embedded in syntax; pervasive behavioral patterns |
Role Category | Example Constructs / Instances | Description / Function |
---|---|---|
Data Roles | Variable, Constant, Parameter, Field / Property | Represent and store values; hold program state |
Computation Roles | Expression, Function call, Operator, Lambda | Perform computations or transform data |
Control Roles | Conditional (if , switch ), Loop (for , while ), Jump (break , return ) |
Determine program execution flow |
Structural / Organizational Roles | Function / Method, Class, Module / Namespace, Package | Organize code into reusable, modular units |
Behavioral / Interaction Roles | Interface, Abstract class, Protocol, Trait | Define behavior contracts and interactions between components |
Resource / Environment Roles | File handle, Database connection, Thread / Process, Network socket | Represent external or managed resources the program interacts with |
Error / Exception Roles | Exception object, Try/Catch block, Error code | Handle and represent exceptional situations |
Meta / Reflective Roles | Macro, Decorator, Annotation, Reflection API | Code that manipulates or describes other code; supports abstraction at the language level |
Pattern / Idiomatic Roles | Singleton, Factory, Observer, Higher-order function | Represent recurring design or computational patterns |
Type Roles | Primitive type, Generic / Template, Composite type (struct, tuple) | Define structure, constraints, and semantic meaning of data |
…
Specify a representation.
A type that abstract and specify a representation.
Note: Remember, there are also untyped data.