Thinking Low-Level, Writing High-Level, the second volume in the landmark Write Great Code series by Randall Hyde, covers high-level programming languages (such as Swift and Java) as well as code generation on 64-bit CPUsARM, the Java Virtual Machine, and the Microsoft Common Runtime. Today's programming languages offer productivity and portability, but also make it easy to write sloppy code that isn't optimized for a compiler. Thinking Low-Level, Writing High-Level will teach you to craft source code that results in good machine code once it's run through a compiler. You'll learn: How to analyze the output of a compiler to verify that your code generates good machine code The types of machine code statements that compilers generate for common control structures, so you can choose the best statements when writing HLL code Enough assembly language to read compiler output How compilers convert various constant and variable objects into machine data With an understanding of how compilers work, you'll be able to write source code that they can translate into elegant machine code. NEW TO THIS EDITION, COVERAGE OF: Programming languages like Swift and Java Code generation on modern 64-bit CPUs ARM processors on mobile phones and tablets Stack-based architectures like the Java Virtual Machine Modern language systems like the Microsoft Common Language Runtime
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
# Write Great Code, Volume 2, 2nd Edition — Reading Guide
## 【One-Line Pitch】
A practical bridge between high-level programming and the machine code your compiler actually generates, teaching you to read assembly output and write source code that compiles into efficient, elegant machine instructions. Essential reading for working developers who want performance insight without becoming assembly-language experts.
## 【Book Arc】
- **Opening (~0%–10%)**: Establishes the book's core philosophy—that compilers are only as good as the source code they're given—and makes the case for why learning assembly language remains valuable even in an era of high-level productivity. Includes endorsements and the author's credentials as a veteran embedded systems engineer.
- **Early (~19%–33%)**: Introduces the 80x86 architecture for HLL programmers, covering registers, addressing modes, literal constants, and data declarations across three assembly syntaxes (HLA, MASM, and GAS). This section builds the foundational vocabulary needed to read compiler output.
- **Middle (~38%–52%)**: Explains how compilers actually work—from scanning and parsing through optimization and code generation—then shows you the tools (GNU compilers, Visual C++, dumpbin, objdump) for analyzing what your compiler produces. Includes detailed coverage of object file formats like COFF and executable formats.
- **Middle (~52%–57%)**: Dives into how compilers handle constants and variables, covering runtime memory organization (code, static, stack, and heap sections), variable binding and lifetime, and the trade-offs between static, automatic, and dynamic storage allocation.
- **Late (~57% onward)**: Continues with variable storage strategies, primitive data types, and memory alignment considerations—showing how high-level declarations translate into concrete machine-level data layouts and how to make choices that reduce instruction size and improve performance.
## 【Key Takeaways】
- **Compilers are only as good as your source code** (Early): The quality of generated machine code depends heavily on what you feed the compiler—garbage in, garbage out applies at the machine-code level too. This reframes performance optimization as a source-writing skill rather than a compiler-tuning problem.
- **Learning assembly is still worth it, but you don't need to master it** (Early): You need enough assembly to *read* compiler output, not to write programs from scratch. The book's "high-level assembler" approach (HLA) lowers the barrier for HLL programmers who want to peek under the hood.
- **Understanding addressing modes reveals performance traps** (Early): The 80x86's register, immediate, displacement-only, RIP-relative, indexed, and scaled-index addressing modes each have different costs and constraints. Knowing which mode your HLL code triggers helps you write source that avoids expensive memory access patterns.
- **Compiler pipelines follow a predictable path** (Middle): Scanning → parsing → intermediate code generation → optimization → native code generation. Understanding this pipeline demystifies why certain HLL constructs produce better or worse machine code, and why optimization is not magic.
- **Object file formats matter for performance** (Middle): COFF headers, section alignment, internal fragmentation, and how linkers combine sections all affect final executable size and speed. Space optimization is sometimes the right call—especially for embedded or memory-constrained environments.
- **Variable storage classes have real performance implications** (Middle): Static, automatic (stack-based), and dynamic (heap-based) variables each carry different costs in terms of offset sizes, access speed, and lifetime management. Choosing the right storage class for the right situation is a concrete, actionable optimization.
- **Memory alignment is not optional** (Middle): Misaligned variables can cause performance penalties or outright faults on some architectures. Understanding how records and structures align in memory lets you design data layouts that the compiler can access efficiently.
## 【Reading Tips】
- **Skim the assembly syntax chapters (3) if you already know one assembler**: The book covers HLA, MASM, and GAS in parallel. If you're comfortable with one syntax, focus on the differences rather than reading every example line-by-line.
- **Deep-read the compiler operation chapter (4)**: This is the conceptual heart of the book. Understanding the translation pipeline and object file formats will pay off in every subsequent chapter.
- **Do the hands-on exercises in chapter 5**: The tools section (dumpbin, objdump, compiler assembly output flags) is meant to be practiced, not just read. Generate assembly output from your own code and compare it against the book's examples.
- **Treat chapters 6–7 as reference material**: The constant and variable chapters are dense with specifics. Read them once for the big picture, then return to them when you're optimizing a particular piece of code.
- **Pair with Volume 1 if you're new to machine architecture**: This volume assumes some familiarity with low-level concepts. If terms like "RIP-relative addressing" feel foreign, consider reviewing the first volume's coverage of CPU architecture.
## 【Coverage Limits】
This guide is based on the book's table of contents and early/middle chapters; the later chapters on control structures, arithmetic, and functions (chapters 8–15) are not covered in detail here. The excerpts do not include the book's treatment of ARM processors, the JVM, or the Microsoft Common Language Runtime, despite those being advertised as new to this edition.
##
Page 3
that you master what is in these pages. Then read it again.” —DevCity “Write Great Code, Volume 2, exceeds its goal of helping developers pay more attention ...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Write Great Code, Volume 2, 2nd Edition (Randall Hyde)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Write Great Code, Volume 2, 2nd Edition (Randall Hyde)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment