Concepts and Semantics of Programming Languages 1
A Semantical Approach with OCaml and Python
Therese Hardin,Mathieu Jaume,Francois Pessaux,Veronique Viguie Donzeau-Gouge
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Concepts and Semantics of Programming Languages 1
A Semantical Approach with OCaml and Python
Therese Hardin,Mathieu Jaume,Francois Pessaux,Veronique Viguie Donzeau-Gouge
About This Book
This book – the first of two volumes – explores the syntactical constructs of the most common programming languages, and sheds a mathematical light on their semantics, while also providing an accurate presentation of the material aspects that interfere with coding.
Concepts and Semantics of Programming Languages 1 is dedicated to functional and imperative features. Included is the formal study of the semantics of typing and execution; their acquisition is facilitated by implementation into OCaml and Python, as well as by worked examples. Data representation is considered in detail: endianness, pointers, memory management, union types and pattern-matching, etc., with examples in OCaml, C and C++. The second volume introduces a specific model for studying modular and object features and uses this model to present Ada and OCaml modules, and subsequently Java, C++, OCaml and Python classes and objects.
This book is intended not only for computer science students and teachers but also seasoned programmers, who will find a guide to reading reference manuals and the foundations of program verification.
Frequently asked questions
Information
1
From Hardware to Software
1.1. Computers: a low-level view
1.1.1. Information processing
- – memories: store data (information) and executable code (the so-called von Neumann architecture);
- – one or more microprocessors, known as CPUs (central processing units), which process information by applying elementary operations;
- – peripherals: these enable information to be exchanged between the CPU/memory couple and the outside.
1.1.2. Memories
- – RAM (Random Access Memory): RAM memory is both readable and writeable. RAM components are generally fast, but also volatile: if electric power falls down, their content is lost;
- – ROM (Read Only Memory): information stored in a ROM is written at the time of manufacturing, and it is read-only. ROM is slower than RAM, but is non-volatile, like, for example, a burned DVD;
- – EPROM (Erasable Programmable Read Only Memory): this memory is non-volatile, but can be written using a specific device, through exposure to ultra- violet light, or by modifying the power voltage, etc. It is slower than RAM, for both reading and writing. EPROM may be considered equivalent to a rewritable DVD.
- – mass storage is measured in terabytes and is made either of mechanical disks (with an access time of ~ 10 ms) or – increasingly – of solid-state drive (SSD) blocks. These blocks use an EEPROM variant (electrically erasable) with an access time of ~ 0.1 – 0.3 ms, known as flash memory. Mass storage is non-volatile and is principally used for the file system;
- – RAM, which is external to the microprocessor. Recent home computers and smartphones generally possess large RAM capacities (measured in gigabytes). Embedded systems or consumer development electronic boards may have a much lower RAM capacity. The access time is around 40–50 ηs;
- – the cache is generally included in the CPU of modern machines. This is a small RAM memory of a few kilobytes (or megabytes), with an access time of around 5 – 10 ηs. There are often multiple levels of cache, and access time decreases with size. The cache is used to save frequently used and/or consecutive data and/or instructions, reducing the need to access slower RAM by retaining information locally. Cache management is complex: it is important to ensure consistency between the data in the main memory and the cache, between different CPUs or different cores (full, independent processing units within the same CPU) and to decide which data to discard to free up space, etc.;
- – registers are the fastest memory units and are located in the center of the microprocessor itself. The microprocessor contains a limited number (a few dozen) of these storage zones, used directly by CPU instructions. Access time is around one processor cycle, i.e. around 1 ns.
1.1.3. CPUs
- – data transfer instructions (copy between registers or between memory and registers);
- – arithmetic instructions (addition of two integer values contained in two registers, multiplication by a constant, etc.);
- – logical instructions (bit-wise and/or/not, shift, rotate, etc.);
- – branching operations (conditional, non-conditional, to subroutines, etc.);
- – other instructions (halt the processor, reset, interrupt requests,
test-and-set, compare-and-swap,
etc.).