Programming: Principles and Practice Using C++

Paperback (Print)
Rent
Rent from BN.com
$22.20
(Save 70%)
Est. Return Date: 09/09/2014
Used and New from Other Sellers
Used and New from Other Sellers
from $22.98
Usually ships in 1-2 business days
(Save 69%)
Other sellers (Paperback)
  • All (71) from $22.98   
  • New (11) from $41.16   
  • Used (60) from $22.77   

Overview

AN INTRODUCTION TO PROGRAMMING BY THE INVENTOR OF C++

 

Preparation for Programming in the Real World

This book assumes that you aim to eventually write non-trivial programs, whether for work in software development or in some other technical field.

Focus on Fundamental Concepts and Techniques

The book explains fundamental concepts and techniques in greater depth than traditional introductions. This will give you a solid foundation for writing useful, correct, maintainable, and efficient code.

Programming with Today’s C++

The book’s focus makes it an introduction to programming in general, including object-oriented programming and generic programming. However, it is also an introduction to the C++ programming language, one of the most widely used languages for real-world software. The book presents modern C++ programming techniques from the start, introducing the C++ standard library to simplify programming tasks.

For Beginners–and Anyone Who Wants to Learn Something New

This book is designed for people who never programmed before, and it has been tested with more than 1,000 first-year students. However, it also appeals to readers with some knowledge of programming (in C++ or other languages). Practitioners and advanced students will gain new insight and guidance by seeing how a recognized master approaches the elements of his art.

Provides a Broad View

The first half of the book alone covers a wide range of essential concepts, techniques, language features, and libraries. Those will enable you to write programsinvolving input, output, computation, and simple graphics. The second half explores more specialized topics, such as text processing and testing, and provides abundant reference material.

Written by Bjarne Stroustrup

Dr. Stroustrup is the designer and original implementer of C++ and the author of The C++ Programming Language (Addison-Wesley, 2000). He is the College of Engineering Chair in Computer Science Professor at Texas A&M University, a member of the U.S. National Academy of Engineering, and an AT&T Fellow. Before moving to academia, he worked for decades in AT&T Bell Labs. He is a founding member of the ISO C++ standards committee.

Read More Show Less

Product Details

  • ISBN-13: 9780321543721
  • Publisher: Addison-Wesley
  • Publication date: 1/2/2009
  • Edition description: Older Edition
  • Pages: 1236
  • Sales rank: 320,020
  • Product dimensions: 7.38 (w) x 9.16 (h) x 1.69 (d)

Meet the Author

Bjarne Stroustrup is the designer and original implementer of C++, as well as the author of The C++ Programming Language, Fourth Edition (Addison-Wesley, 2013), and A Tour of C++ (Addison-Wesley, 2014) and many popular and academic publications. Dr. Stroustrup is a managing director at Morgan Stanley in New York City, as well as a visiting professor at Columbia University and a Research distinguished professor at Texas A&M University. He is a member of the U.S. National Academy of Engineering, an IEEE Fellow, and an ACM fellow. His research interests include distributed systems, design, programming techniques, software development tools, and programming languages. He is actively involved in the ISO standardization of C++.
Read More Show Less

Read an Excerpt

Damn the torpedoes! Full speed ahead.
—Admiral Farragut

Programming is the art of expressing solutions to problems so that a computer can execute those solutions. Much of the effort in programming is spent finding and refining solutions. Often, a problem is only fully understood through the process of programming a solution for it.

This book is for someone who has never programmed before, but is willing to work hard to learn. It helps you acquire the principles and practical skills of programming using the C++ programming language. My aim is for you to gain sufficient knowledge and experience to perform simple useful programming tasks using the best up-to-date techniques. How long will that take? As part of a first-year university course, you can work through this book in a semester (assuming that you have a workload of four courses of average difficulty). If you work by yourself, don’t expect to spend less time than that (maybe 15 hours a week for 14 weeks).

Three months may seem a long time, but there’s a lot to learn and you’ll be writing your first simple programs after about an hour. Also, all learning is gradual: each chapter introduces new useful concepts and illustrates them with examples inspired by real-world uses. Your ability to express ideas in code — getting a computer to do what you want it to do — gradually and steadily increases as you go along. I never say “learn a month’s worth of theory and then see if you can use it.”

Why would you want to program? Our civilization runs on software. Without understanding software you are reduced to believing in “magic” and will be locked out of many of the most interesting, profitable, and socially useful technical fields of work. When I talk about programming, I think of the whole spectrum of computer programs from personal computer applications with GUIs (Graphical User Interfaces), through engineering calculations and embedded system control applications (such as digital cameras, cars, and cell phones), to text manipulation applications as found in many humanities and business applications. Like mathematics, programming — when done well — is a valuable intellectual exercise that sharpens our ability to think. However, thanks to feedback from the computer, programming is more concrete than most forms of math, and therefore accessible to more people. It is a way to reach out and change the world — hopefully for the better. Finally, programming can be great fun.

Why C++? You can’t learn to program without a programming language and C++ directly supports the key concepts and techniques used in real-world software. C++ is one of the most widely used programming languages, found in an unsurpassed range of application areas. You find C++ applications everywhere from the bottom of the oceans to the surface of Mars. C++ is precisely and comprehensively defined by a non-proprietary international standard. Quality and/or free implementations are available on every kind of computer. Most of the programming concepts that you will learn using C++ can be used directly in other languages, such as C, C#, Fortran, and Java. Finally, I simply like C++ as a language for writing elegant and efficient code.

This is not the easiest book on beginning programming; it is not meant to be. I just aim for it to be the easiest book from which you can learn the basics of real-world programming. That’s quite an ambitious goal because much modern software relies on techniques considered advanced just a few years ago.

My fundamental assumption is that you want to write programs for the use of others, and to do so responsibly providing a decent level of system quality. That is, I assume that you want to achieve a level of professionalism. Consequently, I chose the topics for this book to cover what is needed to get started with real-world programming, not just what is easy to teach and learn. If you need a technique to get basic work done right, I’ll describe it, demonstrate concepts and language facilities needed to support the technique, provide exercises for it, and expect you to work on those exercises. If you just want to understand toy programs, you can get along with far less than I present. On the other hand, I won’t waste your time with material of marginal practical importance. If an idea is explained here, it’s because you’ll almost certainly need it.

If your desire is to use the work of others without understanding how things are done and without adding significantly to the code yourself, this book is not for you. If so, please consider if you would be better served by another book and another language. If that is approximately your view of programming, please also consider from where you got that view and whether it in fact is adequate for your needs. People often underestimate the complexity of programming as well as its value. I would hate for you to acquire a dislike for programming because of a mismatch between what you needed and the part of the software reality I describe. There are many parts of the “Information Technology” world that do not require knowledge of programming. This book is aimed to serve those who do want to write nontrivial programs.

Because of its structure and practical aims, this book can also be used as a second book on programming for someone who already knows a bit of C++ or for someone who programs in another language and wants to learn C++. If you fit into one of those categories, I refrain from guessing how long it will take you to read this book, but I do encourage you to do many of our exercises. This will help you to counteract the common problem of writing programs in older, familiar, styles rather than adopting newer techniques where these are more appropriate. If you have learned C++ in one of the more traditional ways, you’ll find something surprising and useful before you reach Chapter 7. Unless your name is Stroustrup, what I discuss here is not “your father’s C++.”

Programming is learned by writing programs. In this, programming is similar to other endeavors with a practical component. You cannot learn to swim, to play a musical instrument, or to drive a car just from reading a book — you must practice. Nor can you learn to program without reading and writing lots of code. This book focuses on code examples closely tied to explanatory text and diagrams. You need those to understand the ideals, concepts, and principles of programming and to master the language constructs used to express them. That’s essential, but by itself, it will not give you the practical skills of programming. For that, you need to do the exercises and get used to the tools for writing, compiling, and running programs. You need to make your own mistakes, and learn to correct them. There is no substitute for writing code. Besides, that’s where the fun is!

On the other hand, there is more to programming — much more — than following a few rules and reading the manual. This book is emphatically not focused on “the syntax of C++.” Understanding the fundamental ideals, principles, and techniques is essence of a good programmer. Only well-designed code has a chance of becoming part of a correct, reliable, and maintainable system. Also, “the fundamentals” are what lasts: they will still be essential after today’s languages and tools have evolved or been replaced.

What about computer science, software engineering, information technology, etc.? Is that all programming? Of course not! Programming is one of the fundamental topics that underlie everything in computer-related fields and has a natural place in a balanced course of computer science. I provide brief introductions to key concepts and techniques of algorithms, data structures, user interfaces, data processing, and software engineering. However, this book is not a substitute for a thorough and balanced study of those topics.

