SlideShare a Scribd company logo
1 of 21
ENERGY 211 / CME 211
Computer Programming in
C++ for Earth Scientists and
Engineers
Lecture 1
September 22, 2008
2
Why This Course?
• To help students improve or acquire the
programming skills they need for
research in earth sciences or
engineering
• Alternative to CS106X, with more
relevant examples and exercises
3
What is Covered?
• Learning C++
– Basics
– Classes
– Standard C++ library, including STL
• Software Engineering Practices
– Computer architecture essentials
– Design, testing, debugging
– Efficient memory usage
• Special Topics
4
Course Staff
• Instructor: Prof. Jim Lambers
– Acting assistant professor, ERE/ICME
– Former software engineer
– Email: lambers@stanford.edu
• TA: Alejandro David Leiva
– MS student, ERE
– Email: aleiva@stanford.edu
• TA: Yifan Zhou
– MS student, ERE
– Email: yifanz@stanford.edu
5
Course Web Sites
• http://energy211.stanford.edu
– Primary site, for easier access to course
materials and information
• http://coursework.stanford.edu
– For viewing grades, receiving email
announcements
• Lecture notes, assignments available at
either site
6
Your Grade
• No midterm or final exam
• 6 programming projects, 10-15% each
• Final project, 30%
• Bonus: 1% added to overall grade if at
least 5 coding-related questions asked
by e-mail to instructor
• Letter grades: straight scale (or nicer)
7
Programming Projects
• 6 projects, one week each
• Can (and should!) work with a partner
– Can be different partner for each project
– No changing partners in the middle of a
project
• Must be submitted electronically (details
to come)
• First project to be distributed on Friday,
October 3
8
Late Days
• Programming projects must be
submitted electronically by 11:59pm on
the due date
• You have five late days for the entire
quarter that may be used at any time,
no questions asked
• Use them wisely, they might be all you
get!
9
Why C++?
• To maximize computational efficiency,
best to use low-level programming
languages (easy to translate into
efficient machine code)
• To efficiently build large applications,
best to use high-level languages that
support modularity, abstraction and
encapsulation
• C++ combines aspects of both
10
Low-level C/C++
#include <stdlib.h>
extern ssize_t write(int, const void *, size_t);
int main()
{
write(1, "Hello world!n", 13);
}
0: 1b 00 00 00 sethi %hi(0x0), %o5
4: 82 10 00 0f mov %o7, %g1
8: 92 03 60 00 add %o5, 0, %o1
c: 90 10 20 01 mov 1, %o0
10: 94 10 20 0d mov 13, %o2
14: 40 00 00 00 call 0x14
18: 9e 10 00 01 mov %g1, %o7
C code
Assembly
code
11
High-level C++
#include <iostream>
int main()
{
std::cout << "Hello world!" << std::endl;
}
• Easier to understand this program’s purpose:
to send text and end-of-line to output device
• No need for device descriptors, computing text
length, or escape sequences
• Being programmer-friendlier carries a cost:
assembly code is nearly 4 times as long!
12
A Few Buzzwords
• Modularity: the extent to which a
program is decomposed into separate
modules, thus simplifying design
• Abstraction: the practice of reducing or
factoring out details so that one can
focus on only a few concepts at a time
• Encapsulation: hiding the design of a
task from the rest of the application,
thus protecting it from changes
13
What C++ Offers
• All of the power and efficiency of C
(which is a subset)
• Object-oriented programming (though
not truly an object-oriented language)
• Generic programming, through
templates
• Definition and extension of operators
• Freedom to use paradigm of choice
14
Why Not Just Use MATLAB?
• MATLAB is useful for proof-of-concept,
but not for release-grade software
• Its language is interpreted, not compiled
into machine code
• Only offers a subset of the functionality
of a compiled language such as C++
• This lack of flexibility significantly, and
adversely, impacts usability and
performance
15
Examples of Drawbacks
• MATLAB uses LAPACK and BLAS for
its low-level linear algebra operations
• Use of other libraries is much more
difficult and less efficient
• Forced to use MATLAB’s data
structures for dense and sparse
matrices, or other data
• Lack of control over how data is
accessed results in needless copying
16
Effective Software
Engineering
• Involves much more than just designing
and implementing algorithms
• Criteria for a program’s usefulness:
– Does it accomplish its intended task, and if
so, with what limitations?
– How efficient is it, in the given computing
environment?
– How robust is it? Does it handle adverse
conditions gracefully?
17
Hard Lessons
• The sooner you start writing code, the
longer it takes you to finish
• Untested code will almost always fail
• What works today can be broken
tomorrow
• The first person to use your code will
input the one case that it doesn’t handle
• Document code well, because your
code can be unintelligible, even to you
18
Sound Programming Practices
are Essential!
• In 1991 Gulf War, US Patriot missiles
intercepted Iraqi SCUD missiles by
estimating velocity = distance / time
• Time interval obtained by subtracting
times at which position was determined
• Times measured as seconds since
tracking devices first activated in the
field
19
Tracking SCUD Missiles
Correct Incorrect
Source: U.S. GAO Report
20
Little Details Aren’t Really
Little
• Time values large, but close together,
so subtraction inaccurate, due to
catastrophic cancellation
• Velocity estimates useless, so missile’s
position could not be determined
• Interception failed, led to 28 deaths
• What is a simple remedy?
21
Next Time
• Overview of C++:
– History
– Design
• How to write and run C++ programs
– Windows
– UNIX/LINUX
• Understanding simple C++ programs

