26,99 €
Let there be code! Beginning Programming All-in-One For Dummies offers one guide packed with 7 books to teach you programming across multiple languages. Coding can seem complex and convoluted, but Dummies makes it simple and easy to understand. You'll learn all about the principles of programming, algorithms, data structures, debugging programs, unique applications of programming and more while learning about some of the most popular programming languages used today. Move confidently forward in your computer science coursework or straight into the workforce. You'll come away with a rock-solid foundation in the programming basics, using data, coding for the web, and building killer apps. * Learn the basics of coding, including writing and compiling code, using algorithms, and data structures * Get comfortable with the syntax of several different programming languages * Wrap your mind around interesting programming opportunities such as conducting biological experiments within a computer or programming a video game engine * Develop cross-platform applications for desktop and mobile devices This essential guide takes the complexity and convolution out of programming for beginners and arms you with the knowledge you need to follow where the code takes you.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 990
Veröffentlichungsjahr: 2022
Beginning Programming All-in-One For Dummies®, 2nd Edition
Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com
Copyright © 2022 by John Wiley & Sons, Inc., Hoboken, New Jersey
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND AUTHORS HAVE USED THEIR BEST EFFORTS IN PREPARING THIS WORK, THEY MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES, WRITTEN SALES MATERIALS OR PROMOTIONAL STATEMENTS FOR THIS WORK. THE FACT THAT AN ORGANIZATION, WEBSITE, OR PRODUCT IS REFERRED TO IN THIS WORK AS A CITATION AND/OR POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE PUBLISHER AND AUTHORS ENDORSE THE INFORMATION OR SERVICES THE ORGANIZATION, WEBSITE, OR PRODUCT MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING PROFESSIONAL SERVICES. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR YOUR SITUATION. YOU SHOULD CONSULT WITH A SPECIALIST WHERE APPROPRIATE. FURTHER, READERS SHOULD BE AWARE THAT WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. NEITHER THE PUBLISHER NOR AUTHORS SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit https://hub.wiley.com/community/support/dummies.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2022936302
ISBN 978-1-119-88440-8 (pbk); ISBN 978-1-119-88441-5 (ebk); ISBN 978-1-119-88442-2 (ebk)
Cover
Title Page
Copyright
Introduction
About This Book
Foolish Assumptions
Icons Used in This Book
Beyond the Book
Where to Go from Here
Book 1: Getting Started with Programming
Chapter 1: Getting Started Programming a Computer
How Computer Programming Works
The History of Computer Programming
Figuring Out Programming
Chapter 2: Different Methods for Writing Programs
Spaghetti Programming
Structured Programming
Event-Driven Programming
Object-Oriented Programming
Using Protocol-Oriented Programming
Design Patterns
Chapter 3: Types of Programming Languages
Your First Language
Curly-Bracket Languages
Artificial Intelligence Languages
Scripting Languages
Database Programming Languages
Comparing Programming Languages
Chapter 4: Programming Tools
Choosing a Compiler
Finding an Interpreter
Compiling to a Virtual Machine
Writing a Program with an Editor
Fixing a Program with a Debugger
Saving Time with Third-Party Components
Optimizing a Program with a Profiler
Managing Source Code
Creating a Help File
Installing a Program
Dissecting Programs with a Disassembler
Book 2: Programming Basics
Chapter 1: How Programs Work
Using Keywords as Building Blocks
Organizing a Program
Dividing a Program into Subprograms
Dividing a Program into Objects
Creating a User Interface
Chapter 2: Variables, Data Types, and Constants
Declaring Variables
Using Different Data Types
Storing Data in a Variable
Retrieving Data from a Variable
Using Constant Values
Defining the Scope of a Variable
Chapter 3: Manipulating Data
Storing Data with the Assignment Operator
Using Math to Manipulate Numbers
Manipulating Strings
Finding Strings with Regular Expressions
Using Comparison Operators
Using Boolean Operators
Converting Data Types
Chapter 4: Making Decisions by Branching
Picking One Choice with the IF-THEN Statement
Picking Two Choices with the IF-THEN-ELSE Statement
Picking Three or More Choices with the IF-THEN-ELSEIF Statement
Playing with Multiple Boolean Operators
Making Multiple Choices with the SELECT CASE Statement
Chapter 5: Repeating Commands by Looping
Looping a Fixed Number of Times with the FOR-NEXT Loop
Looping Zero or More Times with the WHILE Loop
Looping at Least Once with the DO Loop
Playing with Nested Loops
Prematurely Exiting from a Loop
Checking Your Loops
Chapter 6: Breaking a Large Program into Subprograms
Creating and Using Subprograms
Passing Parameters
Repeating a Subprogram with Recursion
Chapter 7: Breaking a Large Program into Objects
How Object-Oriented Programming Works
Encapsulation Isolates Data and Subprograms
Sharing Code with Inheritance
Polymorphism: Modifying Code without Changing Its Name
Design Patterns
Object-Oriented Languages
Real-Life Programming Examples
Chapter 8: Reading and Saving Files
Storing Data in Text Files
Storing Fixed-Size Data in Random-Access Files
Storing Varying-Size Data in Untyped Files
Using Database Files
Chapter 9: Documenting Your Program
Adding Comments to Source Code
Writing Software Documentation
Chapter 10: Principles of User Interface Design
The Evolution of User Interfaces
Elements of a User Interface
Designing a User Interface
Chapter 11: Debugging and Testing
Common Types of Programming Errors
Debugging with Comments and Print Statements
Breakpoints, Stepping, and Watching
Testing Code
Book 3: Data Structures
Chapter 1: Structures and Arrays
Using Structures
Using an Array
Working with Resizable Arrays
Working with Multidimensional Arrays
Using Structures with Arrays
Drawbacks of Arrays
Chapter 2: Sets and Linked Lists
Using Sets
Using Linked Lists
Drawbacks of Sets and Linked Lists
Chapter 3: Collections and Dictionaries
Using a Collection
Using Dictionaries
Understanding Hash Tables
Chapter 4: Stacks, Queues, and Deques
Using Stacks
Using Queues
Using Deques
Chapter 5: Graphs and Trees
Understanding Graphs
Creating Trees
Taking Action on Trees
Book 4: Algorithms
Chapter 1: Sorting Algorithms
Using Bubble Sort
Using Selection Sort
Using Insertion Sort
Using Shell Sort
Using Heap Sort
Using Merge Sort
Using Quick Sort
Comparing Sorting Algorithms
Chapter 2: Searching Algorithms
Sequential Search
Using Indexes
Adversarial Search
Chapter 3: String Searching
Sequential Text Search
Searching with Regular Expressions
Searching Phonetically
Chapter 4: Data Compression Algorithms
Lossless Data Compression Algorithms
Lossy Data Compression
Chapter 5: Encryption Algorithms
How Encryption Works
The Basics of Encryption
Symmetric/Asymmetric Encryption Algorithms
Cracking Encryption
Book 5: Web Programming
Chapter 1: HyperText Markup Language
The Structure of an HTML Document
Adding Graphics
Defining the Background
Creating Hyperlinks
Making Tables
Chapter 2: CSS
The Structure of a Stylesheet
Creating Style Classes
Separating Styles in Files
Cascading Stylesheets
Chapter 3: JavaScript
The Structure of a JavaScript Program
Creating Comments
Declaring Variables
Using Operators
Branching Statements
Looping Statements
Creating Functions
Using Arrays
Designing User Interfaces
Chapter 4: PHP
Examining the Structure of a PHP Program
Creating Comments
Declaring Variables
Using Operators
Branching Statements
Looping Statements
Creating Functions
Using Arrays
Creating Objects
Chapter 5: Ruby
The Structure of a Ruby Program
Creating Comments
Declaring Variables
Using Operators
Branching Statements
Looping Statements
Creating Functions
Using Data Structures
Creating Objects
Book 6: Programming Language Syntax
Chapter 1: C and C++
Looking at the Structure of a C/C++ Program
Creating Comments
Declaring Variables
Using Operators
Branching Statements
Looping Statements
Creating Functions
Data Structures
Using Objects
Chapter 2: Java and C#
Looking at the Structure of a Java/C# Program
Creating Comments
Declaring Variables
Using Operators
Branching Statements
Looping Statements
Creating Functions
Data Structures
Using Objects
Chapter 3: Perl and Python
Reviewing the Structure of a Perl or Python Program
Creating Comments
Defining Variables
Using Operators
Branching Statements
Looping Statements
Creating Functions
Making Data Structures
Using Objects
Chapter 4: Kotlin
Looking at the Structure of a Kotlin Program
Creating Comments
Declaring Variables
Declaring Constants
Using Operators
Branching Statements
Looping Statements
Creating Functions
Creating Data Structures
Creating Objects
Chapter 5: Swift and SwiftUI
Considering the Structure of a Swift Program
Creating Comments
Declaring Variables
Declaring Constants
Using Operators
Branching Statements
Looping Statements
Creating Functions
Data Structures
Creating Objects
Chapter 6: Flutter and Dart
Working with Flutter
Understanding the Dart Language
Book 7: Applications
Chapter 1: Database Management
Understanding the Basics of Databases
Manipulating Data
Database Programming
Chapter 2: Bioinformatics
The Basics of Bioinformatics
Database Searches
Bioinformatics Programming
Chapter 3: Computer Security
Stopping Malware
Stopping Hackers
Secure Computing
Chapter 4: Artificial Intelligence
Problem Solving
Machine Learning
Applications of Artificial Intelligence
Chapter 5: Mobile and Wearable Computing
Understanding the Different Generations of Computing
Giving Data to the User
Getting Data from the User
Tracking Motion and Location
Tracking Real-Time Health Data
Looking to the Future of Augmented Reality and Wearable Computers
Chapter 6: Game Engines
Understanding Game Engines
Picking a Game Engine
Programming a Game Engine
Exploring the Future Uses of Game Engines
Chapter 7: The Future of Computer Programming
Picking a Programming Language
Picking an Operating System
Doing Cross-Platform Programming
Defining Your Future in Programming
Index
About the Author
Advertisement Page
Connect with Dummies
End User License Agreement
Book 1 Chapter 3
TABLE 3-1 Popular “Battling Robot” Programming Games
Book 2 Chapter 2
TABLE 2-1 Typical Storage Requirements for Different Data Types
Book 2 Chapter 3
TABLE 3-1 Examples of Using the Assignment (=) Operator
TABLE 3-2 Common Mathematical Operators
TABLE 3-3 Operator Precedence
TABLE 3-4 Common Built-In Math Functions
TABLE 3-5 Common Built-In String Functions
TABLE 3-6 Examples of Pattern-Matching with Different Regular Expressions
TABLE 3-7 Common Comparison Operators
TABLE 3-8 The And Truth Table
TABLE 3-9 The Or Truth Table
TABLE 3-10 The Xor Truth Table
Book 2 Chapter 4
TABLE 4-1 Multiple Boolean Expressions Ultimately Evaluate to a Single True or F...
Book 2 Chapter 5
TABLE 5-1 A Database of Employee Names Assigned with Specific Employee ID Number...
Book 4 Chapter 1
TABLE 1-1 Comparison of Different Sorting Algorithms
Book 4 Chapter 3
TABLE 3-1 Single Pattern Regular Expressions
TABLE 3-2 Calculating a Soundex Code
Book 4 Chapter 4
TABLE 4-1 Rotating and Sorting Data
Book 5 Chapter 1
TABLE 1-1 HTML Color Codes
Book 5 Chapter 3
TABLE 3-1 Mathematical Operators
TABLE 3-2 Relational Operators
TABLE 3-3 Logical Operators
TABLE 3-4 Assignment Operators
Book 5 Chapter 4
TABLE 4-1 Mathematical Operators
TABLE 4-2 Relational Operators
TABLE 4-3 Logical operators
TABLE 4-4 Assignment Operators
Book 5 Chapter 5
TABLE 5-1 Mathematical Operators
TABLE 5-2 Relational Operators
TABLE 5-3 Logical Operators
TABLE 5-4 Assignment Operators
Book 6 Chapter 1
TABLE 1-1
Typical Storage and Range Limitations of C/C++ Integer Data Types
TABLE 1-2
Typical Floating-Point Data Types
TABLE 1-3
Mathematical Operators
TABLE 1-4
Relational Operators
TABLE 1-5
Logical Operators
TABLE 1-6
Assignment Operators
Book 6 Chapter 2
TABLE 2-1 Typical Storage and Range Limitations of Java Integer Data Types
TABLE 2-2 Typical Storage and Range Limitations of C# Integer Data Types
TABLE 2-3 Typical Floating Point-Data Types
TABLE 2-4 Mathematical Operators
TABLE 2-5 Relational Operators
TABLE 2-6 Logical Operators
TABLE 2-7 Assignment Operators
Book 6 Chapter 3
TABLE 3-1 Mathematical Operators
TABLE 3-2 Relational Operators
TABLE 3-3 Using Perl's Comparison with Signed Result Operator
TABLE 3-4 Logical Operators
TABLE 3-5 Assignment Operators
Book 6 Chapter 4
TABLE 4-1 Kotlin Integer Data Types
TABLE 4-2 Kotlin Floating-Point Data Types
TABLE 4-3 Mathematical Operators
TABLE 4-4 Relational Operators
TABLE 4-5 Logical Operators
Book 6 Chapter 5
TABLE 5-1 Swift Integer Data Types
TABLE 5-2 Swift Decimal Data Types
TABLE 5-3 Mathematical Operators
TABLE 5-4 Relational Operators
TABLE 5-5 Logical Operators
Book 6 Chapter 6
TABLE 6-1 Mathematical Operators
TABLE 6-2 Relational Operators
TABLE 6-3 Logical Operators
TABLE 6-4 Assignment Operators
Book 7 Chapter 5
TABLE 5-1 Understanding the Different Generations of Computing
Book 1 Chapter 1
FIGURE 1-1: A processor uses its registers to temporarily store data.
FIGURE 1-2: An editor lets you write and edit the source code of a program.
Book 1 Chapter 2
FIGURE 2-1: Constantly modifying a program eventually creates an unorganized me...
FIGURE 2-2: Sequences consist of groups of commands that the computer follows, ...
FIGURE 2-3: Branches let the computer choose which group of commands to run at ...
FIGURE 2-4: You can store subprograms in one big file or in separate files.
FIGURE 2-5: Designing a UI involves drawing what you want to appear on your pro...
FIGURE 2-6: Properties define how each part of a UI looks and behaves.
FIGURE 2-7: An event handler tells the UI how to behave when the user does some...
FIGURE 2-8: Object-oriented programming never physically copies code but “point...
Book 1 Chapter 3
FIGURE 3-1: Programming in Scratch means connecting visual building blocks toge...
FIGURE 3-2: LEGO Mindstorms programming connects visual building blocks togethe...
FIGURE 3-3: An Alice program creates an animated character onscreen and moves i...
FIGURE 3-4: Using a battling robot to study programming can make programming mo...
FIGURE 3-5: The .NET framework can tie programs, written in multiple languages,...
FIGURE 3-6: Recording keystrokes automatically creates the equivalent VBA code ...
Book 1 Chapter 4
FIGURE 4-1: Compiler optimization settings let you make your program as small a...
FIGURE 4-2: A cross-compiler lets you write a program and compile it for multip...
FIGURE 4-3: The Flutter website lets you type and run code using any browser.
FIGURE 4-4: A virtual machine acts like a combination of an interpreter and a c...
FIGURE 4-5: An IDE provides access to multiple programming tools within a singl...
FIGURE 4-6: Stepping through a program, line-by-line, can help you find errors ...
FIGURE 4-7: Breakpoints let you skip over parts of your program that you don’t ...
FIGURE 4-8: The
step over
command lets you skip, or “step over,” the lines stor...
FIGURE 4-9: Watching and changing variables can show you how a program reacts t...
Book 2 Chapter 1
FIGURE 1-1: If you put enough commands together, you can create any type of pro...
FIGURE 1-2: Multiple keywords, along with various symbol characters, can create...
FIGURE 1-3: Dividing a large program into parts can make it easier to find spec...
FIGURE 1-4: Subprograms create reusable building blocks that you can use to mak...
FIGURE 1-5: Storing subprograms in separate files can make it easier to read an...
FIGURE 1-6: Subprograms give you the option of using different programming lang...
FIGURE 1-7: Changing one part of a program can affect other parts of that same ...
FIGURE 1-8: Object-oriented programming divides your program into logical parts...
FIGURE 1-9: The UI accepts data and displays the results of its calculations ba...
FIGURE 1-10: Creating a UI involves picking common items, such as buttons and c...
Book 2 Chapter 2
FIGURE 2-1: If a program tries to store the wrong type of data in a variable, t...
FIGURE 2-2: You can’t compile your program until the compiler is certain that y...
FIGURE 2-3: Different data types that can hold a range of values.
FIGURE 2-4: Assigning a new value to a variable wipes out the old value.
FIGURE 2-5: Every part of a program can access and change a global variable.
FIGURE 2-6: Module variables restrict access to code stored in a particular fil...
FIGURE 2-7: Subprogram variables restrict access only to code stored in that pa...
FIGURE 2-8: To share data among subprograms, you have to pass that data from on...
Book 2 Chapter 4
FIGURE 4-1: A simple
IF-THEN
statement runs one extra command if something is
T
...
FIGURE 4-2: An
IF-THEN-ELSE
statement offers two different sets of commands to ...
FIGURE 4-3: An
IF-THEN-ELSEIF
statement offers two different sets of commands t...
Book 2 Chapter 5
FIGURE 5-1: A loop can run one or more commands over and over.
FIGURE 5-2: The
WHILE
loop keeps running as long as a certain condition remains...
FIGURE 5-3: A nested loop appears inside another loop.
Book 2 Chapter 6
FIGURE 6-1: Every large program is made up of smaller subprograms that act as b...
FIGURE 6-2: Reusing subprograms can make writing new programs easier and faster...
FIGURE 6-3: Subprograms let you remove and isolate commands out of your main pr...
FIGURE 6-4: Subprograms usually appear at the beginning or end of a file.
FIGURE 6-5: When you call a subprogram, you may also need to pass parameters to...
FIGURE 6-6: Normally when you pass parameters to a subprogram, the computer mak...
FIGURE 6-7: Passing by reference means the subprogram can manipulate data that ...
FIGURE 6-8: Recursion makes multiple copies of the same subprogram.
Book 2 Chapter 7
FIGURE 7-1: Dividing a program into tasks can obscure the actual purpose of a p...
FIGURE 7-2: Object-oriented programming divides a large program into objects th...
FIGURE 7-3: The parts of a typical object.
FIGURE 7-4: Changing a subprogram can wreck a perfectly working program.
FIGURE 7-5: Encapsulation isolates a chunk of code as an independent object.
FIGURE 7-6: If you modify a subprogram, you need to create a separate copy of t...
FIGURE 7-7: Inheritance lets you reuse another object’s subprograms without phy...
FIGURE 7-8: Objects contain code that’s unique to only that object.
FIGURE 7-9: Polymorphism lets you reuse a method name in another object.
FIGURE 7-10: An interface pattern provides an object-oriented interface to a no...
FIGURE 7-11: The flyweight pattern simplifies objects that contain repetitive i...
FIGURE 7-12: The memento pattern uses one object to store information about ano...
Book 2 Chapter 8
FIGURE 8-1: A record organizes related data together.
FIGURE 8-2: The fixed size of each record makes it easy to identify the physica...
FIGURE 8-3: Untyped files contain records that can vary in size.
FIGURE 8-4: The computer can retrieve data from an untyped file in blocks or ch...
FIGURE 8-5: By defining which chunk of data you want to retrieve, you can retri...
FIGURE 8-6: Database files are divided into tables, and each table is further d...
FIGURE 8-7: Relational databases link tables to group logically related informa...
FIGURE 8-8: Database toolkits take care of the technical details of manipulatin...
FIGURE 8-9: A database toolkit can manipulate data using a familiar database la...
FIGURE 8-10: Programs often act as a front end to a database file.
Book 2 Chapter 10
FIGURE 10-1: The user interface lets you control a program, give it commands, a...
FIGURE 10-2: Early user interfaces were simple menus of keystroke combinations.
FIGURE 10-3: Drop-down lists help organize commands and tuck them out of sight ...
FIGURE 10-4: Buttons can display the entire command name for the user to see.
FIGURE 10-5: Submenus reduce the number of commands in a drop-down list but mak...
FIGURE 10-6: Icons, organized in toolbars, allow one-click access to multiple c...
FIGURE 10-7: Toolboxes provide another way to group icons for easy access.
FIGURE 10-8: Users can type any information inside a text box, including invali...
FIGURE 10-9: Radio buttons can display multiple choices, but they only let you ...
FIGURE 10-10: Check boxes can display multiple choices and allow users to pick ...
FIGURE 10-11: List boxes display a list of options.
FIGURE 10-12: Combo boxes let you either make a choice or type data directly.
FIGURE 10-13: A slider lets users visually choose a numeric value or setting by...
FIGURE 10-14: A user interface displays data in a window that users can manipul...
FIGURE 10-15: Dialog boxes ask the user for more data before carrying out a com...
FIGURE 10-16: Boxes draw lines to separate and organize different user interfac...
FIGURE 10-17: Tabs let you organize and display different user interface items ...
FIGURE 10-18: This program’s drop-down list lets you view a bunch of submenus t...
FIGURE 10-19: A cryptic error message is meaningless and frustrating because th...
FIGURE 10-20: Customization options let a user change the user interface to sui...
Book 2 Chapter 11
FIGURE 11-1: Code snippets can provide templates for writing common statements.
FIGURE 11-2: Code completion displays several commands so you can choose the on...
FIGURE 11-3: Breakpoints identify lines of code where you want the program to s...
FIGURE 11-4: Conditional breakpoints can halt execution only if specific condit...
FIGURE 11-5: You can often select different debugging information to use in a p...
Book 3 Chapter 1
FIGURE 1-1: A structure can contain multiple fields.
FIGURE 1-2: An array can hold multiple chunks of data.
FIGURE 1-3: One-based arrays number array elements differently than zero-based ...
FIGURE 1-4: Some programming languages let you define the numbering of an array...
FIGURE 1-5: By defining your own numbering for an array, you can make those num...
FIGURE 1-6: Resizing an array lets you expand or shrink an array.
FIGURE 1-7: A two-dimensional array lets you store data in a grid.
FIGURE 1-8: A structure can hold only one group of related data, but an array o...
FIGURE 1-9: An array of structures acts like a simple database.
FIGURE 1-10: Inserting data into an array means copying and moving data from on...
Book 3 Chapter 2
FIGURE 2-1: Adding and removing data in a set is easier than adding and removin...
FIGURE 2-2: The
union
command combines data from two sets to create a third set...
FIGURE 2-3: The
intersection
command takes only data common in both sets and st...
FIGURE 2-4: The
difference
command strips out data in common with a second set.
FIGURE 2-5: The order in which you list set names with the
difference
command d...
FIGURE 2-6: A node consists of a pointer and one or more variables to store dat...
FIGURE 2-7: A linked list stores data in each node that points to another node.
FIGURE 2-8: Rearranging the order of a linked list is as simple as rearranging ...
FIGURE 2-9: Adding data from a linked list also involves rearranging pointers.
FIGURE 2-10: Deleting data from a linked list involves removing data and then r...
FIGURE 2-11: A double linked list lets you traverse a linked list in both direc...
FIGURE 2-12: A circular linked list has no beginning or end.
FIGURE 2-13: Pointers must always point to a valid node of a linked list.
Book 3 Chapter 3
FIGURE 3-1: Collections expand automatically each time you store new data.
FIGURE 3-2: You can insert data before a specific location in an array.
FIGURE 3-3: You can insert new data after an existing location in a collection.
FIGURE 3-4: When you remove data from a collection, the collection renumbers th...
FIGURE 3-5: Identify data by its location or by a key.
FIGURE 3-6: Retrieving data by index numbers is unreliable because they can cha...
FIGURE 3-7: Hash tables make searching faster by dividing data into distinct se...
FIGURE 3-8: Hash tables convert each key into a numeric value.
FIGURE 3-9: Chaining lets a single hash value point to a list of multiple items...
FIGURE 3-10: Double hashing creates miniature hash tables within a larger hash ...
Book 3 Chapter 4
FIGURE 4-1: Stacks store the oldest data on the bottom and the newest data on t...
FIGURE 4-2: When you add data to a stack, the oldest data keeps getting pushed ...
FIGURE 4-3: The Peek command retrieves data, but the
Pop
command retrieves and ...
FIGURE 4-4: The
Undo
command offered in most programs can be easily implemented...
FIGURE 4-5: The queue data structure mimics a line of people.
FIGURE 4-6: The oldest data appears at the front while the newest data appears ...
FIGURE 4-7: The
Peek
command retrieves data, but the
Dequeue
command retrieves ...
FIGURE 4-8: A deque acts like a two-way queue.
FIGURE 4-9: Each node in a deque contains two pointers that point to the next a...
FIGURE 4-10: Two ways to implement a deque as a linked list.
FIGURE 4-11: A deque can grow in two different directions.
FIGURE 4-12: A deque could be used by an antivirus program to scan messages.
Book 3 Chapter 5
FIGURE 5-1: Modeling a map of different cities.
FIGURE 5-2: A graph data structure can model the mapping problem better than an...
FIGURE 5-3: The three types of graphs.
FIGURE 5-4: The Seven Bridges of Königsberg represented as a graph.
FIGURE 5-5: A tree is a hierarchical graph.
FIGURE 5-6: A tree consists of one root node and multiple leaf and internal nod...
FIGURE 5-7: A tree can organize names alphabetically by last name.
FIGURE 5-8: An ordered binary tree stores and sorts data by value.
FIGURE 5-9: An ordinary tree is more difficult to search than an ordered binary...
FIGURE 5-10: In a B-tree, all leaf nodes appear at the same level.
FIGURE 5-11: The four different ways to traverse a tree.
FIGURE 5-12: Inserting new data in an ordered binary tree.
FIGURE 5-13: After deleting data from a tree, you may need to rearrange the rem...
FIGURE 5-14: Pruning a tree removes two or more nodes from a tree.
FIGURE 5-15: Grafting a sub-tree can require rearranging the entire modified tr...
FIGURE 5-16: A tree can help a computer plan its next move.
Book 4 Chapter 1
FIGURE 1-1: A bubble sort repetitively compares two adjacent items.
FIGURE 1-2: The bubble sort algorithm examines the entire list of data several ...
FIGURE 1-3: Selection sort repetitively moves the smallest value to the front o...
FIGURE 1-4: Insertion sort only examines a list once to sort it.
FIGURE 1-5: Shell sort performs multiple insertion sorts on parts of a long lis...
FIGURE 1-6: Valid and invalid heap binary trees.
FIGURE 1-7: Heap sort uses a tree data structure to sort and store items tempor...
FIGURE 1-8: An array can mimic a heap data structure.
FIGURE 1-9: Manipulating data in an array that mimics a heap.
FIGURE 1-10: Merge sort breaks a long list into several smaller lists and then ...
FIGURE 1-11: Quick sort repetitively divides a large list into two smaller list...
Book 4 Chapter 2
FIGURE 2-1: The speed of sequential search depends directly on the size of the ...
FIGURE 2-2: Sequential search can be made faster by searching from either the f...
FIGURE 2-3: Block searching can speed up a sequential search on sorted data.
FIGURE 2-4: Binary searching divides a list in half until it eventually finds i...
FIGURE 2-5: Interpolation searching tries to jump straight to the approximate l...
FIGURE 2-6: Fibonacci numbers divide and search a list more efficiently than a ...
FIGURE 2-7: Comparison of hash tables and indexes.
FIGURE 2-8: Clustered indexes physically rearrange data, whereas unclustered in...
FIGURE 2-9: A tree can analyze the best possible move.
FIGURE 2-10: Assigning values to possible moves helps the computer evaluate the...
Book 4 Chapter 3
FIGURE 3-1: Sequential search examines every character.
FIGURE 3-2: The Boyer–Moore algorithm skips over partially matched characters.
FIGURE 3-3: The Rabin–Karp algorithm searches for hash values.
FIGURE 3-4: The Shift Or algorithm creates an array of matching characters.
FIGURE 3-5: The Shift Or algorithm creates a two-dimensional array.
FIGURE 3-6: A finite state machine consists of nodes and arrows.
Book 4 Chapter 4
FIGURE 4-1: Reconstructing the original data from the BWT transformation.
FIGURE 4-2: Uncompressing data requires using a dictionary to replace codes wit...
FIGURE 4-3: The LZ77 algorithm replaces redundant data with pointers.
FIGURE 4-4: The LZW algorithm stores increasingly larger strings as numbers.
FIGURE 4-5: Comparison of compressed graphic images.
Book 4 Chapter 5
FIGURE 5-1: How a stream cipher works.
FIGURE 5-2: The electronic codebook encrypts blocks of data separately with the...
FIGURE 5-3: Cipher-block chaining uses the output from one block as the input f...
FIGURE 5-4: A single password can encrypt and decrypt a message.
FIGURE 5-5: Public keys encrypt data, and private keys decrypt data.
FIGURE 5-6: Public-key and private-key encryption can work together.
Book 5 Chapter 1
FIGURE 1-1: HTML can create six different headings.
FIGURE 1-2: You can specify text to appear center- or right-aligned.
FIGURE 1-3: The
<th>
and
</th>
tags define the headings for the...
FIGURE 1-4: The
<tr>
and
<td>
tags define new rows and data for...
FIGURE 1-5: The
<caption>
and
</caption>
tags define text to ap...
FIGURE 1-6: The
colspan
attribute lets text expand across multiple columns.
Book 6 Chapter 5
FIGURE 5-1: A storyboard lets you visually design a user interface.
FIGURE 5-2: The parts of a SwiftUI program.
FIGURE 5-3: Modifiers affect a View displayed in the Canvas pane.
FIGURE 5-4: State variables let changed data appear in multiple locations autom...
FIGURE 5-5: Swift allows Unicode characters to be used in variable names.
Book 6 Chapter 6
FIGURE 6-1: Adding properties can change the appearance of the
Text
widget.
FIGURE 6-2: The
Expanded
widget inside the
Row
widget can space items apart.
FIGURE 6-3: The
Column
widget arranges widgets vertically.
Book 7 Chapter 1
FIGURE 1-1: A free-form database can store randomly structured information.
FIGURE 1-2: A flat-file database stores data in fields and records.
FIGURE 1-3: A relational database is divided into tables.
FIGURE 1-4: Flat-file databases must store duplicate data in separate files.
FIGURE 1-5: Tables separate data into pieces.
FIGURE 1-6: Relational databases let you combine data from different tables.
FIGURE 1-7: The Select command retrieves a single record or tuple.
FIGURE 1-8: The Project command retrieves selected columns or attributes.
FIGURE 1-9: The Join command matches two or more tables together.
FIGURE 1-10: The three parts of a database program.
Book 7 Chapter 2
FIGURE 2-1: A bioinformatics program can help you search through large amounts ...
Book 7 Chapter 3
FIGURE 3-1: Firewalls can block ports or certain programs from accessing a netw...
Book 7 Chapter 4
FIGURE 4-1: A neural network.
FIGURE 4-2: How a neuron processes and outputs a value.
Book 7 Chapter 5
FIGURE 5-1: Constraints define the placement of UI items on a screen.
FIGURE 5-2: Virtual keyboards can adapt to the user’s needs.
Book 7 Chapter 6
FIGURE 6-1: Visual scripting lets you create a program by connecting nodes in a...
Book 7 Chapter 7
FIGURE 7-1: A virtual machine lets a program run on multiple operating systems.
Cover
Title Page
Copyright
Table of Contents
Begin Reading
Index
About the Author
i
ii
1
2
3
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
263
264
265
266
267
268
269
270
271
272
273
274
275
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
367
368
369
370
371
372
373
374
375
376
377
378
379
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
509
510
511
512
513
514
515
516
517
518
519
520
521
523
524
525
526
527
528
529
530
531
532
533
534
535
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
721
722
723
724
725
726
727
728
729
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
If you enjoy using a computer, you may have even more fun learning to control a computer by writing your own programs. To learn how to program a computer, you need to:
Understand that computer programming is nothing more than problem solving.
Before you even think about writing a program, you need to know what problem you want your program to solve and how it will solve it.
Learn the basic ideas behind computer programming that work with all programming languages on any computer.
Although programming a Windows computer is different from programming a Mac, a smartphone, a smart watch, or a super computer, the general principles remain the same. By learning what these common programming principles are and why they exist, you can learn different ways to tell a computer what to do, step-by-step.
Learn a specific programming language.
A programming language represents just one way to express your ideas in a language that the computer can understand. By combining your knowledge of a programming language with programming principles and the type of problem you want the computer to solve, you can create your own computer programs for fun or profit.
If you have any interest in programming but don’t know where to start, this book can give you a nudge in the right direction. You won’t learn how to write programs in a specific programming language, but you’ll learn the basics of computer programming so you’ll have no trouble learning more on your own.
If you already know something about programming, this book can still help you learn more by introducing you to the variety of programming languages available and make it easy for you to pick up different programming languages quickly. The more you understand the advantages and disadvantages of different programming languages, the better you’ll be able to choose the language that’s best suited for a particular task.
Whether you’re a novice or an intermediate programmer, you’ll find this book can work as a tutorial to teach you more and as a reference to help refresh your memory on programming topics you may not normally use every day. This book won’t turn you into an expert overnight, but it will open the doors to more information about programming than you may have ever known even existed.
This book is a reference — you don’t need to read the chapters in order from front cover to back and you don’t have to commit anything you read here to memory. Also, sidebars (text in gray boxes) and anything marked with the Technical Stuff icon are skippable.
Finally, within this book, you may note that some web addresses break across two lines of text. If you’re reading this book in print and want to visit one of these web pages, simply key in the web address exactly as it’s noted in the text, pretending as though the line break doesn’t exist. If you’re reading this as an e-book, you’ve got it easy — just click the web address to be taken directly to the web page.
When writing this book, I made two assumptions about you, the reader:
You may have no experience in computer programming or a limited amount of experience, but you’re eager to learn.
You have a computer (whether it’s the latest model on the market or simply an older model that still works). Ideally, your computer can connect to the Internet.
That’s it! As long as you have a computer and the desire to learn, you have everything you need to learn computer programming.
Icons highlight important or useful information that you may want to know about. Here’s a guide to the icons:
The Tip icon highlights information that can save you time or make it easier for you to do something.
The Remember icon emphasizes information that’s so important you should commit it to memory.
Look out! The Warning icon highlights something dangerous that you need to avoid before making an irreversible mistake that could make you curse your computer forever.
The Technical Stuff icon highlights interesting technical information that you can safely ignore, but which may provide additional background about programming a computer.
In addition to what you’re reading right now, this product also comes with a free access-anywhere Cheat Sheet that summarizes different types of programming principles, common ways to store and organize data, and lists of suggested software to use. To get this Cheat Sheet, simply go to www.dummies.com and type Beginning Programming All-in-One For Dummies Cheat Sheet in the Search box.
You can use this book as a tutorial or a reference. Although you can just flip through this book to find the information you need, programming novices should start with Book 1 before tackling any other books. After you understand the basics of programming from Book 1, you can freely jump around to read only the information that interests you.
Programming is more than learning a particular programming language or even knowing how to program a particular type of computer. Basically, programming is about tackling difficult problems and breaking them down into smaller problems until you ultimately solve one much bigger problem. If you like the idea of solving problems, this may be the perfect book to introduce you to the wonderful world of computer programming!
Book 1
Chapter 1: Getting Started Programming a Computer
How Computer Programming Works
The History of Computer Programming
Figuring Out Programming
Chapter 2: Different Methods for Writing Programs
Spaghetti Programming
Structured Programming
Event-Driven Programming
Object-Oriented Programming
Using Protocol-Oriented Programming
Design Patterns
Chapter 3: Types of Programming Languages
Your First Language
Curly-Bracket Languages
Artificial Intelligence Languages
Scripting Languages
Database Programming Languages
Comparing Programming Languages
Chapter 4: Programming Tools
Choosing a Compiler
Finding an Interpreter
Compiling to a Virtual Machine
Writing a Program with an Editor
Fixing a Program with a Debugger
Saving Time with Third-Party Components
Optimizing a Program with a Profiler
Managing Source Code
Creating a Help File
Installing a Program
Dissecting Programs with a Disassembler
Chapter 1
IN THIS CHAPTER
Understanding how computer programming works
Diving into the history of computer programming
Discovering programming
Believe it or not, if you can write a recipe on an index card, you can program a computer! At the simplest level, computer programming is nothing more than writing instructions for a computer to follow, step-by-step. The most important part of programming isn’t knowing how to write a program or how to use a particular programming language, but knowing what to create in the first place.
Some of the most popular and useful computer programs were created by people who didn’t have any formal training in math or computer science. Dan Bricklin invented the spreadsheet while studying for his MBA at Harvard. Scott Cook, who worked in marketing and product development at Procter & Gamble, created the popular money-management program Quicken after hearing his wife complain about the tedium of paying bills. Nineteen-year-old Shawn Fanning created Napster, the first peer-to-peer file-sharing network, after hearing a friend complain about the difficulty of finding his favorite songs on the Internet. Game developer Dona Bailey wanted to create a video game that would appeal to both men and women; as the only woman working at Atari’s coin-op division, she created the video game Centipede, which became Atari’s second best-selling coin-op game.
The point is that anyone can figure out how to program a computer. What’s more important than knowing how to program a computer is knowing what to do with your programming skills. As Albert Einstein said, “Imagination is more important than knowledge.” After you have an idea for a program, you can use programming to turn your idea into reality.
Computer programming is nothing more than problem solving. Every program is designed to solve a specific problem. The more universal the problem (calculating formulas in a spreadsheet, managing your money, searching for music files over the Internet, or keeping people amused playing a game creating virtual buildings), the more useful and popular the program will be.
Before you even touch a computer, identify the specific problem you want the computer to solve. For example, spreadsheets eliminate the tedium of writing and calculating formulas manually. Word processors make editing and formatting text fast and easy. Even video games solve the problem of challenging people with puzzles, obstacles, and battles.
Although the most popular programs solve universal problems, literally thousands of programs are designed to solve specific problems in niche markets, such as hotel reservation software, construction billing and invoice management programs, and dental office management programs. If you can identify a problem that a computer can solve or simplify, you have an idea for a computer program.
You must know exactly what you want your program to do before you start designing and writing it. One of the most common reasons programs fail is because the program doesn’t solve the right problem that people really need.
The Federal Bureau of Investigation (FBI) had a problem. It had so much information, stored on paper, scattered among so many agents around the country that finding and using this information was nearly impossible. One agent might have vital information that could help a second agent crack a case, but unless those two agents knew what each other had, that information might as well never have existed in the first place.
So, the FBI had a bright idea: Create a computer program that would allow agents to store and share information through the computer. Several years and $170 million later, the FBI had its program, dubbed Virtual Case File, which consisted of more than 700,000 lines of error-prone commands that never even worked. Rather than try to salvage the project, the FBI decided it was easier just to cancel the whole thing and basically flush 170 million taxpayer dollars down the drain.
What went wrong? Although many factors contributed to the project’s failure, one reason stands out in particular: According to an audit of the program conducted by the U.S. Department of Justice, a prime cause for failure was “poorly defined and slowly evolving design requirements.” In other words, the FBI never knew exactly what it wanted the program to do.
How can you aim at a target if you don’t know what it is? You can’t. Or you can try, just as long as you spend $170 million to discover that if you don’t know what you want, you’re probably never going to get it.
After you know what you want your program to do, you need to define all the steps that tell the computer how to solve that particular problem. The exact steps that define how the program should work is called an algorithm. An algorithm simply defines one of many possible ways to solve a problem.
There’s no single “best” algorithm for writing a program. The same program can be written in a million different ways, so the “best” way to write a program is any way that creates a useful, working, and reliable program as quickly as possible. Anything else is irrelevant.
Knowing what you want the computer to do is the first step. The second step is telling the computer how to do it, which is what makes programming so difficult. The more you want the computer to do, the more instructions you need to give the computer.
Think of a computer program as a recipe. It’s easy to write a recipe for making spaghetti. Just boil water, throw in the noodles until they’re soft, drain, and serve. Now consider a recipe for making butternut squash and potato pie with tomato, mint, and sheep’s milk cheese from Crete. Not as simple as boiling water to make spaghetti, is it?
The same principle holds true for computer programming. The simpler the task, the simpler the program. The harder the task, the bigger and more complicated the program. If you just want a program that displays today’s date on the screen, you won’t need to write many instructions. If you want to write a program that simulates flying a space shuttle in orbit around the Earth, you’ll need to write a lot more instructions.
The more instructions you need to write, the longer it takes and the more likely you’ll make a mistake somewhere along the way.
Ultimately, programming boils down to two tasks:
Identifying exactly what you want the computer to do
Writing step-by-step instructions that tell the computer how to do what you want
Although computer programming may seem like a recent invention, the idea behind writing instructions for a machine to follow has been around for over a century. One of the earliest designs for a programmable machine (in other words, a computer) came from a man named Charles Babbage way back in 1834.
That was the year Charles Babbage proposed building a mechanical, steam-driven machine dubbed the Analytical Engine. Unlike the simple calculating machines of that time that could perform only a single function, Charles Babbage’s Analytical Engine could perform a variety of tasks, depending on the instructions fed into the machine through a series of punched cards. By changing the number and type of instructions (punch cards) fed into the machine, anyone could reprogram the Analytical Engine to make it solve different problems.
The idea of a programmable machine caught the attention of Ada Lovelace, a mathematician and daughter of the poet Lord Byron. Sensing the potential of a programmable machine, Ada wrote a program to make the Analytical Engine calculate and print a sequence of numbers known as the Bernoulli numbers.
Because of her work with the Analytical Engine, Ada Lovelace is considered to be the world’s first computer programmer. In her honor, the Department of Defense named the Ada programming language after Ada Lovelace. Nvidia named a family of graphics cards after Ada Lovelace as well.
Although Charles Babbage never finished building his Analytical Engine, his steam-driven mechanical machine bears a striking similarity to today’s computers. To make the Analytical Engine solve a different problem, you just had to feed it different instructions. To make a modern computer solve a different problem, you just have to run a different program.
Over a century later, the first true computer appeared in 1943 when the U.S. Army funded a computer to calculate artillery trajectories. This computer, dubbed ENIAC (short for Electronic Numerical Integrator and Computer), consisted of vacuum tubes, switches, and cables. To give ENIAC instructions, you had to physically flip its different switches and rearrange its cables.
The first ENIAC programmers were all women.
Physically rearranging cables and switches to reprogram a computer worked, but it was tedious and clumsy. Instead of having to physically rearrange the computer’s wiring, computer scientists decided it would be easier if they could leave the computer physically the same but just rearrange the type of instructions given to it. By giving the computer different instructions, they could make the computer behave in different ways.
In the old days, computers filled entire rooms and cost millions of dollars. Today, computers have shrunk so far in size that they’re essentially nothing more than a little silicon wafer, about the size of a coin.
A processor is essentially an entire computer. To tell the processor what to do, you have to give it instructions written in machine language (a language that the processor can understand).
To make faster computers, engineers combine multiple processors (called cores) together and make them work as a team. So, instead of having a single processor in your computer, the latest computers have multiple processors or cores working together.
To understand how machine language works, you have to understand how processors work. Basically, a processor consists of nothing more than millions of tiny switches that can turn on or off. By turning certain switches on or off, you can make the processor do something useful.
Instead of physically turning switches on or off, machine language lets you turn a processor’s switches on or off by using two numbers: 1 (one) and 0 (zero), where the number 1 means “turn a switch on” and the number 0 means “turn a switch off.” So a typical machine language instruction might look like this:
1011 0000 0110 0001