Basics Track

Computation basics: memory, processes, kernel resources

Story Index Prologue Introduction Models Models of structure and semantics Data Types & instances Operations Callable objects Structures Class structure Libraries Standard libraries References Resource links    
Bite Index Platform Survey of dominant operating systems Memory Memory-mapped files, virtual memory Scheduling Work scheduling, ready, running, blocked IO Sync and async, unbuffered and buffered IO System Res System-wide shared resources Programming Program models Execution Native vs. Managed Functions Functions, methods, lambdas    
"Unix is simple. It just takes a genius to understand its simplicity."
- Dennis Ritchie

Fig 1. Windows API Hello World
This program was built using CMake build system generator. Perplexity AI provided help with Windows API types and correctly configuring compile options in CMakeLists.txt.
Building robust and maintainable system code is easier and more productive if you understand platform basics: OS architecture, hardware interfaces, memory management and system APIs. This Track provides introductions to common platforms, virtual memory management, scheduling, process structure, I/O, and system-wide resources. The Windows platform is our default exemplar, but Linux and macOS use similar models although they differ significantly in lower-level details. There are four ways of viewing Basics content in this site:
  1. Basics Story
    An ebook that covers basic computer technology at intermediate level.
  2. Basics Bites
    A collection of pages each focused on one feature of computer technology, starting with platforms.
  3. Blogs
    will eventually contain discussion of interesting details and comparisons. Those are not yet available.
  4. Basics Playground code examples
    Table of links to a collection of basic to intermediate code examples running in Compiler Explorer.
It's easy to sample each of these views by using the links above, or more selectively, using links in the BasicsExplorer panel on the left (if you don't see it, click on Toggle Ctrl Panel button at bottom left).
What I like about Basics
  • Basics pull core ideas out of the complexity of large software systems
    • Performance issues can be caused by: high page fault rates, thread blocking, I/O latency, garbage collection, database access, inadequate caching, ... Knowing basic concepts helps to sort out the sources of poor performance.
    • Understanding and improving program readability requires building code abstractions and organizing them well. Knowledge of basics guides that process.
  • Provide a substrate of knowledge for competent code development
    • Performance
    • Debugging
The code above on the right illustrates a C++ hello world program implemented using only the Windows API, .e.g., no C or C++ runtime libraries.

Table 1. Rust Resources from this site

Site Resources Content
Rust Repositories Index of all the Rust code repositories
Rust Models Summary of features with screenshots and examples - pdf
Rust Story
Index at upper right on this page.
Rust ebook in 7 chapters
first chapter in Rust Story
Rust Bites
Index at upper right on this page.
Dozens of Code Bites about Rust
first Rust Bite <-- good place to go after this page
Rust Glossary Definitions of common terms
Rust FlashCards Basic types and data structures
Bits of Code Compares small C++, Rust, C#, Python, and JavaScript codes  
Rust Playground online compiler
Code Examples Content
Rust Repositories Index into Rust Repositories
Rust Code examples List of RustBites code examples, RustPlayground code examples, Rust Basic Demos Repository
online code execution RustPlayground, tutorialspoint
Other Resources Content
Rust Guide Definition and examples of Rust collections, iterators, and concurrency constructs.
Tooling Using Visual Studio Code to create and build Rust code
Rust home site Download and install, learn Rust
Rust user's forum Create an account and you can log-in, read, and post messages and questions.
The Rust Reference Semi-formal, but surprisingly readable, reference for Rust
Rust API Guidelines Guidelines for crafting Rust code, from the source
Other intermediate and advanced resources
How to learn modern Rust A collection of links to explorations of intermediate and advanced language materials
idiomatic rust resources Annotated links to articles and examples of community accepted styles and patterns for rust code.
 
You can find videos covering some of the topics in Table 1. and Table 2. using the "Videos" link in the top menu. First Rust Bite is a good next step after this page.

Exercises

  1. Write a Rust program to find the largest file in a specified directory tree, using walkdir crate from crates.io.
  2. Ammend Project #1 by accepting arguments from the command line, using args crate.
  3. Use ChatGPT to create a directory traversal crate and use that instead of walkdir.
  4. Write a Rust program to read a source code file and count the number of lines and number of scopes for each function. You can count scopes by counting open braces "{". Start by searhing for fn and then read each line searching for "{" and "}". Push each open brace on a stack, and pop when a closed brace is encountered. When the stack is empty, the end of the function has been reached.
  5. Modify Project #4 by counting lines and scopes for each file in a directory tree rooted at a specified folder, usually named "src".
< id="bottomMenu">