More Related Content

Similar to Lecture1.ppt

CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)Dilawar Khan
 
C-and-Cpp-Brochure-English. .
C-and-Cpp-Brochure-English.               .C-and-Cpp-Brochure-English.               .
C-and-Cpp-Brochure-English. .spotguys705
 
Unit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptxUnit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptxshashiden1
 
Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++Vaibhav Khanna
 
05 Lecture - PARALLEL Programming in C ++.pdf
05 Lecture - PARALLEL Programming in C ++.pdf05 Lecture - PARALLEL Programming in C ++.pdf
05 Lecture - PARALLEL Programming in C ++.pdfalivaisi1
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesInductive Automation
 
lecture01_Introduction.pdf
lecture01_Introduction.pdflecture01_Introduction.pdf
lecture01_Introduction.pdfMarlonMagtibay2
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesInductive Automation
 
The security professional's guide to programming - Eric Vanderburg
The security professional's guide to programming - Eric VanderburgThe security professional's guide to programming - Eric Vanderburg
The security professional's guide to programming - Eric VanderburgEric Vanderburg
 
Oop lec 2(introduction to object oriented technology)
Oop lec 2(introduction to object oriented technology)Oop lec 2(introduction to object oriented technology)
Oop lec 2(introduction to object oriented technology)Asfand Hassan
 
Creating a textual domain specific language
Creating a textual domain specific languageCreating a textual domain specific language
Creating a textual domain specific languageVicente García Díaz
 
Querix 4 gl app analyzer 2016 journey to the center of your 4gl application
Querix 4 gl app analyzer 2016 journey to the center of your 4gl applicationQuerix 4 gl app analyzer 2016 journey to the center of your 4gl application
Querix 4 gl app analyzer 2016 journey to the center of your 4gl applicationBeGooden-IT Consulting
 
C++ vs C#
C++ vs C#C++ vs C#
C++ vs C#sudipv
 
Domain specific modelling (DSM)
Domain specific modelling (DSM)Domain specific modelling (DSM)
Domain specific modelling (DSM)PG Scholar
 
Verilog Lecture1
Verilog Lecture1Verilog Lecture1
Verilog Lecture1Béo Tú
 

Similar to Lecture1.ppt (20)

CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)
 
C-and-Cpp-Brochure-English. .
C-and-Cpp-Brochure-English.               .C-and-Cpp-Brochure-English.               .
C-and-Cpp-Brochure-English. .
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
201811xx foredrag c_cpp
201811xx foredrag c_cpp201811xx foredrag c_cpp
201811xx foredrag c_cpp
 
