The Channel logo

@Brian Miller

"C++ started out as a preprocessor hack"

That's a common fallacy. Early C++ implementations by Stroustrup were full compilers whose back-end generated C instead of machine code. Very sensible, given that there were lots of C compilers around which could generate machine code for a wide variety of binary targets, and there was only a single C++ compiler writer.

", and a lot of the "power" and "versatility" of C++ is still in the C preprocessor."

That's not true. The power and versatility of C++ come from the support for OO and generic programming, and the powerful standard library. Preprocessor hacks are rare in most modern C++, and various features of C++ were put in with the deliberate aim of reducing use of the preprocessor to a minimum e.g. templates for functions like min()/max(), constant variables being constant expressions, and inline functions.

I agree that a large part of the popularity of C++ is because of the popularity of C. I think that a major reason for that is that Stroustrup (like K&R) doesn't force his ideas of good style down your throat, instead allowing you to make decisions for yourself based on your own constraints, though the structure of C++ is designed to allow you to express your designs very cleanly.

You do have to learn how though, and that does take a lot of effort. Trying to write C++ using only those skills you've learned while writing in C and similar languages will end up with you producing some very poor C++ code. The key is to understand what problems the various language features were designed to solve. Reading "Effective C++" by Scott Meyers, and "The Design and Evolution of C++" by Stroustrup helps a lot.

Forums

Forgotten password

Opinion

euros_channel_money

Tim Worstall

Time to take a sniff at the coffee, perhaps
joe_tucci_emc_channel

Chris Mellor

Will they have to drag him back like last time?
chain_relationship_channel

Features

cloud_accounting
Playing the SLA long game
channel_teaser_money_top
cloud computing Fight
Applications must work for the cloud to float
Paul Cormier, Red Hat
How a Unix killer crawled from the dot-com bust