📄 preface
字号:
ABOUT THE AUTHORI first began teaching introductory computer science more than 20 yearsago while I was still a student at Harvard. Since receiving my Ph.D. in1980, I have taught computer science at Harvard, Wellesley, andStanford, where I am Associate Chair of the Computer Science Department.In that capacity, I am responsible for the undergraduate program incomputer science. Although I have taught advanced courses in computerscience and have also worked in the research industry, my greatest joycomes from opening up the enormous power of computers to students whoare just beginning to learn about them. In their excitement, my ownlove for computer science is constantly renewed.In addition to my teaching at Stanford, I have served since 1990 as thepresident of Computer Professionals for Social Responsibility, apublic-interest association of computer professionals with 2000 membersin 22 chapters throughout the United States. Computers affect oursociety in many different ways. Just as it is important to learn aboutthe technology, it is critical that we also take the responsibility toensure that computers are used for the benefit of all. If you havesuggestions as to how I might make the presentation more clear, or youencounter errors in this text, please let me know. You can reach me byelectronic mail at ericr@aw.com.Eric S. RobertsStanford UniversityTO THE STUDENTWelcome! By picking up this book, you have taken a step into the worldof computer science -- a field of study that has grown from almostnothing half a century ago to become one of the most vibrant and activedisciplines of our time.Over that time, the computer has opened up extraordinary possibilitiesin almost every area of human endeavor. Business leaders today are ableto manage global enterprises on an unprecedented scale because computersenable them to transfer information anywhere in a fraction of a second.Scientists can now solve problems that were beyond their reach until thecomputer made the necessary calculations possible. Filmmakers usecomputers to generate dramatic visual effects that are impossible toachieve without them. Doctors can determine much more accurately whatis going on inside a patient because computers have enabled a massivetransformation in medical technology.Computers are a profoundly empowering technology. The advances we haveseen up to now are small compared to what we will see in the nextcentury. Computers will play a major role in shaping that century, justas they have the last 50 years. Those of you who are students todaywill soon inherit the responsibility of guiding that progress. As youdo so, knowing how to use computers can only help.Like most skills that are worth knowing, learning how computers work andhow to control their enormous power takes time. You will not understandit all at once. You must start somewhere. Twenty-five centuries ago,the Chinese philosopher Lao-tzu observed that the longest journey beginswith a single step. This book can be your beginning.For many of you, however, the first step can be the hardest to take.Many students find computers overwhelming and imagine that computerscience is beyond their reach. Learning the basics of programming,however, does not require advanced mathematics or a detailedunderstanding of electronics. What matters in programming is whetheryou can progress from the statement of a problem to its solution. To doso, you must be able to think logically. You must have the necessarydiscipline to express your logic in a form that the computer canunderstand. Perhaps most importantly, you must be able to see the taskthrough to its completion without getting discouraged by difficultiesand setbacks. If you stick with the process, you will discover thatreaching the solution is so exhilarating that it more than makes up forany frustrations you encounter along the way.This book is designed to teach you the fundamentals of programming andthe basics of C, which is the dominant programming language in thecomputing industry today. It treats the whys of programming as well asthe hows, to give you have a feel for the programming process as awhole. It also includes several features that will help you focus onthe essential points and avoid errors that slow you down. The next fewpages summarize these features and explain how to use this bookeffectively as you begin your journey into the exciting world ofcomputer science.TO THE INSTRUCTORIn 1991-92, Stanford decided to restructure its introductory computerscience curriculum to use ANSI C instead of Pascal. We chose to adoptANSI C in our introductory courses for the following reasons: o Students demanded a more practical language. Future employers want students to have more direct experience with the tools industry uses, which today are principally C and C++. With few employment opportunities listed for Pascal programmers in the newspaper employment section, our students began to question the relevance of their education. o Our Pascal-based curriculum taught students to program in a language that they would never again use. We discovered that many of those students, when they abandoned Pascal for more modern languages, often forgot everything they had learned about programming style and the discipline of software engineering. Having now taught these skills in the context of a language that the students continue to use, we have found that they end up writing much better programs. o Many of our advanced computer science courses, particularly in the systems area, require students to program in C. Working with C from the beginning gives students much more experience by the time they reach the advanced courses. o Learning C early paves the way to learning C++ and the object-oriented paradigm. Because our students have a strong background in C programming after their first year of study, we have been able to offer our course on object-oriented system design much earlier in the curriculum. o C makes it possible to cover several important topics, such as modular development and abstract data types, that are hard to teach in a Pascal environment. o In the last five years, C has made significant headway toward replacing Fortran as the lingua franca of programming for the engineering sciences.Given our experience over the last two years, I am convinced that thechoice was a good one and that our program is stronger because of thechange.At the same time, it is important to recognize that teaching C in thefirst programming course is not always easy. C was designed forprogrammers, not introductory students. Many of its features make senseonly when understood in terms of a larger conceptual framework that newstudents do not recognize. In many respects, C is a complex language.To teach it at the introductory level, we must find a way to control itscomplexity.THE LIBRARY-BASED APPROACHOne of the central goals of this text is to enable teachers to manageC's inherent complexity. Managing complexity, however, is preciselywhat we do as program- mers. When we are faced with a problem that istoo complex for immediate solution, we divide it into smaller pieces andconsider each one independently. Moreover, when the complexity of oneof those pieces crosses a certain threshold, it makes sense to isolatethat complexity by defining a separate abstraction that has a simpleinterface. The interface protects clients from the underlying detailsof the abstraction, thereby simplifying the conceptual structure.The same approach works for teaching programming. To make the materialeasier for students to learn, this text adopts a library-based approachthat emphasizes the principle of abstraction. The essential character
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -