Majed Marji holds a PhD in electrical engineering from Wayne State University and an MBA in strategic management from Davenport University. He has over 15 years of experience in the automotive industry, where he developed many software applications for real-time data acquisition, device control, test-cell management, engineering data analysis, embedded controllers, telematics, hybrid vehicles, and safety-critical powertrain systems. Dr. Marji is also an adjunct faculty member with the Electrical Engineering Department at Wayne State University. He has taught courses on communication engineering, machine vision, microprocessors, control systems, and algorithms and data structures, among other topics.
About the Technical Reviewer
Tyler Watts, EdS, is a creative-computing educator who teaches sixth through eighth graders in Kansas City (Kansas) Unified School District 500 and adult students at the University of MissouriKansas City. He has been using Scratch since 2009 as a tool to combat the digital divide and teach students how to think like computer scientists. Since Tylers first year of teaching Scratch, he has learned the importance of weaning learners off of the Scratch training wheels and challenging them and molding them into digital creators. He feels that programming is a form of personal expression and teaches his students to approach it as they would any other art form and have fun.
Acknowledgments
Although the books cover shows a single author, many people have had a hand in its creation. I would like to acknowledge the many professionals at No Starch Press who contributed to this work. Special thanks go to my editor, Jennifer Griffith-Delgado, and my production editor, Alison Law, for their significant contributions. Their helpful suggestions and expertise have led to a greatly improved book, and their commitment to excellence appears on every page. I would also like to thank Paula L. Fleming and Serena Yang for their work on the book.
I am truly grateful for the valuable feedback provided by the technical editor, Tyler Watts. His thoughtful suggestions have, in many instances, made their way into the book.
My final thanks go to my wife, Marina, and my two sons, Asad and Karam, who supported me throughout this long project. Theyve put up with so much to give me the time and space I needed. Maybe now I can catch up with the things Ive missed!
Introduction
Scratch is a visual programming language that provides a rich learning environment for people of all ages. It allows you to create interactive, media-rich projects, including animated stories, book reports, science projects, games, and simulations. Scratchs visual programming environment enables you to explore areas of knowledge that would otherwise be inaccessible. It provides a full set of multimedia tools you can use to create wonderful applications, and you can do so more easily than with other programming languages.
In many ways, Scratch promotes problem-solving skillsimportant in all areas of life, not just programming. The environment provides immediate feedback, allowing you to check your logic quickly and easily. The visual structure makes it a simple matter to trace the flow of your programs and refine your way of thinking. In essence, Scratch makes the ideas of computer science accessible. It makes learning intrinsically motivating; fosters the pursuit of knowledge; and encourages hands-on, self-directed learning through exploration and discovery. The barriers to entry are very low, while the ceiling is limited only by your creativity and imagination.
A lot of books claim to teach you how to program using Scratch. Most target very young readers and present only a few simple applications that guide the reader through Scratchs user interface. These books are more about Scratch than programming. The goal of this book, by contrast, is to teach fundamental programming concepts using Scratch as a tool, as well as to unveil the capabilities of Scratch as a powerful vehicle for both teaching and learning.
Whom This Book Is For
This book is for anyone eager to explore computer science. It teaches the fundamentals of programming, and it can be used as a textbook for middle and high school students or as a self-study guide. The book can also be used at the college level to teach elementary programming concepts to students from different backgrounds or as a companion textbook that provides an introduction to such a course.
Teachers who want to use Scratch in the classroom can also benefit from the deeper understanding of programming to be found in this book. Youll develop the skills you need to engage students with Scratch in meaningful ways that are compatible with their needs.
The book assumes no prior programming experience and, for the most part, no mathematics beyond what is taught in high school. Some of the advanced simulations can be skipped without causing any learning gap.
A Note to the Reader
The beauty of being a programmer is that you can create. Think about it: You come up with an idea and use your keyboard for a couple of hours, and a new software project comes to life! Like any new skill, however, programming takes practice. Along the way, youll most likely make mistakesbut dont give up. Take time to reflect on the concepts and experiment with different techniques until you master them. And then move on to learn something new.
Features
This book provides a hands-on, problem-solving approach to learning programming and related concepts in computer science. With this approach, I hope to cultivate readers imaginations and make the computer-programming experience available to everyone.
With that in mind, the book is project oriented. Ill present concepts with detailed explanations, and then together, well develop a number of applications that illustrate those concepts. The emphasis is on problem solving rather than on Scratchs particular features..
The examples presented in these pages demonstrate the wide range of knowledge you can explore using Scratch. These examples were selected carefully to explain programming concepts and to show how you can use Scratch to increase your understanding of other topics.
The Try It Out exercises and the problems at the end of each chapter are designed to challenge your programming skills. They also suggest new ideas that incorporate the studied concepts into larger problems. I encourage you to attempt these exercises and to come up with your own programming problems. Solving problems of your own shows that youve developed a solid understanding of programming.
Organization of This Text
The first three chapters of this book introduce Scratch as a powerful tool for drawing geometric shapes and creating media-rich applications. Theyll get you started quickly and easily, while the rest of the book focuses on the programming constructs supported in Scratch.
introduces Scratchs programming environment, the available command blocks, and the process of creating simple programs.
reviews the motion commands and introduces Scratchs drawing capabilities.
discusses Scratchs sound and graphics commands.
introduces procedures as a way to write structured, modular programs. We jump into procedures here to enforce good programming style from the beginning.
explores how you can use variables to keep track of information. This chapter also explains how to ask users questions and get answers, paving the way for building a wide range of interactive applications.