Unit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptxUnit 1 introduction to c++.pptx
Unit 1 introduction to c++.pptx
 
Lec 01 introduction
Lec 01   introductionLec 01   introduction
Lec 01 introduction
 
Object oriented programming 7 first steps in oop using c++
Object oriented programming 7 first steps in oop using  c++Object oriented programming 7 first steps in oop using  c++
Object oriented programming 7 first steps in oop using c++
 
05 Lecture - PARALLEL Programming in C ++.pdf
05 Lecture - PARALLEL Programming in C ++.pdf05 Lecture - PARALLEL Programming in C ++.pdf
05 Lecture - PARALLEL Programming in C ++.pdf
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
cv11
cv11cv11
cv11
 
lecture01_Introduction.pdf
lecture01_Introduction.pdflecture01_Introduction.pdf
lecture01_Introduction.pdf
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
The security professional's guide to programming - Eric Vanderburg
The security professional's guide to programming - Eric VanderburgThe security professional's guide to programming - Eric Vanderburg
The security professional's guide to programming - Eric Vanderburg
 
Amit_Resume
Amit_ResumeAmit_Resume
Amit_Resume
 
Oop lec 2(introduction to object oriented technology)
Oop lec 2(introduction to object oriented technology)Oop lec 2(introduction to object oriented technology)
Oop lec 2(introduction to object oriented technology)
 
Creating a textual domain specific language
Creating a textual domain specific languageCreating a textual domain specific language
Creating a textual domain specific language
 
Querix 4 gl app analyzer 2016 journey to the center of your 4gl application
Querix 4 gl app analyzer 2016 journey to the center of your 4gl applicationQuerix 4 gl app analyzer 2016 journey to the center of your 4gl application
Querix 4 gl app analyzer 2016 journey to the center of your 4gl application
 
C++ vs C#
C++ vs C#C++ vs C#
C++ vs C#
 
Domain specific modelling (DSM)
Domain specific modelling (DSM)Domain specific modelling (DSM)
Domain specific modelling (DSM)
 
Verilog Lecture1
Verilog Lecture1Verilog Lecture1
Verilog Lecture1
 

More from AqeelAbbas94

lecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjd
lecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjdlecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjd
lecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjdAqeelAbbas94
 
1-Lec - Introduction vhvv,vbvv,v (2).ppt
1-Lec - Introduction vhvv,vbvv,v (2).ppt1-Lec - Introduction vhvv,vbvv,v (2).ppt
1-Lec - Introduction vhvv,vbvv,v (2).pptAqeelAbbas94
 
2-Lec - History of OOP and Java (1) .ppt
2-Lec - History of OOP and Java  (1) .ppt2-Lec - History of OOP and Java  (1) .ppt
2-Lec - History of OOP and Java (1) .pptAqeelAbbas94
 
Lecture-32-33.pptx
Lecture-32-33.pptxLecture-32-33.pptx
Lecture-32-33.pptxAqeelAbbas94
 
10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptx10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptxAqeelAbbas94
 
use_case+use_case description.pptx
use_case+use_case description.pptxuse_case+use_case description.pptx
use_case+use_case description.pptxAqeelAbbas94
 
555e81217b39f1c1262b33d0.ppt
555e81217b39f1c1262b33d0.ppt555e81217b39f1c1262b33d0.ppt
555e81217b39f1c1262b33d0.pptAqeelAbbas94
 
12-Lec - Repetition For Loop.pptx
12-Lec - Repetition For Loop.pptx12-Lec - Repetition For Loop.pptx
12-Lec - Repetition For Loop.pptxAqeelAbbas94
 
wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...
wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...
wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...AqeelAbbas94
 
19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.pptAqeelAbbas94
 
Your Title goes Here.pptx
Your Title goes Here.pptxYour Title goes Here.pptx
Your Title goes Here.pptxAqeelAbbas94
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.pptAqeelAbbas94
 

More from AqeelAbbas94 (20)

lecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjd
lecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjdlecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjd
lecture_5 (2).ppt hjhrrgjbgrmgrhbgrgghjd
 
1-Lec - Introduction vhvv,vbvv,v (2).ppt
1-Lec - Introduction vhvv,vbvv,v (2).ppt1-Lec - Introduction vhvv,vbvv,v (2).ppt
1-Lec - Introduction vhvv,vbvv,v (2).ppt
 
2-Lec - History of OOP and Java (1) .ppt
2-Lec - History of OOP and Java  (1) .ppt2-Lec - History of OOP and Java  (1) .ppt
2-Lec - History of OOP and Java (1) .ppt
 
Lecture-32-33.pptx
Lecture-32-33.pptxLecture-32-33.pptx
Lecture-32-33.pptx
 
10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptx10-Lec - Nested IF Statement.pptx
10-Lec - Nested IF Statement.pptx
 
blue.pptx
blue.pptxblue.pptx
blue.pptx
 
use_case+use_case description.pptx
use_case+use_case description.pptxuse_case+use_case description.pptx
use_case+use_case description.pptx
 
555e81217b39f1c1262b33d0.ppt
555e81217b39f1c1262b33d0.ppt555e81217b39f1c1262b33d0.ppt
555e81217b39f1c1262b33d0.ppt
 
12-Lec - Repetition For Loop.pptx
12-Lec - Repetition For Loop.pptx12-Lec - Repetition For Loop.pptx
12-Lec - Repetition For Loop.pptx
 
hexagon.pptx
hexagon.pptxhexagon.pptx
hexagon.pptx
 
wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...
wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...
wepik-exploring-the-robust-features-of-samsung-health-app-enhancing-well-bein...
 
lecture56.ppt
lecture56.pptlecture56.ppt
lecture56.ppt
 
04.ppt
04.ppt04.ppt
04.ppt
 
19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt
 
SelectionSort.ppt
SelectionSort.pptSelectionSort.ppt
SelectionSort.ppt
 
Lecture2 (1).ppt
Lecture2 (1).pptLecture2 (1).ppt
Lecture2 (1).ppt
 
ch06.ppt
ch06.pptch06.ppt
ch06.ppt
 
Your Title goes Here.pptx
Your Title goes Here.pptxYour Title goes Here.pptx
Your Title goes Here.pptx
 
SE_models_1.ppt
SE_models_1.pptSE_models_1.ppt
SE_models_1.ppt
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt
 

Recently uploaded

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfNirmal Dwivedi
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxCeline George
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxakanksha16arora
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonhttgc7rh9c
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 

Recently uploaded (20)

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 

