ENGLISH

The Secret Life of Programs: Understand Computers -- Craft Better Code

Book information

Publisher
No Starch Press
Year
2019
ISBN
1593279701, 9781593279707
Language
english
Format
PDF
Filesize
16 MB (16259238 bytes)
Pages
504\506
Time added
2020-07-27 17:33:20

Description

A primer on the underlying technologies that allow computer programs to work. Covers topics like computer hardware, combinatorial logic, sequential logic, computer architecture, computer anatomy, and Input/Output. Many coders are unfamiliar with the underlying technologies that make their programs run. But why should you care when your code appears to work? Because you want it to run well and not be riddled with hard-to-find bugs. You don't want to be in the news because your code had a security problem. Lots of technical detail is available online but it's not organized or collected into a convenient place. In The Secret Life of Programs, veteran engineer Jonathan E. Steinhart explores--in depth--the foundational concepts that underlie the machine. Subjects like computer hardware, how software behaves on hardware, as well as how people have solved problems using technology over time. You'll learn:   •  How the real world is converted into a form that computers understand, like bits, logic, numbers, text, and colors   •  The fundamental building blocks that make up a computer including logic gates, adders, decoders, registers, and memory   •  Why designing programs to match computer hardware, especially memory, improves performance   •  How programs are converted into machine language that computers understand   •  How software building blocks are combined to create programs like web browsers   •  Clever tricks for making programs more efficient, like loop invariance, strength reduction, and recursive subdivision   •  The fundamentals of computer security and machine intelligence   •  Project design, documentation, scheduling, portability, maintenance, and other practical programming realities. Learn what really happens when your code runs on the machine and you'll learn to craft better, more efficient code. Brief Contents Contents in Detail Acknowledgments Preface Introduction Why Good Programming is Important Learning to Code is Only a Starting Place Importance of Low-Level Knowledge Who Should Read This Book? What Are Computers? What Is Computer Programming? Coding, Programming, Engineering, and Computer Science The Landscape What’s in This Book Chapter 1: The Internal Language of Computers What Is Language? Written Language The Bit Logic Operations Boolean Algebra De Morgan’s Law Representing Integers Using Bits Representing Positive Numbers Binary Addition Representing Negative Numbers Representing Real Numbers Fixed-Point Representation Floating-Point Representation The IEEE Floating-Point Standard Binary-Coded Decimal System Easier Ways to Work with Binary Numbers Octal Representation Hexadecimal Representation Representing the Context Naming Groups of Bits Representing Text The American Standard Code for Information Interchange The Evolution of Other Standards Unicode Transformation Format 8-bit Using Characters to Represent Numbers Quoted-Printable Encoding Base64 Encoding URL Encoding Representing Colors Adding Transparency Encoding Colors Summary Chapter 2: Combinatorial Logic The Case for Digital Computers The Difference Between Analog and Digital Why Size Matters in Hardware Digital Makes for More Stable Devices Digital in an Analog World Why Bits Are Used Instead of Digits A Short Primer on Electricity Using Plumbing to Understand Electricity Electrical Switches Building Hardware for Bits Relays Vacuum Tubes Transistors Integrated Circuits Logic Gates Improving Noise Immunity with Hysteresis Differential Signaling Propagation Delay Output Variations Building More Complicated Circuits Building an Adder Building Decoders Building Demultiplexers Building Selectors Summary Chapter 3: Sequential Logic Representing Time Oscillators Clocks Latches Gated Latches Flip-Flops Counters Registers Memory Organization and Addressing Random-Access Memory Read-Only Memory Block Devices Flash Memory and Solid State Disks Error Detection and Correction Hardware vs. Software Summary Chapter 4: Computer Anatomy Memory Input and Output The Central Processing Unit Arithmetic and Logic Unit Shiftiness Execution Unit Instruction Set Instructions Addressing Modes Condition Code Instructions Branching Final Instruction Set The Final Design The Instruction Register Data Paths and Control Signals Traffic Control RISC vs. CISC Instruction Sets Graphics Processing Units Summary Chapter 5: Computer Architecture Basic Architectural Elements Processor Cores Microprocessors and Microcomputers Procedures, Subroutines, and Functions Stacks Interrupts Relative Addressing Memory Management Units Virtual Memory System and User Space Memory Hierarchy and Performance Coprocessors Arranging Data in Memory Running Programs Memory Power Summary Chapter 6: Communications Breakdown Low-Level I/O I/O Ports Push My Buttons Let There Be Lights Lights, Action, . . . Bright Ideas 2n Shades of Gray Quadrature Parallel Communication Serial Communication Catch a Wave Universal Serial Bus Networking Modern LANs The Internet Analog in the Digital World Digital-to-Analog Conversion Analog-to-Digital Conversion Digital Audio Digital Images Video Human Interface Devices Terminals Graphics Terminals Vector Graphics Raster Graphics Keyboard and Mouse Summary Chapter 7: Organizing Data Primitive Data Types Arrays Bitmaps Strings Compound Data Types Singly Linked Lists Dynamic Memory Allocation More Efficient Memory Allocation Garbage Collection Doubly Linked Lists Hierarchical Data Structures Storage for the Masses Databases Indices Moving Data Around Vectored I/O Object-Oriented Pitfalls Sorting Making a Hash of Things Efficiency vs. Performance Summary Chapter 8: Language Processing Assembly Language High-Level Languages Structured Programming Lexical Analysis State Machines Regular Expressions From Words to Sentences The Language-of-the-Day Club Parse Trees Interpreters Compilers Optimization Be Careful with Hardware Summary Chapter 9: The Web Browser Markup Languages Uniform Resource Locators HTML Documents The Document Object Model Tree Lexicon Interpreting the DOM Cascading Style Sheets XML and Friends JavaScript jQuery SVG HTML5 JSON Summary Chapter 10: Application and System Programming Guess the Animal Version 1: HTML and JavaScript Application-Level Skeleton Web Page Body The JavaScript The CSS Guess the Animal Version 2: C Terminals and the Command Line Building the Program Terminals and Device Drivers Context Switching Standard I/O Circular Buffers Better Code Through Good Abstractions Some Mechanics Buffer Overflow The C Program Training Summary Chapter 11: Shortcuts and Approximations 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 Chapter 12: Deadlocks and Race Conditions 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 Chapter 13: Security Overview of Security and Privacy Threat Model Trust Physical Security Communications Security Modern Times Metadata and Surveillance The Social Context Authentication and Authorization Cryptography Steganography Substitution Ciphers Transposition Ciphers More Complex Ciphers One-Time Pads The Key Exchange Problem Public Key Cryptography Forward Secrecy Cryptographic Hash Functions Digital Signatures Public Key Infrastructure Blockchain Password Management Software Hygiene Protect the Right Stuff Triple-Check Your Logic Check for Errors Minimize Attack Surfaces Stay in Bounds Generating Good Random Numbers Is Hard Know Thy Code Extreme Cleverness Is Your Enemy Understand What’s Visible Don’t Overcollect Don’t Hoard Dynamic Memory Allocation Isn't Your Friend Garbage Collection Is Not Your Friend Either Data as Code Summary Chapter 14: Machine Intelligence Overview Machine Learning Bayes Gauss Sobel Canny Feature Extraction Neural Networks Using Machine Learning Data Artificial Intelligence Big Data Summary Chapter 15: Real-World Considerations The Value Proposition How We Got Here A Short History Open Source Software Creative Commons The Rise of Portability Package Management Containers Java Node.js Cloud Computing Virtual Machines Portable Devices The Programming Environment Are You Experienced? Learning to Estimate Scheduling Projects Decision Making Working with Different Personalities Navigating Workplace Culture Making Informed Choices Development Methodologies Project Design Writing It Down Fast Prototyping Interface Design Reusing Code or Writing Your Own Project Development The Talk Portable Code Source Control Testing Bug Reporting and Tracking Refactoring Maintenance Be Stylish Fix, Don’t Re-create Summary Index

Similar books