Code can be beautiful as well as useful. This book is written to help you see that, to understand what it means for code to be beautiful and to help you to acquire the principles and practical skills to create such code. Good luck with programming!

A note to students

Of the 1,000++ first-year students we have taught so far using drafts of this book at Texas A&M University, about 60% had programmed before and about 40% had never seen a line of code in their life. Most succeeded, so you can do it too.

You don’t have to read this book as part of a course. I assume that the book will be widely used for self study. However, whether you work your way through as part of a course or independently, try to work with others. Programming has an — unfair — reputation as a lonely activity. Most people work better and learn faster when they are part of a group with a common aim. Learning together and discussing problems with friends is not cheating! It is the most efficient — as well as most pleasant — way of making progress. If nothing else, working with friends forces you to articulate your ideas, which is just about the most efficient way of testing your understanding and making sure you remember. You don’t actually have to personally discover the answer to every obscure language and programming environment problem. However, please don’t cheat yourself by not doing the drills and a fair number of exercises (even if no teacher forces you to do them). Remember: programming is (among other things) a practical skill that you need to practice to master. If you don’t write code (do several exercises for each chapter), reading this book will become a pointless theoretical exercise.

Most students — especially thoughtful good students — face times where they wonder whether their hard work is worthwhile. When (not if) this happens to you, take a break, re-read the foreword, look at Chapter 1 (“Computers, People, and Programming”) and Chapter 22 (“Ideals and History”). There, I try to articulate what I find exciting about programming and why I consider it a crucial tool for making a positive contribution to the world. If you wonder about my teaching philosophy and general approach, have a look at Chapter 0 (“Notes to the Reader”).

You might find the weight of this book worrying, but it should reassure you that part of the reason for the heft is that I prefer to repeat an explanation or add an example rather than have you search for the one and only explanation. The other major part of the reason is that the last third of the book is “additional material” presented for you to explore only if you are interested in more information about a specific area of programming, such as embedded systems programming, text analysis, or numerical computation.

And please don’t be too impatient. Learning any major new and valuable skill takes time, and is worth it.

A note to teachers

No, this is not a traditional Computer Science 101 course. It is a book about how to construct working software. As such, it leaves out much of what a computer science student is traditionally exposed to (Turing completeness, state machines, discrete math, Chomsky grammars, etc.). Even hardware is ignored on the assumption that students have used computers in various ways since kindergarten. This book does not even try to mention most important CS topics. It is about programming (or more generally about how to develop software) and as such it goes into more detail about fewer topics than many traditional courses. It tries to do just one thing well and Computer Science is not a one-course topic. If this book/course is used as part of a computer science, computer engineering, electrical engineering (many of our first students were EE majors) information science, or whatever program, I expect it to be taught alongside other courses as part of a well-rounded introduction.

Please read Chapter 0 (“Notes to the Reader”) for an explanation of my teaching philosophy, general approach, etc. Please try to convey those ideas to your students along the way.

Read More Show Less

Table of Contents

Preface xxv

Chapter 0: Notes to the Reader 1

0.1 The structure of this book 2

0.2 A philosophy of teaching and learning 6

0.3 Programming and computer science 12

0.4 Creativity and problem solving 12

0.5 Request for feedback 12

0.6 References 13

0.7 Biographies 13

Chapter 1: Computers, People, and Programming 17

1.1 Introduction 18

1.2 Software 19

1.3 People 21

1.4 Computer science 24

1.5 Computers are everywhere 25

1.6 Ideals for programmers 34

Part I: The Basics 41

Chapter 2: Hello, World! 43

2.1 Programs 44

2.2 The classic first program 45

2.3 Compilation 47

2.4 Linking 51

2.5 Programming environments 52

Chapter 3: Objects, Types, and Values 59

3.1 Input 60

3.2 Variables 62

3.3 Input and type 64

3.4 Operations and operators 66

3.5 Assignment and initialization 69

3.6 Composite assignment operators 73

3.7 Names 74

3.8 Types and objects 77

3.9 Type safety 78

Chapter 4: Computation 89

4.1 Computation 90

4.2 Objectives and tools 92

4.3 Expressions 94

4.4 Statements 100

4.4.1 Selection 102

4.4.2 Iteration 109

4.5 Functions 113

4.6 vector 117

4.7 Language features 125

Chapter 5: Errors 133

5.1 Introduction 134

5.2 Sources of errors 136

