Looking at Effective C++ - page 2
LinuxPlanet: "Modern" computing platforms like Java and .NET are based on managed environments with garbage collection and extensive collections of standard library functionality. C++ isn't. Why would developers choose C++ for software systems today?
Meyers: This is a question that I posed to one of the C++ newsgroups recently. The discussion ran to nearly 250 messages from over 100 different people, but a few reasons came up repeatedly:
- C++ is a multiparadigm programming language, offering support for procedural programming, object-oriented programming, generic programming, template metaprogramming, etc. These paradigms can be freely mixed, so developers are free to choose the approach to a problem they find most natural. No other mainstream language can make that claim. Interestingly, I mention this in Item 1 of the new edition of my book, because recognizing that C++ supports multiple styles of programming is essential to making effective use of it.
- C++ offers programmers control over almost everything, so when they need to touch the hardware, interface with other languages, control the details of dynamic memory allocation, etc., they can do it. Furthermore, when it comes to flat-out performance, well-written C++ still usually beats well-written software in other languages--often by a substantial margin.
- C++ runs almost everywhere, from the smallest embedded systems to the largest computing clusters. Java may be able to make a similar claim, but none of the .NET languages (e.g., C#) can, at least not yet.
- C++ is already very widely used, so in many cases, continuing to use it is the most straightforward way to extend an existing system.
- C++ isn't controlled by any single corporate interest (such as Sun in the case of Java or Microsoft in the case of C#).
LP: For programmers migrating from languages such as Java and C#, you suggest C++ can be a bit of a challenge initially. What do you think is the biggest hurdle for those programmers to overcome?
Meyers: One of the most challenging aspects of moving from one language to another is overcoming false assumptions. It's hard to be on the lookout for trouble if you don't realize that it's possible. For example, C++ objects can sometimes go uninitialized, but, as far as I know, that's impossible in Java or C#. C++ has a number of things that lead to undefined behavior, again, something that can't exist in Java or C#. C++ objects can have multiple addresses, which isn't possible in Java or C#. In the third edition of Effective C++, I mention these things and several others, because it's important for developers from other languages to understand when the fundamental behavior of the language is other than what they are likely to expect. Perhaps that's the biggest hurdle for such developers: becoming aware of subtle, but fundamental, differences in behavior in C++ compared to the language they've been using.
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: GNOME 3.12 and New Betas for Ubuntu 14.04 and OpenMandriva Lx 2014.0
- 2Linux Top 3: Linus Lashes out, Linux 3.14 Gets PIE and Ubuntu One is Done.
- 3Linux Top 3: Ubuntu 14.04, Debian Gives Squeeze More Life and Red Hat Goes Atomic
- 4Linux Top 3: CoreOS, Oracle Enterprise Linux 7 and Ubuntu 14.10
- 5Linux Top 3: Debian Gives Up on Upstart, Ubuntu and Linux Kernel Updates