Skip to content
ImagineWorld

The Secret Life of Programs

node_idnode-book_the-secret-life-of-programs
node_typenode-book
schema_profileworld.node_book.v1
statusactive
orthogonal_scopemanifold, entropy, authority, state
manifoldworld
entropymedium
authorityinforms
stateexternal
domainimagineworld.net
node_interiorrosetta_contract
unisonone evidence claim read five ways: seated in the systems field, the work reveals the secret life of programs — what code actually does on the machine beneath — its framework, regime, and stance agreeing on what it is
governed_byWORLD-MANIFOLD
constitutional_citationCONSTITUTION
evidence_bundle
compared_by
grounded_by
anchors_into
peer_node_books
pillar_membershipG — concurrency_storage_distributed_systems
book_titleThe Secret Life of Programs
book_subtitleUnderstand Computers — Craft Better Code
book_authorJonathan E. Steinhart
book_year2019
total_chapters19
total_source_pages506
total_nodes20
source_pdfthe-secret-life-of-programs.pdf
source_pdf_sha25602b98880515970cdc7254ddf373dab6a723c3b5a022ad836c8362d93c4ed1c8d
ocr_sourceLightOnOCR-3-4B via vLLM (400dpi; grounding+transcription modes)
ocr_quality_classcleaned
verification_statusone-shot-fill-lint-complete-1-review
verification_progress{"all_nodes":"PHASE 1 fill complete; deterministic lint complete — 1 review flag on this node (2026-10-12)"}
stitched_bykimi-k3-lightonocr3-one-shot
generated_at2026-10-12
pillar_normalizedG-concurrency_storage_distributed_systems
updated_at2026-10-14T05:45:16Z
visual_conversions0
visual_conversion_placeholders0
asset_count398
reviewunbalanced $ inline delimiters
local graph

The Secret Life of Programs — Jonathan E. Steinhart

Section titled “The Secret Life of Programs — Jonathan E. Steinhart”

node-book_the-secret-life-of-programs_chapter-01-acknowledgments — Acknowledgments

node-book_the-secret-life-of-programs_chapter-02-preface — Preface

node-book_the-secret-life-of-programs_chapter-03-introduction — Introduction

node-book_the-secret-life-of-programs_chapter-04-the-internal-language-of-computers — The Internal Language of Computers

node-book_the-secret-life-of-programs_chapter-05-combinatorial-logic — Combinatorial Logic

node-book_the-secret-life-of-programs_chapter-06-sequential-logic — Sequential Logic

node-book_the-secret-life-of-programs_chapter-07-computer-anatomy — Computer Anatomy

node-book_the-secret-life-of-programs_chapter-08-computer-architecture — Computer Architecture

node-book_the-secret-life-of-programs_chapter-09-communications-breakdown — Communications Breakdown

node-book_the-secret-life-of-programs_chapter-10-organizing-data — Organizing Data

node-book_the-secret-life-of-programs_chapter-11-language-processing — Language Processing

node-book_the-secret-life-of-programs_chapter-12-the-web-browser — The Web Browser

node-book_the-secret-life-of-programs_chapter-13-application-and-system-programming — Application and System Programming

node-book_the-secret-life-of-programs_chapter-14-shortcuts-and-approximations — Shortcuts and Approximations

node-book_the-secret-life-of-programs_chapter-15-deadlocks-and-race-conditions — Deadlocks and Race Conditions

node-book_the-secret-life-of-programs_chapter-16-security — Security

node-book_the-secret-life-of-programs_chapter-17-machine-intelligence — Machine Intelligence

node-book_the-secret-life-of-programs_chapter-18-real-world-considerations — Real-World Considerations

node-book_the-secret-life-of-programs_chapter-19-index — Index


FORTRAN

ASSEMBLY LANGUAGE

BINARY


[!visual-conversion] Cartoon miner holding blocks labeled FORTRAN, ASSEMBLY LANGUAGE, BINARY, with Cropped from the scan (PDF page 001): Cartoon miner holding blocks labeled FORTRAN, ASSEMBLY LANGUAGE, BINARY, with vintage computer parts and No Starch Press logo.

no starch press

THE SECRET LIFE OF PROGRAMS

Understand Computers — Craft Better Code

Section titled “Understand Computers — Craft Better Code”

by Jonathan E. Steinhart

[!visual-conversion] logo “no starch press” Cropped from the scan (PDF page 005): logo “no starch press”

no starch press

San Francisco

THE SECRET LIFE OF PROGRAMS. Copyright © 2019 by Jonathan E. Steinhart.

Section titled “THE SECRET LIFE OF PROGRAMS. Copyright © 2019 by Jonathan E. Steinhart.”

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.

ISBN-10: 1-59327-970-1
ISBN-13: 978-1-59327-970-7

Publisher: William Pollock
Production Editor: Janelle Ludowise
Cover Illustration: Josh Ellingson
Interior Design: Octopod Studios
Developmental Editors: Corbin Collins and Annie Choi
Technical Reviewer: Aubrey Anderson
Copyeditor: Rachel Monaghan
Compositor: Happenstance Type-O-Rama
Proofreader: Paula L. Fleming
Indexer: JoAnne Burek

The following images are attributed as follows: Composition in Figure 6-36 courtesy of Hanalei Steinhart. Brick wall in Figures 11-3, 11-4, 11-7 and 11-8 from www.cadhatch.com. Figure 14-25 from The Rocky Horror Picture Show (1975).

For information on distribution, translations, or bulk sales, please contact No Starch Press, Inc. directly:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 1.415.863.9900; [email protected]
www.nostarch.com

Library of Congress Cataloging-in-Publication Data

Section titled “Library of Congress Cataloging-in-Publication Data”

Names: Steinhart, Jonathan E., author.
Title: The Secret Life of Programs / Jonathan E. Steinhart.
Description: San Francisco : No Starch Press, Inc., [2019]
Identifiers: LCCN 2019018295 (print) | LCCN 2019021631 (ebook) | ISBN 9781593279714 (epub) | ISBN 159327971X (epub) | ISBN 9781593279707 (print) | ISBN 1593279701 (print)
Subjects: LCSH: Computer programming. | Programming languages (Electronic computers) | Browsers (Computer programs)
Classification: LCC QA76.6 (ebook) | LCC QA76.6 .S735 2019 (print) | DDC 005.1—dc23
LC record available at https://lccn.loc.gov/2019018295

No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.

The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.

To Julie and Hanalei for making
me learn how to explain complex
technologies to laypeople.

To the amazing place that was Bell
Telephone Laboratories and all the
people who worked there, especially to
Carl for making a place for me there
when I was a teenager.

Jonathan E. Steinhart has been involved in engineering since the 1960s. He started designing hardware in middle school and software in high school, which led to summer jobs at Bell Telephone Laboratories. He received his BSEE in Electrical Engineering and Computer Science from Clarkson University in 1977. After graduation, he worked for Tektronix before trying his hand at startup companies. He became a consultant in 1987, focused on safety-critical systems engineering. He cut back a bit starting in the 1990s to start Four Winds Vineyard.

Aubrey Anderson has a BSEE in Electrical Engineering and Computer Science from Tufts University. While there, he was a Teaching Fellow and helped to improve curricula for introductory computer science courses. He started programming at 14 and since then has worked on a variety of robotics, system design, and web programming projects. Aubrey currently works as a Software Engineer at Google.

Acknowledgments … xix
Preface … xxi
Introduction … xxv
Chapter 1: The Internal Language of Computers … 1
Chapter 2: Combinatorial Logic … 33
Chapter 3: Sequential Logic … 69
Chapter 4: Computer Anatomy … 93
Chapter 5: Computer Architecture … 117
Chapter 6: Communications Breakdown … 141
Chapter 7: Organizing Data … 183
Chapter 8: Language Processing … 217
Chapter 9: The Web Browser … 237
Chapter 10: Application and System Programming … 259
Chapter 11: Shortcuts and Approximations … 283
Chapter 12: Deadlocks and Race Conditions … 335
Chapter 13: Security … 351
Chapter 14: Machine Intelligence … 385
Chapter 15: Real-World Considerations … 413
Index … 445

xix

xxi

xxv

  • Why Good Programming is Important … xxvi
  • Learning to Code is Only a Starting Place … xxvii
  • Importance of Low-Level Knowledge … xxviii
  • Who Should Read This Book? … xxviii
  • What Are Computers? … xxix
  • What Is Computer Programming? … xxix
  • Coding, Programming, Engineering, and Computer Science … xxxii
  • The Landscape … xxxiii
  • What’s in This Book … xxxv

1

  • What Is Language? … 2
  • Written Language … 2
  • The Bit … 3
  • Logic Operations … 3
    • Boolean Algebra … 4
    • De Morgan’s Law … 5
  • Representing Integers Using Bits … 6
    • Representing Positive Numbers … 6
    • Binary Addition … 8
    • Representing Negative Numbers … 10
  • Representing Real Numbers … 14
    • Fixed-Point Representation … 14
    • Floating-Point Representation … 15
    • The IEEE Floating-Point Standard … 17
  • Binary-Coded Decimal System … 18
  • Easier Ways to Work with Binary Numbers … 18
    • Octal Representation … 18
    • Hexadecimal Representation … 19
    • Representing the Context … 20
  • Naming Groups of Bits … 20
  • Representing Text … 22
    • The American Standard Code for Information Interchange … 22
    • The Evolution of Other Standards … 24
    • Unicode Transformation Format 8-bit … 24
  • Using Characters to Represent Numbers … 25
    • Quoted-Printable Encoding … 26
    • Base64 Encoding … 26
    • URL Encoding … 27

Representing Colors 27
 Adding Transparency 29
 Encoding Colors 30
Summary 31

The Case for Digital Computers 34
 The Difference Between Analog and Digital 35
 Why Size Matters in Hardware 36
 Digital Makes for More Stable Devices 37
 Digital in an Analog World 38
 Why Bits Are Used Instead of Digits 40
A Short Primer on Electricity 41
 Using Plumbing to Understand Electricity 41
 Electrical Switches 44
Building Hardware for Bits 47
 Relays 47
 Vacuum Tubes 50
 Transistors 51
 Integrated Circuits 52
Logic Gates 53
 Improving Noise Immunity with Hysteresis 54
 Differential Signaling 55
 Propagation Delay 57
 Output Variations 58
Building More Complicated Circuits 60
 Building an Adder 60
 Building Decoders 63
 Building Demultiplexers 64
 Building Selectors 65
Summary 67

Representing Time 70
 Oscillators 70
 Clocks 71
 Latches 71
 Gated Latches 73
 Flip-Flops 74
 Counters 77
 Registers 78
Memory Organization and Addressing 79
 Random-Access Memory 82
 Read-Only Memory 83
Block Devices 85
Flash Memory and Solid State Disks 88
Error Detection and Correction 88
Hardware vs. Software 90
Summary 91

xii Contents in Detail

4 COMPUTER ANATOMY 93

  • Memory 94
  • Input and Output 96
  • The Central Processing Unit 97
    • Arithmetic and Logic Unit 97
    • Shiftiness 99
    • Execution Unit 100
  • Instruction Set 102
    • Instructions 102
    • Addressing Modes 104
    • Condition Code Instructions 105
    • Branching 105
    • Final Instruction Set 106
  • The Final Design 109
    • The Instruction Register 109
    • Data Paths and Control Signals 109
    • Traffic Control 110
  • RISC vs. CISC Instruction Sets 113
  • Graphics Processing Units 114
  • Summary 115

5 COMPUTER ARCHITECTURE 117

  • Basic Architectural Elements 118
    • Processor Cores 118
    • Microprocessors and Microcomputers 119
  • Procedures, Subroutines, and Functions 120
  • Stacks 122
  • Interrupts 125
  • Relative Addressing 128
  • Memory Management Units 130
  • Virtual Memory 132
  • System and User Space 133
  • Memory Hierarchy and Performance 133
  • Coprocessors 135
  • Arranging Data in Memory 136
  • Running Programs 137
  • Memory Power 138
  • Summary 139

6 COMMUNICATIONS BREAKDOWN 141

  • Low-Level I/O 142
    • I/O Ports 142
    • Push My Buttons 144
    • Let There Be Lights 146
    • Lights, Action, 147
    • Bright Ideas 148
    • 2n2^n Shades of Gray 149

Contents in Detail xiii

Quadrature 150
Parallel Communication 152
Serial Communication 152
Catch a Wave 154
Universal Serial Bus 156
Networking 156
 Modern LANs 158
 The Internet 158
Analog in the Digital World 160
 Digital-to-Analog Conversion 160
 Analog-to-Digital Conversion 162
 Digital Audio 165
 Digital Images 173
 Video 174
Human Interface Devices 176
 Terminals 176
 Graphics Terminals 177
 Vector Graphics 178
 Raster Graphics 180
 Keyboard and Mouse 181
Summary 181

Primitive Data Types 184
Arrays 185
Bitmaps 187
Strings 188
Compound Data Types 189
Singly Linked Lists 191
Dynamic Memory Allocation 195
More Efficient Memory Allocation 196
Garbage Collection 197
Doubly Linked Lists 198
Hierarchical Data Structures 199
Storage for the Masses 203
Databases 204
Indices 206
Moving Data Around 206
Vectored I/O 210
Object-Oriented Pitfalls 211
Sorting 212
Making a Hash of Things 213
Efficiency vs. Performance 215
Summary 216

Assembly Language 217
High-Level Languages 219

xiv Contents in Detail