5.3 Compile-time errors 136

5.4 Link-time errors 139

5.5 Run-time errors 140

5.6 Exceptions 146

5.7 Logic errors 154

5.8 Estimation 157

5.9 Debugging 158

5.10 Pre- and post-conditions 163

5.11 Testing 166

Chapter 6: Writing a Program 173

6.1 A problem 174

6.2 Thinking about the problem 175

6.3 Back to the calculator! 178

6.4 Grammars 188

6.5 Turning a grammar into code 195

6.6 Trying the first version 203

6.7 Trying the second version 208

6.8 Token streams 209

6.9 Program structure 215

Chapter 7: Completing a Program 221

7.1 Introduction 222

7.2 Input and output 222

7.3 Error handling 224

7.4 Negative numbers 229

7.5 Remainder: % 230

7.6 Cleaning up the code 232

7.7 Recovering from errors 239

7.8 Variables 242

Chapter 8: Technicalities: Functions, etc. 255

8.1 Technicalities 256

8.2 Declarations and definitions 257

8.3 Header files 264

8.4 Scope 266

8.5 Function call and return 272

8.6 Order of evaluation 291

8.7 Namespaces 294

Chapter 9: Technicalities: Classes, etc. 303

9.1 User-defined types 304

9.2 Classes and members 305

9.3 Interface and implementation 306

9.4 Evolving a class 308

9.5 Enumerations 318

9.6 Operator overloading 321

9.7 Class interfaces 323

9.8 The Date class 334

Part II Input and Output 343

Chapter 10: Input and Output Streams 345

10.1 Input and output 346

10.2 The I/O stream model 347

10.3 Files 349

10.4 Opening a file 350

10.5 Reading and writing a file 352

10.6 I/O error handling 354

10.7 Reading a single value 358

10.8 User-defined output operators 363

10.9 User-defined input operators 365

10.10 A standard input loop 365

10.11 Reading a structured file 367

Chapter 11: Customizing Input and Output 379

11.1 Regularity and irregularity 380

11.2 Output formatting 380

11.3 File opening and positioning 388

11.4 String streams 394

11.5 Line-oriented input 395

11.6 Character classification 396

11.7 Using nonstandard separators 398

11.8 And there is so much more 406

Chapter 12: A Display Model 411

12.1 Why graphics? 412

12.2 A display model 413

12.3 A first example 414

12.4 Using a GUI library 418

12.5 Coordinates 419

12.6 Shapes 420

12.7 Using Shape primitives 421

12.8 Getting this to run 435

Chapter 13: Graphics Classes 441

13.1 Overview of graphics classes 442

13.2 Point and Line 444

13.3 Lines 447

13.4 Color 450

13.5 Line_style 452

13.6 Open_polyline 455

13.7 Closed_polyline 456

13.8 Polygon 458

13.9 Rectangle 460

13.10 Managing unnamed objects 465

13.11 Text 467

13.12 Circle 470

13.13 Ellipse 472

13.14 Marked_polyline 474

13.15 Marks 476

13.16 Mark 478

13.17 Images 479

Chapter 14: Graphics Class Design 487

14.1 Design principles 488

14.2 Shape 493

14.3 Base and derived classes 504

14.4 Benefits of object-oriented programming 513

Chapter 15: Graphing Functions and Data 519

15.1 Introduction 520

15.2 Graphing simple functions 520

15.3 Function 524

15.4 Axis 529

15.5 Approximation 532

15.6 Graphing data 537

Chapter 16: Graphical User Interfaces 551

16.1 User interface alternatives 552

16.2 The “Next” button 553

16.3 A simple window 554

16.4 Button and other Widgets 561

16.5 An example 565

16.6 Control inversion 569

16.7 Adding a menu 570

16.8 Debugging GUI code 575

Part III: Data and Algorithms 581

Chapter 17: Vector and Free Store 583

17.1 Introduction 584

17.2 vector basics 586

17.3 Memory, addresses, and pointers 588

17.4 Free store and pointers 591

17.5 Destructors 601

17.6 Access to elements 605

17.7 Pointers to class objects 606

17.8 Messing with types: void* and casts 608

17.9 Pointers and references 610

17.10 The this pointer 618

Chapter 18: Vectors and Arrays 627

18.1 Introduction 628

18.2 Initialization 629

18.3 Copying 631

18.4 Essential operations 640

18.5 Access to vector elements 646

