Is C++ Just a Better C?

A lot of money and energy was spent in converting or writing new software in C++ during the 80s and 90s. Even nowadays, when the leading commercial language is Java, there is a lot of effort spent in learning and using C++ in several areas where performance is considered to be an important asset.

However, despite all these efforts after 20 years, C++ is not used to its full extent. Some features such as the STL have become really successful and widely accepted by the industry. On the other hand, other features such as checked exceptions and RTTI have been met with little enthusiasm.

It is necessary to understand what these features have in common and why they were not considered to be so useful as their creators supposed them to be. Especially when such features have been introduced more than a decade ago and are still nowhere near full acceptance.

Duplicate Features

One of the problems of the C++ language is that it has, more than once, introduced features that are difficult to use and/or implement. As a general rule, this is a disadvantage of languages designed by a committee. Some features end up becoming part of the standard document, but they have little support in the real world.

For example, a decade ago the designers of C++ though about the possibility of having templates defined in separate translation units from the ones where the templates are used. The intention is good, since templates take a long time to parse and compile.

However, the big problem with separate compilation of templates, provided by the external template keyword, is that it was never implemented by major compilers. The main justification is that it is a complicated feature to implement. Also, it would require modifications to the current way programmers declare and templates.

The result is that external templates are now viewed as a dead feature, something that might be useful but is not available in any of the major compilers.

Coding Standards

A related problem for C++ is that nobody uses all its features. Due to the fact that there are competing implementation for the same concept (for example, two IO libraries — the old C-base library and a stream object-based library), C++ users have to decide which option to use. This may be done in a case-by-case basis, or even by the use of a coding style.

Big companies such as Google have decide to rule out most of the advanced features found in newer versions of C++. These features include exceptions, multiple inheritance, for example. What this means in practice is that C++ is being used just as a better C, without many of the features that its creators though would be useful.

On close inspection, it seams that C++ is mostly a language designed at two levels: the first level, incorporating the ideas of the day, which change every few years with the desires of researchers. Examples include checked exceptions and run time type information. In the process, lots of incompatible ways of writing the same code are introduced. For example, are you going to use return values or exceptions? Streams or standard buffered I/O? Both have its advantages and disadvantages, so you better know what they are.

In the other hand, there is also a second level dictated by developers, as they decide which subset of the language to use. Since it is not possible to use all the provided features at the same time, one has to selectively use C++ to create new software projects. One of the ways this is done is by adopting a styling convention. In this process, developers rule out a set of features that believe are not productive.

Still, another result of this evolutionary process is that there are some features that people don’t like, but that are not easy to substitute. For example, templates are a pain to create and even to use. However most developers use them because it is the only way to do some things in C++. Somebody else could create better container classes, but that would become a huge problem for compatibility with existing libraries.

Conclusion

C++ is an evolving language. As a consequence many of its features are not well developed. Other features have been rejected by the community as too complex or unsafe to use.

A large part of being a good C++ developer is understanding what are the good and bad parts of the language, and how to take advantage of them when necessary.

Further Reading

The Design and Evolution of C++, by Bjarne Stroustrup is a great book that explain the reasoning for most of the features in C++. It is a must read if you want to understand the initial phase of evolution of the language.

Similar Posts:

Similar Posts

