Dec 19, 2014

[C++] relax reading : Why C++ Sails When the Vasa Sank

Scott Meyers
https://www.youtube.com/watch?v=ltCgzYcpFUI

Vasa (ship)
Vasa (or Wasa)[1] is a Swedish warship built 1626–1628.
The ship foundered and sank after sailing about 1,300 m (1,400 yd) into her maiden voyage on 10 August 1628.

Why C++ Sails When the Vasa Sank? :-)

Is C++ heavily armed?
yeah, so why C++ still sails?

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

* Destructors (C++)
RAII => general-purpose Undo
Basis of all resource management
Exception safety (emm, beyond(includes) C++11, destructors is by default noexcept)

* Templates (C++)
Generic programming (boost, STL etc.)
TMP
compile-time dimensional units analysis

* Overloading. (C++)
Generic programming.
Smart pointers
Function objects
Basis for lambdas in C++11

It's a language for library writers!


Pradigm agnosticism :-)
Procedural programming.
Free functions:
Basis of STL (C++)
Naturally models symmetric relationshops (C++)
Facilitates natural type extension (C++)

OOP
including MI. (C++)

Generic programming
Code works for any types (C++)

Functional programming.
Function objects(including closures) (C++)
TMP (ugly, but still~) (C++)

Unsafe programming
Pointers, casts, unchecked arrays, etc.
'Trust the programmer'

Safe programming
STL (C++)

Commitment to Systems Programming
Program speed

Program size.
static (C++, TMP. C, probably MACRO, type unsafe)
dynamic

Data layout
Driver
Comm protocols
Use with legacy code/system

Communicate with outsude entities
Hardware
OSes
Code in other languages

Zero overhead principle:
don'y pay what you don't need (C/C++)

Microcontrollers to supercomputers.
Implementation-defined sizes for e.g int/ptr
No assumptions about I/O capabilities

Hosted and unhosted.
No OS required

C/C++ compilers available almost everywhere.


Legacy code keeps working.
Standarization safequards investments in C++

All in all:
Compat with C
Very general features
Paradigm agnosticism
Commitment to systems programming
Dedication to backwards-compatibility

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.