18.5.1 Overloading on const 647

18.6 Arrays 648

18.7 Examples: palindrome 659

Chapter 19: Vector, Templates, and Exceptions 667

19.1 The problems 668

19.2 Changing size 671

19.3 Templates 678

19.4 Range checking and exceptions 693

19.5 Resources and exceptions 697

Chapter 20: Containers and Iterators 711

20.1 Storing and processing data 712

20.2 STL ideals 717

20.3 Sequences and iterators 720

20.4 Linked lists 724

20.5 Generalizing vector yet again 729

20.6 An example: a simple text editor 734

20.7 vector, list, and string 741

20.8 Adapting our vector to the STL 745

20.9 Adapting built-in arrays to the STL 747

20.10 Container overview 749

Chapter 21: Algorithms and Maps 757

21.1 Standard library algorithms 758

21.2 The simplest algorithm: find() 759

21.3 The general search: find_if() 763

21.4 Function objects 765

21.5 Numerical algorithms 770

21.6 Associative containers 776

21.7 Copying 789

21.8 Sorting and searching 794

21.9 Container algorithms 797

Part IV: Broadening the View 803

Chapter 22: Ideals and History 805

22.1 History, ideals, and professionalism 806

22.2 Programming language history overview 818

Chapter 23: Text Manipulation 849

23.1 Text 850

23.2 Strings 850

23.3 I/O streams 855

23.4 Maps 855

23.5 A problem 864

23.6 The idea of regular expressions 866

23.7 Searching with regular expressions 869

23.8 Regular expression syntax 872

23.9 Matching with regular expressions 880

23.10 References 885

Chapter 24: Numerics 889

24.1 Introduction 890

24.2 Size, precision, and overflow 890

24.3 Arrays 895

24.4 C-style multidimensional arrays 896

24.5 The Matrix library 897

24.6 An example: solving linear equations 908

24.7 Random numbers 914

24.8 The standard mathematical functions 917

24.9 Complex numbers 919

24.10 References 920

Chapter 25: Embedded Systems Programming 925

25.1 Embedded systems 926

25.2 Basic concepts 929

25.3 Memory management 935

25.4 Addresses, pointers, and arrays 943

25.5 Bits, bytes, and words 954

25.6 Coding standards 974

Chapter 26: Testing 989

26.1 What we want 990

26.2 Proofs 992

26.3 Testing 992

26.4 Design for testing 1011

26.5 Debugging 1012

26.6 Performance 1012

26.7 References 1016

Chapter 27: The C Programming Language 1021

27.1 C and C++: siblings 1022

27.2 Functions 1028

27.3 Minor language differences 1036

27.4 Free store 1043

27.5 C-style strings 1045

27.6 Input/output: stdio 1050

27.7 Constants and macros 1054

27.8 Macros 1055

27.9 An example: intrusive containers 1059

Part V: Appendices 1071

Appendix A: Language Summary 1073

A.1 General 1074

A.2 Literals 1077

A.3 Identifiers 1081

A.4 Scope, storage class, and lifetime 1082

A.5 Expressions 1086

A.6 Statements 1096

A.7 Declarations 1098

A.8 Built-in types 1099

A.9 Functions 1103

A.10 User-defined types 1106

A.11 Enumerations 1107

A.12 Classes 1108

A.13 Templates 1121

A.14 Exceptions 1125

A.15 Namespaces 1127

A.16 Aliases 1128

A.17 Preprocessor directives 1128

Appendix B: Standard Library Summary 1131

B.1 Overview 1132

B.2 Error handling 1137

B.3 Iterators 1139

B.4 Containers 1144

B.5 Algorithms 1152

B.6 STL utilities 1162

B.7 I/O streams 1168

B.8 String manipulation 1175

B.9 Numerics 1180

B.10 Time 1185

B.11 C standard library functions 1185

B.12 Other libraries 1195

Appendix C: Getting Started with Visual Studio 1197

C.1 Getting a program to run 1198

C.2 Installing Visual Studio 1198

C.3 Creating and running a program 1199

C.4 Later 1201

Appendix D: Installing FLTK 1203

D.1 Introduction 1204

D.2 Downloading FLTK 1204

D.3 Installing FLTK 1205

D.4 Using FLTK in Visual Studio 1205

D.5 Testing if it all worked 1206

Appendix E: GUI Implementation 1207

E.1 Callback implementation 1208

E.2 Widget implementation 1209

