Chapters 1 & 2 Programming and Programs: From Bjarne Stroustrup S Lecture Course
Chapters 1 & 2 Programming and Programs: From Bjarne Stroustrup S Lecture Course
Programming and
Programs
From Bjarne Stroustrups lecture course:
www.stroustrup.com/Programming
Abstract
In this lecture, well outline the aims for this course and present a rough
course plan. Well introduce the basic notion of programming and give
examples of areas in which software is critical to our civilization. Finally,
well present the simplest possible C++ program and outline how it can
be made into running code.
Stroustrup/Programming
Overview
Course aims and outline
Programming
Hello, world!
Compilation
Stroustrup/Programming
This is a module
In OO Programming
For OOP beginners
who want to become professionals
i.e., people who can produce systems that others will use
Stroustrup/Programming
Not!
An easy module
A module in
For students
Using
Stroustrup/Programming
The Aims
Teach/learn
The Means
Lectures
Attend every one
Notes/Chapters
Read a chapter ahead (about one per lecture)
Read the chapter again after each lecture
Feedback is welcome (typos, suggestions, etc.)
Stroustrup/Programming
Exercises
Exam: 50%
Stroustrup/Programming
Cooperate on Learning
Dont claim to have written code that you copied from others
Dont give anyone else your code (to hand in for a grade)
When you rely on the work of others, explicitly list all of your sources
i.e. give credit to those who did the work
Why C++ ?
http://www.research.att.com/~bs/applications.html
Stroustrup/Programming
10
Why C++ ?
Stroustrup/Programming
11
Throughout
Program design and development techniques
C++ language features
Background and related fields, topics, and languages
Stroustrup/Programming
12
Promises
Detail: We will try to explain every construct used in this course
in sufficient detail for real understanding
There is no magic
Stroustrup/Programming
13
More Promises
Realism: the concepts, constructs, and techniques can be used
to build industrial strength programs
i.e., they have been used to
Stroustrup/Programming
14
Feedback request
Please post questions and constructive comments to the
moodle site:
http://moodle.itb.ie/mod/forum/view.php?id=52659
Or you could email [email protected]
Your feedback will be most appreciated
On style, contents, detail, examples, clarity, conceptual problems,
exercises, missing information, depth, etc.
Stroustrup/Programming
15
Why programming?
Our civilization runs on software
Most engineering activities involve software
Stroustrup/Programming
16
Ships
Design
Construction
Management
Monitoring
Engine
Hull design
Pumps
Stroustrup/Programming
17
Aircraft
Communication
Control
Display
Signal processing
Gadget control
Monitoring
Stroustrup/Programming
18
Phones
Voice quality
User interfaces
Billing
Mobility
Stroustrup/Programming
Switching
Reliability
Provisioning
Images
19
Energy
Control
Monitoring
Analysis
Design
Stroustrup/Programming
Communications
Visualization
Manufacturing
20
PC/workstation
Stroustrup/Programming
21
Mars rovers, animation, graphics, Photoshop, GUI, OS, compilers, slides, chip
design, chip manufacturing, semiconductor tools, etc.
See www.research.att/~bs/applications.html
Stroustrup/Programming
22
Stroustrup/Programming
23
24
A second program
// modified for Windows console mode:
#include "../../std_lib_facilities.h"
int main()
// main() is where a C++ program starts
{
cout << "Hello, world\n";
// output the 13 characters hello, world!
// followed by a new line
keep_window_open();
// wait for a keystroke
return 0;
// return a value indicating success
}
// without keep_window_open() the output window will be closed immediately
// before you have a chance to read the output (on Visual C++ 2003)
Stroustrup/Programming
25
Hello, world!
Hello world is a very important program
Its purpose is to help you get used to your tools
Compiler
Program development environment
Program execution environment
Stroustrup/Programming
26
Hello world
Its almost all boiler plate
Thats normal
Most of our code, and most of the systems we use simply exist to make
some other code elegant and/or efficient
real world non-software analogies abound
Style Matters!
Stroustrup/Programming
27
The compiler translates what you wrote into object code (sometimes called
machine code)
Object code is simple enough for a computer to understand
28
So what is programming?
Conventional definitions
Telling a very fast moron exactly what to do
A plan for solving a problem on a computer
Specifying the order of a program execution
But modern programs often involve millions of lines of code
And manipulation of data is central
29
Programming
Programming is fundamentally simple
Just state what the machine is to do
Programming is understanding
When you can program a task, you understand it
When you program, you spend significant time trying to understand the
task you want to automate
30
Stroustrup/Programming
31