Structured Programming 220
Lexical Analysis 221
 State Machines 223
 Regular Expressions 224
From Words to Sentences 226
The Language-of-the-Day Club 228
Parse Trees 228
Interpreters 231
Compilers 232
Optimization 234
Be Careful with Hardware 236
Summary 236

Markup Languages 238
Uniform Resource Locators 239
HTML Documents 240
The Document Object Model 242
 Tree Lexicon 243
 Interpreting the DOM 244
Cascading Style Sheets 244
XML and Friends 248
JavaScript 251
jQuery 253
SVG 254
HTML5 255
JSON 255
Summary 256

Guess the Animal Version 1: HTML and JavaScript 262
 Application-Level Skeleton 263
 Web Page Body 263
 The JavaScript 264
 The CSS 267
Guess the Animal Version 2: C 267
 Terminals and the Command Line 267
 Building the Program 268
 Terminals and Device Drivers 268
 Context Switching 269
 Standard I/O 271
 Circular Buffers 272
 Better Code Through Good Abstractions 273
 Some Mechanics 274
 Buffer Overflow 275
 The C Program 275
 Training 281
Summary 282

Contents in Detail xv

  • Table Lookup
    • Conversion
    • Texture Mapping
    • Character Classification
  • Integer Methods
    • Straight Lines
    • Curves Ahead
    • Polynomials
  • Recursive Subdivision
    • Spirals
    • Constructive Geometry
    • Shifting and Masking
  • More Math Avoidance
    • Power Series Approximations
    • The CORDIC Algorithm
  • Somewhat Random Things
    • Space-Filling Curves
    • L-Systems
    • Going Stochastic
    • Quantization
  • Summary
  • What Is a Race Condition?
  • Shared Resources
  • Processes and Threads
  • Locks
    • Transactions and Granularity
    • Waiting for a Lock
    • Deadlocks
    • Short-Term Lock Implementation
    • Long-Term Lock Implementation
  • Browser JavaScript
  • Asynchronous Functions and Promises
  • Summary
  • Overview of Security and Privacy
    • Threat Model
    • Trust
    • Physical Security
    • Communications Security
    • Modern Times

Metadata and Surveillance 359
The Social Context 359
Authentication and Authorization 361
Cryptography 362
 Steganography 362
 Substitution Ciphers 363
 Transposition Ciphers 365
 More Complex Ciphers 366
 One-Time Pads 367
 The Key Exchange Problem 367
 Public Key Cryptography 368
 Forward Secrecy 369
 Cryptographic Hash Functions 369
 Digital Signatures 370
 Public Key Infrastructure 370
 Blockchain 371
 Password Management 371
Software Hygiene 372
 Protect the Right Stuff 372
 Triple-Check Your Logic 373
 Check for Errors 373
 Minimize Attack Surfaces 373
 Stay in Bounds 374
 Generating Good Random Numbers Is Hard 375
 Know Thy Code 376
 Extreme Cleverness Is Your Enemy 378
 Understand What’s Visible 378
 Don’t Overcollect 379
 Don’t Hoard 379
 Dynamic Memory Allocation Isn’t Your Friend 379
 Garbage Collection Is Not Your Friend Either 381
 Data as Code 382
Summary 384

Overview 386
Machine Learning 388
 Bayes 389
 Gauss 390
 Sobel 393
 Canny 398
 Feature Extraction 399
 Neural Networks 401
 Using Machine Learning Data 406
Artificial Intelligence 407
Big Data 409
Summary 412

Contents in Detail xvii

The Value Proposition … 414
How We Got Here … 416
 A Short History … 416
 Open Source Software … 419
 Creative Commons … 420
 The Rise of Portability … 420
 Package Management … 421
 Containers … 422
 Java … 422
 Node.js … 424
 Cloud Computing … 424
 Virtual Machines … 425
 Portable Devices … 425
The Programming Environment … 425
 Are You Experienced? … 426
 Learning to Estimate … 426
 Scheduling Projects … 426
 Decision Making … 427
 Working with Different Personalities … 428
 Navigating Workplace Culture … 429
 Making Informed Choices … 430
Development Methodologies … 430
Project Design … 432
 Writing It Down … 432
 Fast Prototyping … 432
 Interface Design … 433
 Reusing Code or Writing Your Own … 436
Project Development … 436
 The Talk … 437
 Portable Code … 439
 Source Control … 440
 Testing … 440
 Bug Reporting and Tracking … 441
 Refactoring … 441
 Maintenance … 441
Be Stylish … 442
Fix, Don’t Re-create … 443
Summary … 444

445


xviii Contents in Detail