Comparing the C++ Standard and Boost
Nerval's Lobster writes "The one and only Jeff Cogswell is back with an article exploring an issue important to anyone who works with C++. It's been two years since the ISO C++ committee approved the final draft of the newest C++ standard; now that time has passed, he writes, 'we can go back and look at some issues that have affected the language (indeed, ever since the first international standard in 1998) and compare its final result and product to a popular C++ library called Boost.' A lot of development groups have adopted the use of Boost, and still others are considering whether to embrace it: that makes a discussion (and comparison) of its features worthwhile. 'The Standards Committee took some eight years to fight over what should be in the standard, and the compiler vendors had to wait for all that to get ironed out before they could publish an implementation of the Standard Library,' he writes. 'But meanwhile the actual C++ community was moving forward on its own, building better things such as Boost.'"
Want to use boost? Header only, right? yeah, well, there are so many damn interdependencies it's a mess. And while are some gems in there (the good ones made it to c++11), there's a lot of total garbage. And they seem to go full retard with regards to doing everything in the most c++ way possible.
There, I've said it. It's obscuratist beyond all reason and results in incomprehensible code of the type that any professional programmer should be ashamed of.
what are the odds.
It would be taken over and split up. It's a not a "set of libraries", it's a "set of sets of libraries".
Proof? Show me a reasonable tutorial on Boost (enough so that a proficient C++ programmer will be able to get useful work done using a Boost library of his or her choosing) available for a reasonable price.
instead of verbose vagueness need to have lists of comparisons between standard libraries and boost. is this author practicing to be paid by the word?
I just cannot embrace the mess C++ became anymore. Life is too short to learn C++. Basically I'm using "C with classes" today, without STL, Boost or any of these aberrations.
The article talks a lot about the history of everything, but the "comparison" is a short section at the end that basically says "boost actually exists."
Not as advertised.
BOOST is a great suit of tools ..... that somehow managed to become BLOATED and I'm not talking about features.
Although many of the libraries are technically simplification of common tasks, the implementation is always ridiculously bloated. Take for example the conditional variable and mutex classes .... to do something simple, they added hundreds of lines of completely unnecessary code to them. So instead of being lite and fast, like they are supposed to, they are 3 to 4 times slower than what you can write on your own.
The other part, is the heavy reliance on macros. You have macros calling macros that call macros. And they are not bug free at all. I found 1 macro that generated over 98K of "dynamic" code (can't remember the actual name right now). Seriously, 98K+?? And worst, it had a bug .... and no way to figure out where in the 98K of crap it was crashing.
So in the end, because of the lack of performance and the HUGE increase in binary output size, our project decided against using BOOST ... and only use it as a reference.
Even experienced programmers with no c++ background (for whatever reason) struggle with c++. On one hand, the elegance is quickly recognized. But the other hand curses it's clumsiness when it comes to trivial tasks like string handling, or when 3 out of 5 google queries return 'use boost or this 20-line example', what other languages solve in 1 line.
Personally, i think that is partly the cause why any other language can gain popularity. And while i recognize, and value, the portability aspect, c++ is clearly not the answer to every task. Also, this very portability aspect seems to cut c++ itself in the fingers. If i'm interested in, say, embedded programming, i'd simply expect some standard libraries not to be available. But for 'daily' use on standard pc hardware and major OS'es, i'd like my language to be complete as possible, and not have to include 3 alien libraries for a 20-line program. If iso c++ finally brings that, i'd be delighted, but can't help to wonder why it feels like its 15 years late.
2 cents from a c++ noob and ex-delphi (object pascal) / c# / php programmer
Why are "articles" written by this guy still accepted for slashdot submissions?
"... unzipped the .hpp files span 9000 files and 90MB."
Do you even lift?
These aren't the 'roids you're looking for.
We had decent (not perfect) C++ support. Now we go and fragment the industry by inventing a new standard. Code developed to the 0x11 standard won't work on legacy systems with legacy compilers.
Meanwhile boost and Qt worked around the C++ limitations without introducing any compiler differences. I think that was the right approach. True not all things could be delivered without messing with the compiler, but a good many were.
Now my only problem is that Qt (the leading C++ library aside from stl) and boost are not compatible. Boost has the more permissive license, but it is its own license, and boost additions can be under their own license. The Qt library is now LGPL (or commercial), and as of Qt5, Qt is divided into even smaller modules.
I hope the community does not fork again (C++ vs 0x11) with boost vs Qt. I cannot decide whose library should be adopted. But whatever comes to pass, I hope either Qt adopts boost or boost adopts Qt, to prevent further fracturing of C++ community.
Slashdot's rate-of-post filter: Preventing you from posting too many great ideas at once.
If you wait for another decade to come up with an update to the standard, you'll find even more independent libraries and implementations. People need to solve their problems now, they can't wait for somebody else to decide what to include into a standard. Example: a native string object must exist in a language of 21st century, so must a list, a set and a map.
You can't handle the truth.
But the day I walked away from C++, Boost and MFC (mutha fucking classes) and joined a C# .Net shop was the happiest day of my life. Slam it all you like, but for UI development, Boost and MFC /Win32 is the worst platform to develop on unless you are a clueless sadomasochist that enjoys pain and suffering.
I haven't thought of anything clever to put here, but then again most of you haven't either.
Just ask Phil Greenspun.
It's obvious that both Boost and C++ come mostly from an academic environment. In a sense it's very general, but this makes it sometimes hard to apply to practical problems. For example, try to create a random number from 0 to 1. Any other language has a function for that. Not so C++, here you have to create two objects before you can generate a random number. Which makes it more versatile, but also more cumbersome. Same goes for the reference documentation: mostly incomprehensible because of all the template arguments, and a library is only as useful as it's documentation.
Boost and MFC /Win32
Agreed. Writing GUIs in C++ isn't that much fun, and GUI logic doesn't need the theoretical performance that C++ could give anyway. Just because C++ is not the right tool for every job does not mean that it is intrinsically bad.
Like all pain, suffering is a signal that something isn't right
Has anyone here tried reading the standard? It's unintelligible.
Has anyone here tried reading C++ code? Like the standard, a lot of it is unintelligible. To C++'s credit, this isn't a problem with the language itself, per se. It's a problem with substandard software engineers.
I write C++ professionally. I like C++ because I am adept at expressing myself in it. I can build useful things with it quicker than I could with C. But every once in a while, I'll get reminded that I don't know C++ as well as I thought I did. C++ has a myriad of pitfalls that are difficult to understand until you get first-hand experience being bitten in the ass by them. And often times, when it happens to me, I think to myself, "this is so incredibly fucking stupid."
- I was working with c++ for 15 years
- I breathed it for day and night
- I did it for my living
- I protected it on every forums, LOLing Java and other guys
- happily used STL, because it is rellay great
Then I had to learn and use c# every day, and I realized that c++ is
- unlearnably and unnecessarily complex, requiring expensive experts
- still, painfully error-prone
- missing a standardized toolset for everyday tasks
- except for extremely CPU-bound tasks, utterly uneffective to develop with it
So, according to the "right tool for the right job" principle, if c# would be as free as c++, and the decision between the two would be based on purely on their effectiveness:
- c++ would be pushed back to a very narrow niche, and very few expert would really require it
Sad, but c++ is a dying dinosaur.
Microsoft would be able to kill it within one day, by just letting c# freely available on every platform.
C code doesn't have to be procedural. You can implement classes and objects and what's more, you can actually understand how they work when you do. You can create just about anything you want (not everything, but very near.) You'll know what you are writing. You won't be including incredibly overweight code that bloats your app and slows it down. You can manage memory intelligently, you can construct very maintainable code, and you can be quite concise about it.
What you're running into, I suspect, is programmers that aren't experts in either C or OO. They know how to use the bits of OO that C++ "cans" for them, but if you told them to build such things... C++, like any HLL, has its place holding the hands of mediocre programmers, and also in empowering truly excellent programmers. But C is enormously capable and from my personal experience, it's hugely more maintainable, less verbose, and more to the point than C++ simply by virtue of the fact that the language space is much smaller -- only as large as it actually needs to be, with very few exceptions. A true object can be built in C without any of the cruft or "mommy" limits; it can be highly efficient in terms of both memory used and execution time. It won't end up being megabytes just to get a basic UI going.
The amount of "stuff" a programmer needs to know about a language gets in the way of the amount of "stuff" that same programmer needs to know about programming techniques in general and the specific task(s) at hand.
Every once in a while, I have to write in C++. I'm pretty good at it -- experts in C tend to have a good basis to add C++ concepts on top of. I even enjoy it. But contrary to your experience, I have found that most C++ code I have to deal with from others is very bad from the POV of maintainability, bugs (and they get a lot more obscure) and in being much more verbose (just a typical C++ header file makes that point rather well, without even getting into code.)
The worst thing I run into is the assumption on the part of OS documents that you will be writing in C++; pretty soon, you have to capitulate and get the C++ written, just so you can interface with the bloody system. All of a sudden, you're pulling in huge chunks of code you never heard of and have no interest in, and you have a form of the classic many-megabyte "hello whirled" program. Ugh.
I've fallen off your lawn, and I can't get up.
You can get that same warm feeling by writing good code in C, assuming only you have the skill to do it. Furthermore, when it is useful and appropriate to step outside the paradigms that C++ would force on you, but you can choose to use in C, you can. You'll understand why you did it, what you saved or cost yourself by doing it, and it won't be buried underneath some ridiculous, time-and-space wasting get/set layer, etc.
Not saying C++ is bad. Far from it. But I am saying that C is fully capable of supporting strong, highly correct programming, and that if C++ restrictions (or those of any other language) are the source of your feeling of having "done it" correctly... it's very likely there's more basic programming landscape for you to explore.
I've fallen off your lawn, and I can't get up.
The Boost guys seem to be grinding some sort of axe with respect to the FSF. All over their site are little digs about how awful the GPL is, etc. The benefits of various licenses are open to question, of course, but their little snipes just seem unprofessional.
Also, bjam. If you have to write your own make replacement just to compile your code, you're doing it wrong. Ugh.
C-like-C++ kinda combines the worst of both worlds.
At that point, I think you'd be better off using straight C (which I like a lot and think is the best tool for most jobs), or full C++ (which bugs me, but I admit I like the STL better than C collections).
Bzzzzt. Use of Qt presumes some sort of GUI. Not all applications need a GUI. Why would a loader need Qt? For the puzzled, a loader is /lib/ld.so* and is the key bit of code which manages where your application sits in Virtual Memory, along with the statically bound dynamic libraries. For general application developers, It is something well beyond your capacity to understand, so stick with your burger-flipping.
are you concerned about a future where everyone can assemble a house with prefabricated parts, but only the smallest minority know how to fabricate the parts?
I'm concerned with a future where the parts cartel controls access to parts by adding organizational requirements for use of their parts that discriminate against students, amateurs, home-based businesses, and various forms of lean startup company. In some parts of the software industry, this has already happened *cough*games*cough*.
Bzzzt.
None of QtCore, QtSQL, Qt Network, Qt...need I continue? Only QtGUI presumes a GUI. QtCore is just datatypes, of which they have advanced storage classes and signals and slots (and event loops) and threading.
Slashdot's rate-of-post filter: Preventing you from posting too many great ideas at once.
"Two, the junior programmers (and even the senior ones you know who shouldn’t have been promoted) are less likely to make the same old mistake of writing things like for (i=0; i=length;i++) and then ask you why the code seems to sort of work some of the time, while other times it crashes inside the other function the loop is calling." Well is it really better to write an osbcur function instead of understanding why? Such shortcuts conduced to choose some languages like Java which try to do by itself everything a "junior" programmer don't want to do. And we now have thousands of applications programmed in Java whereas it's absolutely unusefull and which run 1/10th of the expect speed. For example, I want to speak about Androïd where Java is absolutely unusefull because we can't expect any portability from or to other systems and which have been choosed only because of the large number of potential programmers. What a pity! Sorry to have posted a comment a bit out of the subject. Regards, Alain