E.3 Window implementation 1210

E.4 Vector_ref 1212

E.5 An example: manipulating Widgets 1213

Glossary 1217

Bibliography 1223

Index 1227

Read More Show Less

Preface

Damn the torpedoes! Full speed ahead.
—Admiral Farragut

Programming is the art of expressing solutions to problems so that a computer can execute those solutions. Much of the effort in programming is spent finding and refining solutions. Often, a problem is only fully understood through the process of programming a solution for it.

This book is for someone who has never programmed before, but is willing to work hard to learn. It helps you acquire the principles and practical skills of programming using the C++ programming language. My aim is for you to gain sufficient knowledge and experience to perform simple useful programming tasks using the best up-to-date techniques. How long will that take? As part of a first-year university course, you can work through this book in a semester (assuming that you have a workload of four courses of average difficulty). If you work by yourself, don’t expect to spend less time than that (maybe 15 hours a week for 14 weeks).

Three months may seem a long time, but there’s a lot to learn and you’ll be writing your first simple programs after about an hour. Also, all learning is gradual: each chapter introduces new useful concepts and illustrates them with examples inspired by real-world uses. Your ability to express ideas in code — getting a computer to do what you want it to do — gradually and steadily increases as you go along. I never say “learn a month’s worth of theory and then see if you can use it.”

Why would you want to program? Our civilization runs on software. Without understanding software you are reduced to believing in “magic” and will be locked out of many of the most interesting, profitable, and socially useful technical fields of work. When I talk about programming, I think of the whole spectrum of computer programs from personal computer applications with GUIs (Graphical User Interfaces), through engineering calculations and embedded system control applications (such as digital cameras, cars, and cell phones), to text manipulation applications as found in many humanities and business applications. Like mathematics, programming — when done well — is a valuable intellectual exercise that sharpens our ability to think. However, thanks to feedback from the computer, programming is more concrete than most forms of math, and therefore accessible to more people. It is a way to reach out and change the world — hopefully for the better. Finally, programming can be great fun.

Why C++? You can’t learn to program without a programming language and C++ directly supports the key concepts and techniques used in real-world software. C++ is one of the most widely used programming languages, found in an unsurpassed range of application areas. You find C++ applications everywhere from the bottom of the oceans to the surface of Mars. C++ is precisely and comprehensively defined by a non-proprietary international standard. Quality and/or free implementations are available on every kind of computer. Most of the programming concepts that you will learn using C++ can be used directly in other languages, such as C, C#, Fortran, and Java. Finally, I simply like C++ as a language for writing elegant and efficient code.

This is not the easiest book on beginning programming; it is not meant to be. I just aim for it to be the easiest book from which you can learn the basics of real-world programming. That’s quite an ambitious goal because much modern software relies on techniques considered advanced just a few years ago.

My fundamental assumption is that you want to write programs for the use of others, and to do so responsibly providing a decent level of system quality. That is, I assume that you want to achieve a level of professionalism. Consequently, I chose the topics for this book to cover what is needed to get started with real-world programming, not just what is easy to teach and learn. If you need a technique to get basic work done right, I’ll describe it, demonstrate concepts and language facilities needed to support the technique, provide exercises for it, and expect you to work on those exercises. If you just want to understand toy programs, you can get along with far less than I present. On the other hand, I won’t waste your time with material of marginal practical importance. If an idea is explained here, it’s because you’ll almost certainly need it.

If your desire is to use the work of others without understanding how things are done and without adding significantly to the code yourself, this book is not for you. If so, please consider if you would be better served by another book and another language. If that is approximately your view of programming, please also consider from where you got that view and whether it in fact is adequate for your needs. People often underestimate the complexity of programming as well as its value. I would hate for you to acquire a dislike for programming because of a mismatch between what you needed and the part of the software reality I describe. There are many parts of the “Information Technology” world that do not require knowledge of programming. This book is aimed to serve those who do want to write nontrivial programs.

Because of its structure and practical aims, this book can also be used as a second book on programming for someone who already knows a bit of C++ or for someone who programs in another language and wants to learn C++. If you fit into one of those categories, I refrain from guessing how long it will take you to read this book, but I do encourage you to do many of our exercises. This will help you to counteract the common problem of writing programs in older, familiar, styles rather than adopting newer techniques where these are more appropriate. If you have learned C++ in one of the more traditional ways, you’ll find something surprising and useful before you reach Chapter 7. Unless your name is Stroustrup, what I discuss here is not “your father’s C++.”

