Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Randall Hyde

Rating No ratings yet

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 langua

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A practical bridge between high-level source code and the machine code compilers actually emit, teaching you to write HLL that compilers can translate into efficient, elegant assembly. Best for working developers in C, C++, Swift, Java, or similar who want performance insight without becoming full-time assembly programmers. 【Book Arc】 - **Opening (~0%–10%)**: Frames the core premise—compilers are only as good as the source you feed them—and argues why a little assembly knowledge pays off even for HLL developers. - **Early (~10%–33%)**: Builds the minimum assembly foundation (80x86 registers, addressing modes, constants, data declarations) so you can read compiler output rather than write assembly from scratch. - **Middle (~33%–57%)**: Explains how compilers work internally—translation phases, optimization, object/executable file formats, linkers—and how constants and variables are laid out in memory. - **Late (~57%–85%)**: Moves into code generation for real constructs: control structures, expressions, arrays, strings, and functions/procedures, showing what machine code each HLL choice produces. - **Ending (~85%–100%)**: Closes with an engineering-software afterword and glossary, tying low-level reasoning back to everyday design decisions. 【Key Takeaways】 - **Compilers are only as good as your source** (Opening): Sloppy HLL constructs force weak machine code; understanding the translation pipeline lets you write code compilers optimize well. - **Enough assembly to read, not to write** (Early): Registers, addressing modes, and data declarations are taught as a reading skill for inspecting compiler output. - **Know your toolchain** (Middle): Compiler phases, optimization passes, object file formats (COFF), and linker behavior all shape the final binary. - **Constants and variables have machine-level costs** (Middle): How integers, floats, characters, booleans, and their storage classes (static, automatic, dynamic) map to memory affects performance. - **Control structures generate predictable patterns** (Late): Knowing the assembly idioms for conditionals and loops helps you pick the HLL construct that compiles cleanest. - **Functions and procedures carry overhead** (Late): Calling conventions, parameter passing, and stack frames explain why some abstractions are cheaper than others. - **Language-neutral mindset** (Throughout): The reasoning applies across Swift, Java, C/C++, and stack-based targets like the JVM and Microsoft runtime, not just one language. 【Reading Tips】 - Deep-read the early assembly chapters even if you never plan to write assembly—they are the vocabulary for everything later. - Skim the object-file-format and linker details on a first pass; return when you actually need to debug binary size or alignment. - Keep a compiler open alongside the book: generate assembly output (`-S`, `/FA`, `objdump`) and compare it to the patterns described. - Treat the constants/variables chapters as a reference; revisit them when tuning memory layout or data structure choices. - Don't expect language-specific recipes—extract the general principle and apply it to your own stack. 【Coverage Limits】 This guide is synthesized from front matter, table of contents, and early/middle excerpts; the excerpts do not cover the detailed content of the later code-generation chapters or the afterword, so specifics there are inferred from chapter titles only.
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...
View in text
Page 9
ter 15: Functions and Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535 Afterword: Engineering Software . . . . . . . . . ....
View in text
Page 12
37 3 .6 Declaring Data in Assembly Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 3 .6 .1 Data Declarations in HLA . . . . . . . ....
View in text
Page 13
mp Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 5 .4 Using a Disassembler to Analyze Compiler Output . . . . . . . . . . . . . . . . ....
View in text
Page 9
RAY DATA TYPES 225 8 .1 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 8 .1 .1 Array Decl...
View in text
Page 16
tion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 11 RECORD, UNION, AND CLASS DATA TYPES 331 11 .1 Records . . . . ....
View in text
Page 17
50 13 CONTROL STRUCTURES AND PROGRAMMATIC DECISIONS 451 13 .1 How Control Structures Affect a Program’s Efficiency . . . . . . . . . . . . . . . . . . . 452...
View in text
Page 18
. . . . . . . . . . . . . . . . . . . . . . . . 585 15 .5 .6 Java VM and Microsoft CLR Parameters and Locals . . . . . . . . . . . . 587 15 .6 Parameter-Pass...
View in text
Tags
AI categories
Programming LanguageC++C#
ISBN: 1718500386
Publisher: No Starch Press
Publish Year: 2020
Language: English
Pages: 660
File Format: PDF
File Size: 4.7 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…