18 Comments

  1. C++ is powerful language. Yes, I too agree, its real power comes with understanding the language features and design principles. We can see few of the applications that were developed in C++ on the following link

    http://www2.research.att.com/~bs/applications.html

    There are many other books on understanding the language features (like those by Mayers, Herb Shutter, Andrei Modern C++, C++ Coding Standards, etc…)

  2. The problem is that C++ is _not_ a better C. It’s actually a worse C.

    C is a portable assembly language that provides minimal abstraction between you and what the machine is actually doing. Its purpose is to not get in the way between the programmer and the hardware.

    Scripting Languages like Python/Ruby/PHP abstract away everything they can: memory management, type conversions, even your entire build system (no compile stage). They build objects on top of dictionaries instead of structures, meaning you can add or remove things on the fly. It’s a completely different way of programming, where you program _to_ the abstractions, because they’re opaque and most of the implementation details become completely irrelevant. (Is the dictionary mentined above implemented as a tree or a hash table? Answer: it doesn’t matter, it just works.)

    C++ is an uncomfortable middle ground: its abstractions leak implementation details in subtle ways, ALL THE TIME. It includes the whole of C (static memory management, static typing requiring templates to resolve at compile time, pointers), but then tries to implement thick abstraction layers on top of pointers and memcpy() and stack vs heap storage distinctions and target-specific word size and alignment requirements… Its abstractions regularly fail to hide implementation details, but the _existence_ of the “abstraction” gives complexity somewhere to hide and breed… until it doesn’t work and you have to figure out why. (A lot of C++ programmers have put _decades_ into “figuring out why”, and are sometimes highly defensive of this sunk intellectual capital to a degree bordering on stockholm syndrome.)

    C is good at what it does. Scripting languages are good at what they do. C++ is big and complicated and a great way to gain employment, just like cobol was.

  3. C++ is definitely is better C. The two good reasons not to use C++ instead of C for a new project are 1) portability 2) familiarity with C.

    C is a great language but suffers from several historic flaws: Weak type safety, reliance on macros, lack of uniform resource management.

    C++ partially fixes those defects with the following features: new style casts and const safety, templates, support for RAII.

    C++ has its share of horrible features (exception specification comes to mind) but C99 recently introduced highly questionable constructs that do not fit well in the language, for instance VLAs and complex numbers, whereas C++ is powerful enough to support them as mere libraries.

    Because C is the language of choice for someone does not mean it is the same for everyone. There are domains which require both performance and high-level constructs (e.g. video games and scientific computing) and C++ is currently the best fit for those.

  4. @Julien, yes, C++ has a lot of features that are helpful. It is sad, however, that it is so confusing to use in general.

  5. @Rob, C++ has a lot of problems, but sometimes it might be easier to use for non-critical applications. I wouldn’t create an OS in C++, but a desktop application may benefit from it.

  6. What is this about the “newer verions of c++” and multiple inheritance? C++ has always, from way back in cfront days, had multiple inheritance. If a company throws that out, especially virtual function only mixin class inheritance, then they have thrown out an important bit of what little expressive power the language has. I imagine such “safe c++” shops also toss out operator overloading as well.

  7. It is not a secret that multiple inheritance is avoided by lots of users and companies. In most cases it is only allowed when necessary to implement interface-style classes that are pure virtual, almost the same way as Java does.

  8. Erlebe virtuellen Social Casino-Flair auf höchstem Niveau
    – und das bei genügend Twists sogar kostenlos!
    Aufgrund unserer vielen Aktionen und der virtuellen Währung, den Twists, bist
    du außerdem in der Lage, so manchen Gaming-Moment gratis zu genießen. Du
    kannst außerdem an so mancher Abstimmung und ähnlichen Aktionen via
    Kommentarfunktion teilnehmen oder einfach
    den spannenden Content, wie etwa Videos mit aufregenden Social Slot-Teasern genießen. Dreh es und lass dich überraschen, wie viele
    Twists du kostenlos gewonnen hast.
    Wenn es einen neuen Online-Slot gibt, den Sie kostenlos spielen möchten, können Sie das hier tun, sobald er veröffentlicht
    wird. Spiele also coole Spiele online und kostenlos auf Spielaffe.deund entdecke jeden Tag neue Trendspiele oder bewährte
    Spiele-Klassiker fürdich. Hier finden sichauch zahlreiche Puzzle, Mahjong-Spiele und Management-Klassiker wie Big Farmoder My Free Zoo, in denen du mal eine
    erfolgreiche Farm und mal einenblühenden Zoo erbaust und auch viele andere Aufbauspiele sowie
    Minecraft.Wenn du ein Fan von Multiplayer-Spielen und besonders Browsergames bist,stellt Spielaffe dir auch hier eine große Auswahl an tollen Games zurVerfügung.
    Und falls du einfach mal nur zu zweit spielenwillst, bietet dir die Feuer und Wasser-Reihe oder ein anderes
    Spiel fürzwei Spieler jede Menge kurzweilige Unterhaltung für zwischendurch.
    Viele io Games lassen dich zudem mit Spielern aus aller Weltgemeinsam online spielen.
    Wenn Sie online spielen, stoßen Sie immer auf Spiele von Branchenriesen wie
    IGT und Novomatic. Behalten Sie eine Uhr oder
    einen Alarm im Auge, um darauf zu achten, wie viel Zeit
    Sie online spielen. Auch wenn Sie kostenlos spielen,
    verbringen Sie nicht Stunden damit, Verlusten oder großen Preisen nachzujagen. Dann besuchen Sie unseren neuen Online-Slots-Bereich, um
    kostenlos zu spielen. Sie können auch die neuesten Video-Spielautomaten kostenlos spielen.

    References:
    https://online-spielhallen.de/500-casino-bewertung-ein-tiefer-einblick-fur-spieler/

  9. Bei den besten Anbietern warten zusätzlich zum Bonus noch weitere
    Extras wie Gewinnspiele, Cashbacks oder Reload-Boni.

    + Gratis-Freispiele für die Registrierung Bei der Online Spielothek erwartet
    euch eine Top Auswahl an Slots vieler beliebter Hersteller sowie hohe Neukundenboni und umsatzfreie
    Freispiele. Swiftspiele bietet außerdem viele Zahlungsmethoden an und wartet mit einem sehr guten Bonus auf.
    BingBong war eines der ersten deutschen Online
    Casinos und Spielotheken, das eine offizielle Glücksspiellizenz
    nach neuem Recht erhalten hat.
    Er ist bei Online Spielern bekannt für viele ausgeschüttete Millionengewinne.
    Auch diese findet ihr in fast jedem Automaten Casino und
    sind auch im Online Casino ohne Spielpause spielbar.
    Ich zeige euch, wo ihr am meisten Spaß haben und gleichzeitig groß gewinnen könnt, wenn
    ihr in Online Casinos Echtgeld einzahlt. Die kleinsten Einsätze liegen bei den Spielautomaten online häufig zwischen 0,01€ bis 0,10€.

    Für die Vollständigkeit findet ihr in dieser Liste der von mir getesteten Automatenspiele trotzdem noch die nicht
    mehr verfügbaren bekannten Titel neben den reinen Online Slots.
    An dieser Stelle möchte ich euch die besten Online Automatenspiele Casinos nach Kategorie vorstellen. Slotpark ist eine kostenlose Online-Glücksspiel-Plattform,
    die ausschließlich Unterhaltungszwecken dient. Unsere kostenlosen Slots sind auf
    allen aktuellen Betriebssystemen, Browsern und Mobilgeräten voll spielbar.
    Die bequemste und einfachste Methode, deinen neuen Lieblings-Slot zu finden – hier auf Slotpark!

    References:
    https://online-spielhallen.de/hit-spin-casino-erfahrungen-ein-umfassender-uberblick/

  10. Interessanterweise fehlen die Spiele von Evolution Gaming und Ezugi,
    die bei allen anderen Casinos der Gruppe zu finden sind. Das Spielangebot bei Rolletto Casino umfasst eine
    Vielzahl von Videoslots, Jackpot Slots, Drop and Wins,
    Megaways und Bonus Buy Automaten. Die Mindesteinzahlung
    und Mindestauszahlung betragen jeweils 20€, wobei es je nach
    gewähltem Zahlungsanbieter möglicherweise Unterschiede geben kann.

    Interessanterweise bietet das Casino auch die Möglichkeit, Bitcoin über die Kasse zu kaufen. Das Rolletto
    Casino ist Krypto-Freundlich und bietet ausserdem eine Menge
    Möglichkeiten über Fiat einzuzahlen. Der eSport Bonus von Rolletto Casino beläuft sich auf 100%
    bis zu 500€ und wird aktiviert, sobald du eine Mindesteinzahlung von 20€ vornimmst.

    Rolletto Casino bietet für In-Play, Pre-Match und Virtual eine Cashout-Funktion,
    die es dir ermöglicht, deinen Wettschein auszuzahlen, bevor das Spiel vorbei ist.
    Um bei Rolletto Casino den Sportwetten Bonus von 150% bis zu 1.500€ freizugeben, musst du eine Mindesteinzahlung von 20€ tätigen.

    References:
    https://online-spielhallen.de/avantgarde-casino-mobile-app-dein-mobiles-spielerlebnis/

  11. Streams load quickly, table layouts are clearly organised, and navigation between games is seamless
    on both desktop and mobile. This mix of entertainment and flexibility is what makes
    Australian live dealer casinos stand out.
    Below, we give you our well-researched recommendations for top
    live dealer sites in Australia based on trust and safety,
    bonuses, payment options, and software providers. With professional dealers, crystal-clear streams,
    and interactive features like live chat, they offer an immersive alternative
    to standard RNG games. Wilna van Wyk is an online
    casino enthusiast with over a decade of experience working with some of
    the world’s biggest gambling affiliates, including Thunderstruck Media and OneTwenty Group.

    Here’s where SkyCrown really tries to shine, and honestly, they do a pretty
    decent job. Nothing kills the mood like waiting 30 seconds for a slot machine to load when you’re
    ready to play. The real question is whether quantity translates to
    quality, and I’ll get into that in the next section. SkyCrown Casino launched relatively recently, but they’ve managed to create quite a buzz in the online
    gambling community. Check our promotions page regularly to stay updated on the
    latest offers.
    Clearly a fake page trying to imitate the real
    casino. Don’t miss the chance to claim your welcome
    bonus and start playing slots today! It has excellent encryption protocols to protect your user
    data, providing an environment that feels reliable and
    safe for all its players. Payments are processed quickly and efficiently,
    making sure players receive their winnings without delay. ? Banking &
    Withdrawals – Safe & Quick Transactions Depositing and withdrawing funds at Skycrown online casino is fast and secure.

  12. Deposits are credited instantly, allowing immediate gameplay.
    This mandatory step helps combat money laundering and underage
    gambling. The procedure prevents unauthorized access to gaming accounts and blocks attempts at
    fraudulent activity. Document verification may be requested
    before the first withdrawal to prevent unauthorized access and
    ensure compliance with gambling regulations.
    The account creation process at Sky crown casino eliminates unnecessary complications.
    The interface successfully balances aesthetic considerations with ease of
    use that appeals to both newcomers and experienced gamblers.

    Reliable casinos operating in Australia are usually regulated by respected authorities such as
    Curaçao eGaming or Malta Gaming Authority. Picking the wrong one can mean slow payouts, unclear bonus rules,
    or even unsafe banking. SkyCrown ticks all these boxes, making it
    a convenient and trustworthy option for real-money play.

    From licences and payment methods to supported currencies and withdrawal speeds, this section covers everything at a glance.

    No matter your gaming preference, SkyCrown Casino Online has something to
    thrill and entertain. SkyCrown prides itself on offering a diverse collection of games to suit every preference.
    Skycrown functions under a license granted by the Curacao jurisdiction, a reputable and recognized authority within the digital gaming sector.

    References:
    https://blackcoin.co/thrill-awaits-at-lucky-ones-casino/

  13. Our goal is to ensure every player has a safe and enjoyable
    experience. We are committed to responsible gaming and offer tools such as deposit and time limits, loss tracking, self-exclusion, and direct
    links to professional help. Every game is optimized for mobile and desktop play, ensuring a flawless experience across all devices.

    Our interface and customer service are built to accommodate a wide range of players across Australia and beyond.
    We only work with trusted providers like Evolution,
    Pragmatic Play, Red Tiger, NetEnt, and Microgaming. All
    RNG-based games are independently audited to guarantee fairness and transparency.
    The Star Gold Coast Casino Online operates under a reputable international gaming license and complies with Australian and global regulatory standards.

    References:
    https://blackcoin.co/57_instant-play-casinos-2022_rewrite_1/

  14. Roulette offers another layer of excitement, with players guessing
    where the ball will land among the spinning wheel’s numbers and colors.
    The pokies are also designed with varying pay line options, allowing for
    numerous strategies and multiple chances to win big.

    From nostalgic classic reels that evoke the feel of traditional casinos to state-of-the-art video pokies with cutting-edge graphics and themes,
    the selection is vast.
    Two casinos in northern Australia found at high risk of being used
    for money laundering have been ordered to undertake an external audit.
    The operators of the casinos both say they take their obligations
    seriously and will co-operate with the authorities.
    Two casinos in Townsville and Darwin will undertake external audits of their anti-money laundering measures.
    In January, Echo said Jupiters Townsville had limited
    expansion opportunities and offloading the casino
    would allow the company to focus on its Sydney, Brisbane
    and Gold Coast properties. “[Jupiters Townsville] is the worst-performing casino in Australia by a long way,” he said.

    References:
    https://blackcoin.co/roulette/

  15. In July 2020, the Federal Acquisition Regulation Council published a Federal Register notice prohibiting all federal
    government contractors from selling Huawei hardware to the federal government and preventing federal contractors
    from using Huawei hardware. However, on 29 June 2019 at the G20 summit,
    the US President made statements implicating plans to ease the restrictions on US companies doing
    business with Huawei. Various US-based companies immediately froze their business with Huawei to comply with the regulation.
    The NSA was concerned that Huawei’s infrastructure could provide China
    with signals intelligence capabilities. In addition, the company’s central email archive was accessed,
    including messages from founder Ren Zhengfei and chairwoman Sun Yafang.
    In 2014, Der Spiegel and The New York Times reported that, according to global surveillance disclosures, the National
    Security Agency (NSA) infiltrated Huawei’s computer network
    in 2009. Huawei’s Chief Financial Officer, Meng Wanzhou, whose father founded the company, was previously
    charged in the case and detained in Canada for nearly
    three years before the charges against her were
    dropped in 2022. The case charges Huawei with using racketeering
    to grow its business, stealing trade secrets from U.S.
    companies, and committing bank fraud related to Iran.
    On 8 October 2023, former MI6 spy Aimen Dean posted on X that Israel’s failure to detect the Hamas-led attack on Israel was due partly to its militants use of Huawei phones, tablets and laptops, elaborating that US tech companies barring of Huawei had forced it to develop
    its own systems that were not easy to hack except by China.

    References:
    https://blackcoin.co/casino-crypto-first-online-casino-review/

  16. For players who like having everything in one place — pokies, live tables, bonuses, and reliable withdrawals
    — SkyCrown delivers a rounded experience that’s hard to overlook.
    Skycrown Casino is a leading online gaming destination for Australian players, offering a massive selection of over 6,000 games—including pokies, table games,
    live casino, blackjack, roulette, and progressive jackpots.
    The online casino scene in Australia is growing fast, with countless sites offering pokies,
    bonuses, and big jackpots.
    24/7 confidential counselling and chat support If gambling stops being fun and starts to
    feel like a problem, reach out for help immediately. If you find yourself chasing losses, playing
    longer than you planned, or spending more than you can afford, it’s time to
    step back. Online casinos are designed for fun, and while winning is
    exciting, it’s never guaranteed.
    Skycrown Casino provides players in Australia with fast and secure ways
    to deposit and withdraw funds. First-time players receive 50 free spins just for completing installation.
    Downloading casino games directly to Android
    phones beats browser play every time. This tiered bonus system gives players increasingly valuable rewards as they continue playing.
    Skycrown maintains competitive wagering requirements that give players a fair chance to convert
    bonus funds into withdrawable winnings. The loyalty program rewards consistent play
    with points that convert to real bonus funds or free spins.

    References:
    https://blackcoin.co/basic-draw-poker-rule/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.