Learn to Program, Third Edition
by Chris Pine
Version: P1.0 (June 2021)
Copyright 2021 The Pragmatic Programmers, LLC. This book is licensed to the individual who purchased it. We don't copy-protect it because that would limit your ability to use it for your own purposes. Please don't break this trustyou can use this across all of your devices but please do not share this copy with other members of your team, with friends, or via file sharing services. Thanks.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein.
About the Pragmatic Bookshelf
The Pragmatic Bookshelf is an agile publishing company. Were here because we want to improve the lives of developers. We do this by creating timely, practical titles, written by programmers for programmers.
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com.
Our ebooks do not contain any Digital Restrictions Management, and have always been DRM-free. We pioneered the beta book concept, where you can purchase and read a book while its still being written, and provide feedback to the author to help make a better book for everyone. Free resources for all purchasers include source code downloads (if applicable), errata and discussion forums, all available on the book's home page at pragprog.com. Were here to make your life easier.
New Book Announcements
Want to keep up on our latest titles and announcements, and occasional special offers? Just create an account on pragprog.com (an email address and a password is all it takes) and select the checkbox to receive newsletters. You can also follow us on twitter as @pragprog.
About Ebook Formats
If you buy directly from pragprog.com, you get ebooks in all available formats for one price. You can synch your ebooks amongst all your devices (including iPhone/iPad, Android, laptops, etc.) via Dropbox. You get free updates for the life of the edition. And, of course, you can always come back and re-download your books when needed. Ebooks bought from the Amazon Kindle store are subject to Amazon's polices. Limitations in Amazon's file format may cause ebooks to display differently on different devices. For more information, please see our FAQ at pragprog.com/#about-ebooks. To learn more about this book and access the free resources, go to https://pragprog.com/book/ltp3, the book's homepage.
Thanks for your continued support,
Andy Hunt
The Pragmatic Programmers
The team that produced this book includes: Dave Rankin (CEO) Janet Furlow (COO) Tammy Coron (Managing Editor) Tammy Coron (Development Editor) Corina Lebegioara (Copy Editor) Potomac Indexing, LLC (Indexing) Gilson Graphics (Layout) Andy Hunt and Dave Thomas (Founders)
For customer support, please contact .
For international rights, please contact .
Table of Contents
Copyright 2021, The Pragmatic Bookshelf.
Early Praise for Learn to Program, Third Edition
I would absolutely recommend this book. Its the book I wish Id had when I started.
Erin Dees |
Principal Engineer and Author |
Chris Pine has an uncanny ability to empathize with beginning programmers. His understanding of software, curriculum design and the science of attention continues to make Learn to Program, Third Edition the best resource Ive ever found for those that are just getting started on this journey. Im presently building a team of developer educators and I intend to buy a copy for every one of them as an example of how to design software curriculum.
Jonan Scheffler |
Director of Developer Relations and Hacker/Maker |
This is an excellent book for someone who has never tried programming before, or someone who has tried but found it frustrating or confusing.
Justin Foote |
Software Engineer and Architect |
I really love this book because Chris has so much compassion for his readers. He really brings you on a wonderful and enjoyable journey of code.
Rey Abolofia |
Senior Software Engineer and Educator |
Acknowledgments
The book you are reading is better than the book I originally wrote.
First and foremost, I want to thank my dear wife, Katy. Through all the incarnations of this book over the last 18 years, you were there supporting me from the very beginning. You were the original guinea pig for this experiment. This book wouldnt exist without you.
I also want to thank Tammy Coron, my amazing editor. Im so glad no one has to read the book I originally wrote! You make me appear to be a better author than I actually am.
Thanks to my technical reviewers: Erin Dees, Jason Clark, Jonan Scheffler, Justin Foote, Rachael Berecka, Rachel Klein, and Rey Abolofia! I really look like I know what Im talking about because of you.
A special thanks to my dear daughter, Ruby, for her artwork appearing at the end of the third chapter. Its a magical thing to see your child develop skills that far surpass your own.
Thanks to all of my readers and technical reviewers of earlier editions. Your feedback was invaluable in making this book what it is.
It really does take a village.
Copyright 2021, The Pragmatic Bookshelf.
Preface to the Third Edition
I just realized that Ive been working on this book, in one form or another, for 18 years. When I started, it was before smartphones, before Twitter and YouTube, and before Gmail and Google Maps. You couldnt visit MySpace in Firefox, because neither one existed yet. RSS feeds were the hot new thing.
The world has changed so much since then, and the changes keep happening faster and faster. This third edition was written under the shadow of COVID-19. As unemployment in the United States reaches heights not seen since the Great Depression, I still see lots of open programmer jobs out there. And programming is a job you can easily do from home.
Programming was a fun and interesting thing to learn in 2002. At the time not nearly as many programming jobs existed, but there were enough. And anyway, many of us did it for fun, for the joy of creating new things.
Today, surrounded by computers, programming increasingly feels like a critical skill to learn. Its still as fun and rewarding as it ever was. But as more industries become digital, and more companies become software companies with an app for that, the importance of programming is greater than it has ever been.
Im excited to embark on this journey with you.
Whats New in This Edition