C++0x noise, bloat and portability

At first when I saw the upcoming C++0x standard I was delighted, and not that I'm pessimistic, but when thinking of it now I feel somewhat less hopeful.

Mainly because of three reasons:

  1. a lot of boost bloat (which must cause hopeless compile times?),
  2. the syntax seems lengthy (not as Pythonic as I initially might have hoped), and
  3. I'm very interested in portability and other platforms (iPhone, Xbox, Wii, Mac), isn't there are very real risk that the "standard" will take long to get portable enough?

I suppose #3 is less of a risk, lessons learned from templates in the previous decade; however Devil's in the details.

Edit 2 (trying to be less whimsy): Would you say it's safe for a company to transition to C++0x in the first effective year of the standard, or will that be associated with great risk?


Edit: do I (and others like me) have to keep a very close eye on build times, unreadable code and lack of portability and do massive prototyping to ensure that it's safe to move on with the new standard?

Yes. But you have to do all these things with the current standard as well. I don't see that it is getting any worse with C++0x.

C++ build times have always sucked. There's no reason why C++0x should be slower than it is today, though. As always, you only include the headers you need. And each header has not grown noticeably bigger, as far as I can tell.

Of course Concepts was one of the big unknowns here, and it was feared that they would slow down compile-times dramatically. Which was one of the many reasons why they were cut.

C++ easily becomes unreadable if you're not careful. Again, nothing new there. And again, C++0x offers a lot of tools to help minimize this problem. Lambdas aren't quite as concise as in, say, Python or SML, but they're a hell of a lot more readable than the functors we're having to define today.

As for portability, C++ is a minefield already. There are no guarantees given for integer type sizes, nor for string encodings. In both cases, C++0x offers the tools to fix this (with Unicode-specific char types, and integers of a guaranteed fixed size)

The upcoming standard nails down a number of issues that currently hinder portability.

So overall, yes, the issues you mention are real. They exist today, and they will exist in C++0x. But as far as I can see, C++0x lessens the impact of these problems. It won't make them worse.

You're right, it'll take a while for compliant standards to become available on all platforms. But I think it'll be a quicker process than it was with C++98.

All the major compiler vendors seem very keen on C++0x support, which wasn't really the case last time around. (probably because back then, it was mostly a matter of adjusting and fixing the pre-standard features they already implemented, so it was easier to claim that your pre-standard compiler was "sort of almost nearly C++98-compliant".

I think on the whole, the C++ community is much more standard-focused and forward-looking than a decade ago. If you want to sell your compiler, you're going to have to take C++0x seriously.

But there's definitely going to be a period of several years from the standard is released until fully (or mostly) compliant compilers are available.

  1. You pay for only what you use. If you don't need a complex template feature, don't #include the headers it's defined in, and you won't have to deal with it.
  2. Lambda functions should reduce the verbosity of STL algorithms a good bit; and auto variables will help with code like std::map<foo, std::shared_ptr<std::vector<bar> > >::const_iterator...
  3. Yes, it will take a while. Many of the new features are indeed in boost, and if you want portability that's what you should be using for at least a few years after the standard is implemented. Fortunately there are only two compilers that cover those platforms you mentioned: g++ and Microsoft's C++ compiler. Once they get support, it's just a matter of time before the embedded toolchains get rebuilt with the new versions. Unfortunately, possibly a lot of time...

Like most of C++ you will pay for only what you need. Therefore if you don't want the "boost bloat" of useful tracking pointers, thread libraries etc. then you don't need to pay for the compilation.

I'm very sure that portability will be addressed with the design, especially since a lot is based on existing portable code from projects like boost. Both GCC and Microsoft VC have implementations of much of C++ 0x already as you'll see from their respective current prototype versions.

  1. C++ is always going to have hopeless compile times, it's whole philosophy is do things once(i.e. do it at compile time) so you don't have to repeat it at runtime and reduce the performance. And as others have said, don't include a library if you don't need it!
  2. C++ will never be very pythonic because of it's aim of being backwards compatible. The verboseness comes from being an old language that had many things added on as the language evolved. As some others have said, lambdas and auto variables will greatly reduce the verbosity as well
  3. This is a problem with any big changes to a language, but I think it's widely agreed that the changes will make the language a lot easier to use, so it should get adopted quickly.

I would actually consider #3 the biggest risk short term. AFAIK, the standard is introducing new syntax in a couple of areas (lambdas) and changing the meaning of previous words (auto for instance). Code using these features can only be portable if the compiler for every platform you deploy to supports them.

Sure this will happen at some point in time. But adding a new feature to a compiler is no small feat and takes quite a bit of time. I would be afraid that it will take too long for these features to be supported in the main compilers and hence inhibit the ability of a programmer to be an early adopter and portable.

I find that C++0x makes code a lot clearer in many cases.

Build times can be greatly shortened when dealing with heavily templated code, due to variadic templates. boost:: uses a really ugly template overloading scheme to sort of implement "variadic templates" in C++98. This causes compile time to blow through the roof. Link

Range-based for-loops are great as well for readability.

Consider the C++98-ish:

for (std::vector<int>::const_iterator itr = vec.begin(); itr != vec.end(); ++itr)

Can now be written (implemented in G++ 4.6) as:

for (auto elem : vec)

auto keyword reduces syntactic noise as well.

Lambdas are great for use with STL algorithms as well, and makes it more readable when you don't have to separately create C style callback functions or even a whole class.

One of the advantages of standard things is that compilers can take shortcuts. E.g. the boost template circus needed to implement is_X<U> disappears if you can simply hand off to __compiler__is_X<U>. This could easily save 2 orders of magnitude, sometimes 3.

What's the question here? Of course it's going to take years before compilers on esoteric platforms will implement these features. Don't count on being able to use new features until 3, maybe 5 years in the future. 'He who then lives, then worries', as we say in Dutch.

Category:c# Time:2009-08-12 Views:1

Related post

  • Physics toolkit portability 2009-06-11

    Summary: Have you ever made an interface between two -- or better yet even more -- different physics toolkits? For a online game (or at least with network physics)? How did it turn out? Lessons learned? Is it better to rewrite large chunks of code el

  • Why is it difficult to write portable C programs? 2009-08-11

    I want to know, why is it too hard to make a program run in many OSes, like Windows and Linux, without including glue code. They all share the same architecture (x86), so I think it should be simple. Furthermore, C is standardized, so why are impleme

  • Arbitrary-precision random numbers in C: generation for Monte Carlo simulation without atmospheric noise 2010-05-23

    I know that there are other questions similar to this one, however the following question pertains to arbitrary-precision random number generation in C for use in Monte Carlo simulation. How can we generate good quality arbitrary-precision random num

  • Portability libraries/frameworks 2010-12-23

    I have the book "Write Portable Code" which details POSH, an open-source "framework" (mostly just a header) to help with portability of C/C++ code between different platforms and hardware. Since Poshlib hasn't had an update in 5 years now, I was wond

  • portable print and compare pthread_t 2011-01-21

    What I actually need is portable compare and print for *nix pthread identifiers (pthread_t). pthread_equal function exists to compare two thread id's for equality, however it's not possible to compare them with operators < <= >= > (portab

  • fulltext noise words - the logic behind 2011-10-20

    As the title depicts, what is the logic behind implementing noise words in fulltext searches to avoid these words being searched? I mean, what if someone searches "to be or not to be"? No result shown? I'll highly appreciate if someone can tell me th

  • Why do Perlin noise algorithms use lookup tables for random numbers 2012-03-14

    I have been researching noise algorithms for a library I wish to build, and have started with Perlin noise (more accurately Simplex noise, I want to work with arbitrary dimensions, or at least up to 6). Reading Simplex noise demystified, helped, but

  • Real Solutions to the Winsxs bloat. 2013-07-10

    Hello! I'm searching for solutions for reducing the winsxs stuff. First, I'm not a layman so I don't need an umpteenth reiteration, that I shouldn't delete anything because they're backups and variants of dlls. I simply don't need it. I pretty much u

  • Laptop fan noise/buzzing persists at all performance levels 2012-02-11

    Bought 2 days ago, on the first day the fan acted normally but on the second it seems to be experiencing resistance and a loud buzzing noise even on silent, vibrations are felt clearly if the keyboard is touched in the mid far left of the keyboard by

  • unable to install LG portable super multi-drive on windows 8 2012-03-08

    I have downloaded the latest update of software from LG and my surface 2 will not allow it to run. It diverts me to the app store, but there aren't any apps that fit my need. Any help? --------------Solutions------------- Hi, As far as the drive itse

  • Having problems hearing sound when there is background noise (fan across room) on Samsung laptop. 2012-07-16

    Original title: I have all the volumes up on my Samsung laptop (Win 7) and am having problems hearing when there is background noise (fan across room). Guess I just need speakers? but that sucks...... details? this is not a prob when speakers are att

  • Computer keeps running and the fan makes alot of noise. 2012-09-13

    Original Title: my computer keeps running i my computer keeps running and the fan makes alot of noise i am usung vista --------------Solutions------------- Hi alanstoller, Did you make any software or hardware changes on the computer prior to this is

  • The machine makes noises during bootup and will type an endless stream of capital i's in powerpoint 2013-05-26

    Original Title: Help! My Windows 7 pc is infected I need a quick soution. My pc is Hp Paviion dm1 (a laptop. Yesterday, after I started my pc, windows boot manager appeared after BIOS. I have no other os in my notebook. Then I started on windows 7 on

  • Does anyone know how I can stop the noise coming from a second hand gaming PC tower that I'm running Microsoft Office on? 2013-11-01

    I am running Windows XP Pro with 2.00 GB and 1.96 GB available. Unfortunately, my hard drive is once again continually making noise if my PC is on. When I was first given the tower it was dusty and dirty. I cleaned it with a compressed-gas duster acc

  • , delete high pitch alarm , noise from sound system 2014-09-18

    Need help ; loud high pitch squeak ,alarm , siren continuously on with volume . when I turn volume off ,way down ,no more sound RealTek system for windows 7 in Acer Aspire Notebook 7736-6080 been at this for over 24 hrs can't shake it unless I disabl

  • Device not detected, Samsung S2 portable 1TB, 3 flashes on device. 2014-11-15

    when i plug the hard drive into the usb port the blue light on the device comes on then turns off, then multiple sets of 3 flashes. no trecognised on laptop running windows 7. is there a answer cause its doin my head. From the other thread: http://an

  • Toshiba canvio 1 TB portable hard drive doesn't work with windows 8 2015-03-02

    Is the Toshiba Canvio 1 TB potable hard drive compatible with Windows 8? --------------Solutions------------- Hi Michael, Welcome to Microsoft Community and we are happy to assist you on this issue. As per the query description, the Toshiba Canvio 1

  • Can placement new for arrays be used in a portable way? 2008-08-18

    Is it possible to actually make use of placement new in portable code when using it for arrays? It appears that the pointer you get back from new[] is not always the same as the address you pass in (5.3.4, note 12 in the standard seems to confirm tha

  • Portably handle exceptional errors in C++ 2008-09-02

    I'm working on porting a Visual C++ application to GCC (should build on MingW and Linux). The existing code uses __try { ... } __except(1) { ... } blocks in a few places so that almost nothing (short of maybe out of memory type errors?) would make th

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.990 (s). 13 q(s)