Programming Languages Deep Notes
Programming Languages Deep Notes
Notes
1. Syntactic and Semantic Rules of a Programming Language
Syntactic Rules:
Example: In C, a function must be defined with a return type: int main() {...}
Semantic Rules:
- Readability: Easy to read and understand, with consistent naming and indentation.
- Robust Error Handling: Provides clear error messages and recovery mechanisms.
- Security: Restricts access to protected data and enforces safe programming practices.
- Rich Ecosystem: Should have tools like debuggers, IDEs, and libraries.
- Converts entire high-level source code into machine code before execution.
- Example: C, C++
Interpreter:
Assembler:
Hybrid:
Primitive Types:
- Defines what values a data type can hold and what operations can be performed.
Implementation:
- Describes how the data type is stored in memory (bits, bytes, alignment).
- Involves storage strategy, precision (for floats), encoding (ASCII for chars).
Example: int a = 5;
Type Checking:
Type Conversion:
Example: x = 10;
Initialization:
Floating-point Types:
- Includes: float (4 bytes), double (8 bytes), long double (10 or more bytes).
9. Enumerations
- enum defines symbolic names for integer constants.
Syntax:
Color c = GREEN;
Characters: