Coding For Dummies
Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com
Copyright 2015 by John Wiley & Sons, Inc., Hoboken, New Jersey
Media and software compilation copyright 2015 by John Wiley & Sons, Inc. All rights reserved.
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 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 : THE PUBLISHER AND THE AUTHOR 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 WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
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 www.wiley.com/techsupport .
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: 2014954659
ISBN 978-1-118-95130-9 (pbk); ISBN 978-1-118-95130-9 (ebk); ISBN 978-1-118-97091-1 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
About the Author
Nikhil Abraham has worked at Codecademy.com for the last two years. At Codecademy, he helps technology, finance, media, and advertising companies teach their employees how to code. With his help, thousands of marketing, sales, and recruiting professionals have written their first lines of code and built functional applications. In addition to teaching, he manages partnerships and business development for Codecademy, and has helped bring coding to schools in the United States, Brazil, Argentina, France, and the United Kingdom.
Prior to Codecademy, Nikhil worked in a variety of fields, including management consulting, investment banking, and law, and founded a Y-Combinatorbacked technology education startup. He received a JD and MBA from the University of Chicago, and a BA in quantitative economics from Tufts University.
Nikhil lives in Manhattan, New York.
Dedication
This book is dedicated to Molly Grovak.
Authors Acknowledgments
This book was possible with help from a number of people.
Thanks to all the people at Wiley, including Steven Hayes, for keeping an open mind to as many ideas as can fit in one phone call, and Christopher Morris for edits and helpful advice. Also, thank you to all the technical editorial, layout, and graphics folks for turning text of variable quality into text of outstanding quality.
Thanks to those of you who helped shape the content in this book and online. For everyone at Codecademy, including Zach and Ryan, thank you for the feedback on the chapters and for answering my questions. Thanks to Douglas Rushkoff, for starting a national conversation on whether we as a society should program or be programmed, and for bringing this message to schools, universities, and non-profits. Thanks to Susan Kish, for being the only executive I can find who has spoken publicly about her journey learning how to code (check out her TED Talk!), and for seeing the future of coding in corporations. Thanks to Alia Shafir and Joshua Slusarz for all the coding sessions you helped organize, leaders you wrangled, rooms you reserved, and laptops you rebooted. Thanks to Melissa Frescholtz and her leadership team for supporting a culture of code, and bringing code education even to places where its used every day. Thanks to alumni at Cornell University, Northwestern University, University of Virginia, and Yale University for testing early versions of content, and helping make it better. Thanks to the people at Donorschoose.org, including Charles Best and Ali Austerlitz, and at Google.org for shining a bright light on coding for women and girls. Thanks to Code.org for making coding accessible and cool for tens of millions of kids in the United States and abroad.
Finally, thanks to Molly, who ordered more take-out, brewed more tea, and cleaned the apartment more times than I can count.
Publishers Acknowledgments
Executive Editor: Steve Hayes
Senior Project Editor: Christopher Morris
Copy Editor: Christopher Morris
Technical Editor: Travis Faas
Editorial Assistant: Claire Johnson
Sr. Editorial Assistant: Cherie Case
Project Coordinator: Melissa Cossell
Cover Image: iStock.com/blackred
Chapter 1
What Is Coding?
In This Chapter
Seeing what code is and what it can do
Touring your first program using code
Understanding programming languages used to write code
A million dollars isnt cool, you know whats cool? A billion dollars.
Sean Parker, The Social Network
Every week the newspapers report on another technology company that has raised capital or sold for millions of dollars. Sometimes, in the case of companies like Instagram, WhatsApp, and Uber, the amount in the headline is for billions of dollars. These articles may pique your curiosity, and you may want to see how code is used to build the applications that experience these financial outcomes. Alternatively, your interests may lie closer to work. Perhaps you work in an industry in decline, like print media, or in a function that technology is rapidly changing, like marketing. Whether you are thinking about switching to a new career or improving your current career, understanding computer programming or coding can help with your professional development. Finally, your interest may be more personal perhaps you have an idea, a burning desire to create something, a website or an app, to solve a problem you have experienced, and you know reading and writing code is the first step to building your solution. Whatever your motivation, this book will shed light on coding and programmers, and help you think of both not as mysterious and complex but approachable and something you can do yourself.
Next page