Programming is learned by writing programs. In this, programming is similar to other endeavors with a practical component. You cannot learn to swim, to play a musical instrument, or to drive a car just from reading a book — you must practice. Nor can you learn to program without reading and writing lots of code. This book focuses on code examples closely tied to explanatory text and diagrams. You need those to understand the ideals, concepts, and principles of programming and to master the language constructs used to express them. That’s essential, but by itself, it will not give you the practical skills of programming. For that, you need to do the exercises and get used to the tools for writing, compiling, and running programs. You need to make your own mistakes, and learn to correct them. There is no substitute for writing code. Besides, that’s where the fun is!

On the other hand, there is more to programming — much more — than following a few rules and reading the manual. This book is emphatically not focused on “the syntax of C++.” Understanding the fundamental ideals, principles, and techniques is essence of a good programmer. Only well-designed code has a chance of becoming part of a correct, reliable, and maintainable system. Also, “the fundamentals” are what lasts: they will still be essential after today’s languages and tools have evolved or been replaced.

What about computer science, software engineering, information technology, etc.? Is that all programming? Of course not! Programming is one of the fundamental topics that underlie everything in computer-related fields and has a natural place in a balanced course of computer science. I provide brief introductions to key concepts and techniques of algorithms, data structures, user interfaces, data processing, and software engineering. However, this book is not a substitute for a thorough and balanced study of those topics.

Code can be beautiful as well as useful. This book is written to help you see that, to understand what it means for code to be beautiful and to help you to acquire the principles and practical skills to create such code. Good luck with programming!

A note to students

Of the 1,000++ first-year students we have taught so far using drafts of this book at Texas A&M University, about 60% had programmed before and about 40% had never seen a line of code in their life. Most succeeded, so you can do it too.

You don’t have to read this book as part of a course. I assume that the book will be widely used for self study. However, whether you work your way through as part of a course or independently, try to work with others. Programming has an — unfair — reputation as a lonely activity. Most people work better and learn faster when they are part of a group with a common aim. Learning together and discussing problems with friends is not cheating! It is the most efficient — as well as most pleasant — way of making progress. If nothing else, working with friends forces you to articulate your ideas, which is just about the most efficient way of testing your understanding and making sure you remember. You don’t actually have to personally discover the answer to every obscure language and programming environment problem. However, please don’t cheat yourself by not doing the drills and a fair number of exercises (even if no teacher forces you to do them). Remember: programming is (among other things) a practical skill that you need to practice to master. If you don’t write code (do several exercises for each chapter), reading this book will become a pointless theoretical exercise.

Most students — especially thoughtful good students — face times where they wonder whether their hard work is worthwhile. When (not if) this happens to you, take a break, re-read the foreword, look at Chapter 1 (“Computers, People, and Programming”) and Chapter 22 (“Ideals and History”). There, I try to articulate what I find exciting about programming and why I consider it a crucial tool for making a positive contribution to the world. If you wonder about my teaching philosophy and general approach, have a look at Chapter 0 (“Notes to the Reader”).

You might find the weight of this book worrying, but it should reassure you that part of the reason for the heft is that I prefer to repeat an explanation or add an example rather than have you search for the one and only explanation. The other major part of the reason is that the last third of the book is “additional material” presented for you to explore only if you are interested in more information about a specific area of programming, such as embedded systems programming, text analysis, or numerical computation.

And please don’t be too impatient. Learning any major new and valuable skill takes time, and is worth it.

A note to teachers

No, this is not a traditional Computer Science 101 course. It is a book about how to construct working software. As such, it leaves out much of what a computer science student is traditionally exposed to (Turing completeness, state machines, discrete math, Chomsky grammars, etc.). Even hardware is ignored on the assumption that students have used computers in various ways since kindergarten. This book does not even try to mention most important CS topics. It is about programming (or more generally about how to develop software) and as such it goes into more detail about fewer topics than many traditional courses. It tries to do just one thing well and Computer Science is not a one-course topic. If this book/course is used as part of a computer science, computer engineering, electrical engineering (many of our first students were EE majors) information science, or whatever program, I expect it to be taught alongside other courses as part of a well-rounded introduction.

Please read Chapter 0 (“Notes to the Reader”) for an explanation of my teaching philosophy, general approach, etc. Please try to convey those ideas to your students along the way.

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)