Lecture1.ppt

  • 1. ENERGY 211 / CME 211 Computer Programming in C++ for Earth Scientists and Engineers Lecture 1 September 22, 2008
  • 2. 2 Why This Course? • To help students improve or acquire the programming skills they need for research in earth sciences or engineering • Alternative to CS106X, with more relevant examples and exercises
  • 3. 3 What is Covered? • Learning C++ – Basics – Classes – Standard C++ library, including STL • Software Engineering Practices – Computer architecture essentials – Design, testing, debugging – Efficient memory usage • Special Topics
  • 4. 4 Course Staff • Instructor: Prof. Jim Lambers – Acting assistant professor, ERE/ICME – Former software engineer – Email: lambers@stanford.edu • TA: Alejandro David Leiva – MS student, ERE – Email: aleiva@stanford.edu • TA: Yifan Zhou – MS student, ERE – Email: yifanz@stanford.edu
  • 5. 5 Course Web Sites • http://energy211.stanford.edu – Primary site, for easier access to course materials and information • http://coursework.stanford.edu – For viewing grades, receiving email announcements • Lecture notes, assignments available at either site
  • 6. 6 Your Grade • No midterm or final exam • 6 programming projects, 10-15% each • Final project, 30% • Bonus: 1% added to overall grade if at least 5 coding-related questions asked by e-mail to instructor • Letter grades: straight scale (or nicer)
  • 7. 7 Programming Projects • 6 projects, one week each • Can (and should!) work with a partner – Can be different partner for each project – No changing partners in the middle of a project • Must be submitted electronically (details to come) • First project to be distributed on Friday, October 3
  • 8. 8 Late Days • Programming projects must be submitted electronically by 11:59pm on the due date • You have five late days for the entire quarter that may be used at any time, no questions asked • Use them wisely, they might be all you get!
  • 9. 9 Why C++? • To maximize computational efficiency, best to use low-level programming languages (easy to translate into efficient machine code) • To efficiently build large applications, best to use high-level languages that support modularity, abstraction and encapsulation • C++ combines aspects of both
  • 10. 10 Low-level C/C++ #include <stdlib.h> extern ssize_t write(int, const void *, size_t); int main() { write(1, "Hello world!n", 13); } 0: 1b 00 00 00 sethi %hi(0x0), %o5 4: 82 10 00 0f mov %o7, %g1 8: 92 03 60 00 add %o5, 0, %o1 c: 90 10 20 01 mov 1, %o0 10: 94 10 20 0d mov 13, %o2 14: 40 00 00 00 call 0x14 18: 9e 10 00 01 mov %g1, %o7 C code Assembly code
  • 11. 11 High-level C++ #include <iostream> int main() { std::cout << "Hello world!" << std::endl; } • Easier to understand this program’s purpose: to send text and end-of-line to output device • No need for device descriptors, computing text length, or escape sequences • Being programmer-friendlier carries a cost: assembly code is nearly 4 times as long!
  • 12. 12 A Few Buzzwords • Modularity: the extent to which a program is decomposed into separate modules, thus simplifying design • Abstraction: the practice of reducing or factoring out details so that one can focus on only a few concepts at a time • Encapsulation: hiding the design of a task from the rest of the application, thus protecting it from changes
  • 13. 13 What C++ Offers • All of the power and efficiency of C (which is a subset) • Object-oriented programming (though not truly an object-oriented language) • Generic programming, through templates • Definition and extension of operators • Freedom to use paradigm of choice
  • 14. 14 Why Not Just Use MATLAB? • MATLAB is useful for proof-of-concept, but not for release-grade software • Its language is interpreted, not compiled into machine code • Only offers a subset of the functionality of a compiled language such as C++ • This lack of flexibility significantly, and adversely, impacts usability and performance
  • 15. 15 Examples of Drawbacks • MATLAB uses LAPACK and BLAS for its low-level linear algebra operations • Use of other libraries is much more difficult and less efficient • Forced to use MATLAB’s data structures for dense and sparse matrices, or other data • Lack of control over how data is accessed results in needless copying
  • 16. 16 Effective Software Engineering • Involves much more than just designing and implementing algorithms • Criteria for a program’s usefulness: – Does it accomplish its intended task, and if so, with what limitations? – How efficient is it, in the given computing environment? – How robust is it? Does it handle adverse conditions gracefully?
  • 17. 17 Hard Lessons • The sooner you start writing code, the longer it takes you to finish • Untested code will almost always fail • What works today can be broken tomorrow • The first person to use your code will input the one case that it doesn’t handle • Document code well, because your code can be unintelligible, even to you
  • 18. 18 Sound Programming Practices are Essential! • In 1991 Gulf War, US Patriot missiles intercepted Iraqi SCUD missiles by estimating velocity = distance / time • Time interval obtained by subtracting times at which position was determined • Times measured as seconds since tracking devices first activated in the field
  • 19. 19 Tracking SCUD Missiles Correct Incorrect Source: U.S. GAO Report
  • 20. 20 Little Details Aren’t Really Little • Time values large, but close together, so subtraction inaccurate, due to catastrophic cancellation • Velocity estimates useless, so missile’s position could not be determined • Interception failed, led to 28 deaths • What is a simple remedy?
  • 21. 21 Next Time • Overview of C++: – History – Design • How to write and run C++ programs – Windows – UNIX/LINUX • Understanding simple C++ programs