1 C++ and Real-Time Programming B.E. Glendenning 1999-Apr-13.

Slides:



Advertisements
Similar presentations
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Advertisements

Object-oriented Software Change Dynamic Impact Analysis Lulu Huang and Yeong-Tae Song Dept. of Computer and Information Sciences Towson University Towson,
C++ Programming Languages
CSE 341, Winter Type Systems Terms to learn about types: –Type –Type system –Statically typed language –Dynamically typed language –Type error –Strongly.
1 Objects and ClassesStefan Kluth 1.6Objects and Classes 1.6What is an Object? 1.7Objects and Classes 1.8Object Interface, Class Inheritance, Polymorphism.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Scripting Languages For Virtual Worlds. Outline Necessary Features Classes, Prototypes, and Mixins Static vs. Dynamic Typing Concurrency Versioning Distribution.
C++ Training Datascope Lawrence D’Antonio Lecture 3 An Overview of C++
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles C/C++ Emery Berger and Mark Corner University of Massachusetts.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Algorithm Programming Coding Advices Bar-Ilan University תשס " ו by Moshe Fresko.
Language Issues Misunderstimated? Sublimable? Hopefuller? "I know how hard it is for you to put food on your family.” "I know the human being and fish.
C ++ Programming Languages Omid Jafarinezhad Lecturer: Omid Jafarinezhad Fall 2013 Lecture 2 C ++ -overview Department of Computer Engineering 1.
CIT241 Prerequisite Knowledge ◦ Variables ◦ Operators ◦ C++ Syntax ◦ Program Structure ◦ Classes  Basic Structure of a class  Concept of Data Hiding.
Types in programming languages What are types, and why do we need them? Types in programming languages1.
Language Evaluation Criteria
Programming Languages and Paradigms Object-Oriented Programming.
C++ Programming. Table of Contents History What is C++? Development of C++ Standardized C++ What are the features of C++? What is Object Orientation?
EE4E. C++ Programming Lecture 1 From C to C++. Contents Introduction Introduction Variables Variables Pointers and references Pointers and references.
Programming Language C++ Xulong Peng CSC415 Programming Languages.
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
Object Oriented Programming Elhanan Borenstein copyrights © Elhanan Borenstein.
1 ENERGY 211 / CME 211 Lecture 26 November 19, 2008.
8-1 Embedded Systems Fixed-Point Math and Other Optimizations.
Copyright © 2005 Elsevier Chapter 8 :: Subroutines and Control Abstraction Programming Language Pragmatics Michael L. Scott.
Core Java: Essential Features 08/05/2015 Kien Tran.
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
Rapid Development Part 2 Mihail V. Mihaylov (Mike Ramm) CEO, RammSoft Mihail V. Mihaylov (Mike Ramm) CEO, RammSoft February.
Software Development. Software Developers Refresher A person or organization that designs software and writes the programs. Software development is the.
GPCE'04, Vancouver 1 Towards a General Template Introspection Library in C++ István Zólyomi, Zoltán Porkoláb Department of Programming Languages and Compilers.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
OOPLs /FEN March 2004 Object-Oriented Languages1 Object-Oriented Languages - Design and Implementation Java: Behind the Scenes Finn E. Nordbjerg,
C++ Memory Overview 4 major memory segments Key differences from Java
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look, Part 2.
1 Memory Management Basics. 2 Program P Basic Memory Management Concepts Address spaces Physical address space — The address space supported by the hardware.
Types in programming languages1 What are types, and why do we need them?
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
Real Time Programming Language. Intro A programming language represents the nexus of design and structure. But misuse of the programming language can.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Copyright , Dennis J. Frailey CSE7315 – Software Project Management CSE7315 M18 - Version 9.01 SMU CSE 7315 Planning and Managing a Software Project.
C++ (intro) Created by Hwansoo Han Edited by Ikjun Yeom.
Computer Graphics 3 Lecture 1: Introduction to C/C++ Programming Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.
Compiler Directives. The C Preprocessor u The C preprocessor (cpp) changes your source code based on instructions, or preprocessor directives, embedded.
A Survey of Object-Oriented Concept Oscar Nierstrasz.
CISC. What is it?  CISC - Complex Instruction Set Computer  CISC is a design philosophy that:  1) uses microcode instruction sets  2) uses larger.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (2/2)
Lecture 10 Page 1 CS 111 Online Memory Management CS 111 On-Line MS Program Operating Systems Peter Reiher.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 20 – C++ Subclasses and Inheritance.
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel.
ISBN Chapter 12 Support for Object-Oriented Programming.
A Survey of Object-Oriented Concepts, by Oscar Nierstrasz Reviewed by Odd Petter N. Slyngstad for DT8100, 27/1/2005.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Realizing Concurrency using the thread model
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Chapter 9 – Real Memory Organization and Management
Object-Orientated Programming
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Type Systems Terms to learn about types: Related concepts: Type
Chap. 8 :: Subroutines and Control Abstraction
Chap. 8 :: Subroutines and Control Abstraction
Ada – 1983 History’s largest design effort
CMSC 202 Lesson 22 Templates I.
Yikes! Why is my SystemVerilog Testbench So Slooooow?
Miscellaneous C++ Topics
Templates I CMSC 202.
Type Systems Terms to learn about types: Related concepts: Type
Presentation transcript:

1 C++ and Real-Time Programming B.E. Glendenning 1999-Apr-13

2 Outline l Is Object-anything any good? A tale of two papers. l C++ as a better C - the non-controversial bits. l The other bits. l What about performance? l RT/Embedded issues. l Advice.

3 Does OO Sync with How We Think? IEEE Software, May/June 1998 l Case study from two ~50kloc systems (program analysis tools), one written in C, the other C++. Detailed maintenance and development statistics were kept. l Same highly skilled staff, C++ version was “true ab initio OO designed parser” l Initial C++ defect rates 25% higher (although both were good: 2.9/kloc vs. 2.5/kloc). l 60% of all fixes for C took less than 2 hours, only 30% of C++ fixes did »The “time to fix” graph was shifted: all fixes of any complexity took longer in C++ »Overall, 1341 hours in fixing 94 C++ defects, 375 hours to fix 74 C defects

4 Does OO Sync with How We Think? (2) l Other than GUI building, ACM surveys have not shown reuse to be a strong success with C++ l Claim: OO is not a good match for human reasoning - inheritance and polymorphism use long-term memory rather than short-term memory »Encapsulation “at least partially fits how we think” l Possible problems with the paper »Entanglement of C++ & OO »First C++ project? »Relatively small systems »C++ system did more than the C system in the same size?

5 Impact of Ada and Object-Oriented Design in the Flight Dynamics Division at Goddard Space Flight Center SEL l Evaluation of ~20 systems implemented in ADA over ~10 years. l “Use of Ada and OOD in the FDD resulted in »Increased software reuse by 300% »Reduced system cost by 40% »Shortened cycle time by 25% »Reduced error rates by 62%” l Earliest projects had performance problems and development overruns l OO FORTRAN had reuse, but not cost, improvements l Verbatim reuse improves productivity ~5x. l Political failure - workforce lukewarm to Ada l Question: Is Ada better than C++, or is experience the difference?

6 C++ as a Better C l Some changes have already made it into C (void, prototypes) l Declare variables where needed, especially temporary variable »for (int i = 0; i<100; i++) {... l Inline functions, and enumerations, instead of macros const bool

7 Big Features l Object-Oriented features »Classes (encapsulation) –construction/destruction –disciplined access to data »Inheritance (extension) »Polymorphism (run-time selection) l Generic programming »template classes, functions, member-functions, … l Exception handling l Standard library l Missing »Persistence »Garbage collection

8 Performance l Pointing aliasing can slow you down ~30% compared to FORTRAN l Operator overloading can cause severe performance degradation »temporaries creation/destruction, memory allocations, … »inefficient use of registers »Can be overcome by “template metaprogramming” techniques, but requires modern compilers l Good OO practice usually has more function calls »Generally not an issue - the small function calls can be inlined or don’t take much aggregate time l Virtual function vs. function calls is a non-issue »it’s very cheap, and if you are using virtual functions you have to do the if somewhere anyway

9 Performance (2) l Optimizers usually have more trouble with C++ l Exceptions usually have some run-time overhead

10 Real-Time/Embedded issues l Temporaries can cause memory fragmentation l Some care has to be taken to make an object ROMmable. l WRS estimates that only ~5% of projects implemented with VxWorks use C++ »C++ use heavy in telecommunications and banking l C++ programs tend to use more stack and dynamic memory »Many devices will be <<1MB for years to come l Embedded C++ subset has been defined: » »No templates, exceptions, multiple inheritance, RTTI » simple library »Much like C++ circa 1990 l Smart pointers/arrays can greatly reduce incidence of memory leaks and problems

11 Advice l Stick with C unless »you have a lot of complexity to manage; or »you already have experienced C++ developers; or »there is a large code base you know you can reuse l Consider using the embedded C++ subset and style guide l avoid idioms that create temporaries l In any event, be wary of using exceptions in multi- threaded/multi-tasking code