Is Boost considered harmful?

Answers to C ++ questions contain the answer:

"You should use boost: :( insert your favorite smart pointer here) or better yet: :( favorite mega-complex boost type here)"

I am not at all convinced that this makes any kind of endorsement to those who, in general, are an obvious C ++ newbie. My reasons are as follows:

  • Using smart pointers without realizing that a hood is happening will lead to a generation of C ++ programmers who lack some basic programming skills. To a large extent, this seems to have happened in the Java field already.

  • Determining the type of smart pointer usage is highly dependent on the problem domain. This is almost always missing from the questions posted here, so just “using a shared pointer” is likely to be at least useless and possibly completely wrong.

  • Boost is not yet part of the C ++ standard and may not be available in a particular platform - the questionnaire uses. Installation is a bit (I just did it with Jam ) and if all you want is a few smart pointers.

  • If you write FOSS code , you do not want the code to be highly dependent on external libraries, which, again, your users may not have. I was put off using the FOSS code on a number of occasions simply because of the Byzantine complexity of the dependency between libraries.

In conclusion, I am not saying that I do not recommend Boost, but we must be more careful when doing this.

+49
c ++ boost
Feb 20 '09 at 11:23
source share
19 answers

A few points:

  • Using something without understanding is considered harmful. But in the end, only the ignorant technology user (and his manager) burned out.
  • You do not need to set boost to get smart pointers - they are only for headers. And the installation itself is quite simple, in the simplest approach they simply type one or two teams.
  • Many Boost libraries and solutions are present in TR1 or will be present in C ++ 0x
  • You will always depend on external libraries ... Try to choose one that has a bright future in terms of service and support.
  • If you do not want to deploy your own solution, which will have some advantages and disadvantages.
+90
Feb 20 '09 at 11:31
source share

C ++ is not a convenient language for beginners. With an apology to Scott Meyers, the newbie does not learn only one language with C ++, but four:

  • Part C
  • Object oriented parts: classes, inheritance, polymorphism, etc.
  • STL: containers, iterators, algorithms
  • Templates and metaprogramming

I would say that if a beginner is already climbing this mountain, from the very beginning they should point to the more “modern” aspects of C ++. Otherwise, the beginner will recognize C-ish C ++ with regular pointers, resource leaks, etc. They find themselves in the world of pain, and then discover Boost and other libraries as a way to stop the pain.

This is a complex picture, no matter what, so why not point them in a direction that has a positive return for the embedded mental good?

Regarding dependencies, a lot of Boost only has a title. And a liberal Boost license should allow its inclusion in almost any project.

+62
Feb 20 '09 at 13:20
source share

Do you know how the compiler works? Do you know how the OS works? Do you know how the processor works? Do you know how electronics work? Do you know how electricity works?

At some point you are using a black box, the question is "is my ignorance problematic for what I am doing now?"

If you have a taste for knowledge, this is a great thing - and I think this is a plus when interviewing engineers, but do not forget about completing your work: create systems that solve problems.

+40
Feb 20 '09 at 12:48
source share

I do not agree. No one would suggest you diving into smart pointers without a full understanding of what is happening behind the scenes, but wisely used them to remove a number of common mistakes. Moreover, Boost is a high-quality production code from which a C ++ novice can learn a lot in terms of design and implementation. This is also not very difficult, and you can select the bits you need.

+25
Feb 20 '09 at 11:30
source share
  • It’s impossible to understand everything all the time. Therefore, take the floor of many professional C ++ developers for the fact that many parts of the enhancement are really useful in your day-to-day development.
  • The inclusion of a fairly large boost in C ++ 0X is evidence that even the team that controls the evolution of the language thinks that boosting is a good thing (tm)
  • C ++ is a weird, hard language. It is relatively easy to learn compared to how incredibly difficult to master. There are some really secret things you can handle. Boost :: mpl is building some of these cryptic things. I like the promotion, but every time I see that someone from my organization uses boost :: mpl. Reason: even quite experienced C ++ developers cannot wrap their heads around how it works, and the code it uses often reflects this (it ends up with someone hitting the code until it works). This is not good, so I partially agree that some parts of boost should not be used without caution (boost :: spirit is another example).
  • The C ++ standard is also weird. Most common compilers do not implement the entire existing standard (for example, exporting templates). This is just a guide to what to expect.
  • If your developer does not have a reasonable solution, which smart pointer to use in a specific situation, perhaps they should not mess around in this part of the code without a guide.
  • There are always external libraries starting at runtime. A big boost is just the title, so it does not introduce new external dependencies.
+21
Feb 20 '09 at 12:47
source share

Honestly, for beginners, I think that the promotion is not so well suited. I think newcomers have a better understanding of how the basics work before promoting the product chain using higher-level tools / libraries such as boost or even STL. At the initial stage, this is not about performance, but about understanding. I think that knowing how pointers work, such as being able to manually create a linked list or sort, is part of the basics every programmer needs to learn.

+15
Feb 20 '09 at 12:11
source share

I totally agree with you. That is why I will first explain to them how this should be done (that is, when you recommend boost :: variant, I will explain that they should use a discriminatory union as a whole. And I try not to talk about it simply "magic boost", but show how they basically implemented it.When I recommend boost :: shared_ptr, I will explain that they will need to use a pointer, but it is better to use a smart pointer that has common property semantics.). I try not to say just “use boost::xxx ” when I see that the questionnaire is new. This is a language that is not as easy to use as some scripting language. You need to understand the material that uses, because the language does not protect the programmer from bad things.

Of course, beginners, of course, cannot understand everything from the very beginning. But they should understand that their acceleration library decides and how it basically does it.

You cannot compare this with learning processors or assembly language. Similarly, it is not important to know what the null pointer bit pattern looks like. Knowing these issues is not relevant to C ++ programming. But pointers, an array, or any other basic things in C ++ are not. Do not learn them before using [boost|std]::shared_ptr or [boost|std]::array successfully. This is what you need to understand first to use accelerated utilities, in my opinion. This is not about the details, but about how to manually implement the pimpl idiom using the source pointers - this is not what I am doing. But the fact is that you first need to know the basic things about pointers or other parts that the acceleration library helps with (for example, for pointers, what they are for and what they are good for). Just take a look at the shared_ptr manual and try to get it without knowing about pointers. It's impossible.

And it’s important to always point to the appropriate acceleration guide. High quality acceleration guides.

+10
Feb 20 '09 at 12:48
source share

I think boost is a great library. I like it. My favorite library is boost :: bind and boost :: function, which make function pointers more flexible and easier to use. It fits perfectly into different frames and keeps the code in order.

I also use different Boost classes. For example, I use boost :: graph to create graph classes, and I use boost :: filesystem to work with files inside directories.

However, the gain is very complex. You must be an experienced programmer to know its value. In addition, you need to have at least some C ++ experience to understand how Boost works and the implications of using Boost here or there.

Therefore, I highly recommend watching Boost for experienced programmers, especially if they are trying to reinvent the wheel (again). In fact, this may be what he says about the tin: enhancing your goal.

However, if you feel that the person asking the question is a beginner and is trying to understand (for example) the memory allocation, telling him to try to raise smart pointers, this is a very bad idea. This is not at all useful. The benefits of smart pointer classes, etc. They can be understood only when a person has experienced how standard methods for allocating memory work.

To complete, Boost is not like learning to drive a car with an automatic transmission. He likes to learn to ride a Formula 1 racing car.

+9
Feb 20 '09 at 11:38
source share

The consensus among almost all the answers is that the upgrade is very valuable for experienced developers and for complex, real world C ++ software. I totally agree.

I also think that a promotion can be very valuable for beginners. Isn't it easier to use lexical_cast than to use ostringstream? Or use BOOST_FOREACH instead of iterator syntax? The big problem is the lack of good documentation to enhance, especially for beginners. We need a book that tells how to start with boost, which libraries are simple libraries that simplify tasks, and which libraries are more complex. Using these libraries along with good documentation, IMO will simplify C ++ learning.

+7
Feb 20 '09 at 12:43
source share

I do not agree. Of course, you will always know more about the inner workings of everything when you code it from scratch than when using third-party libraries. But time and money are limited, and using good third-party libraries like boost is a very good way to save your resources.

+5
Feb 20 '09 at 11:40
source share

I think you mix a lot of different problems, not all of them are related to Boost:

First, should programmers (or C ++ novices) be encouraged to use libraries, idioms, paradigms, languages, or language functions that they don’t understand?

  • No, of course not. Every programmer should understand the tools that they use, especially in C ++. However, I do not see many questions here about where people are encouraged not to understand the code that they use. When people say they want to make X in C ++, I think he says that “Boost has an implementation of X that works, which is more than a homebrew solution, and use that.”

Of course, if the question is “how does X work,” the question cannot be answered “use Boost implementation”. But I really don't see the problem in the Boost recommendation for the old questions.

I also do not see how you can use Boost without understanding what is happening under the hood. C ++, with or without Boost, is not Java. Using Boost in no way protects you from the complexities of the language. You still have to worry about copy constructors, pointer arithmetic, templates, and everything else that could explode in your face.

This is not like what happened in Java. They developed a language that removed all the subtleties. Boost does not. On the contrary, he developed new idioms and methods in general programming. Using Boost is not always easy.

On the availability of Boost, I think this is not a problem. It is available on the platforms used in the vast majority of issues, and if they cannot use Boost, the offer is still not harmful, just useless.

In addition, most Boost libraries are header-only and do not require installation of everything. If you only want smart pointers, just include those headers and nothing else.

About FOSS, you have a point in some cases. But I would say that this is a problem for less universal libraries that users do not have. But Boost is extremely common, and if people don’t have it, they should get it, because it applies to almost all problem domains. And, of course, the license is compatible with any FOSS project that you would like to mention. I would rather work on an OSS project that used Boost for heavy lifting than one that invented its own (buggy and proprietary) wheels with steep learning curves that could have been avoided.

So yes, in some cases the Boost recommendation is useless. But I do not see how it can be harmful.

In any case, I don’t see how it can be even half as harmful as teaching beginners to roll on their own. In C ++, this is a recipe for disaster. This is the only reason C ++ still has a reputation for error prone and buggy software. Because for too long people write everything from scratch themselves, not trusting the standard library, not trusting third-party code, not trusting everything that was not legal in C.

+5
Mar 06 '09 at 15:14
source share

We should encourage the use of standard canned libraries (and Boost is almost standard as far as they get) when possible.

Some people seem to think that newcomers should first learn the C-side of C ++, and then introduce it to higher-level material later. However, people tend to work the way they are trained, so we'll see a lot of production code written with poorly managed source pointers (well-managed source pointers are sometimes terribly difficult), arrays (and the inevitable confusion between deleting and deleting [] ), and so on. I worked with such code. I do not want to do it again than I should.

Beginners with how you want them to write code. This means that they first study the containers and STL algorithms and some Boost libraries, so the first thing they think about when a group of things is needed is the vector <>. Then teach them lower-level designs so that they know about them (or where to look for them) when they run into them, or in very rare cases when they need micro-optimization.

Basically, there are two types of programmers: coders who should learn languages ​​the way they should write them, and an enthusiast who will study low-level material, including the principles of operating systems, C, assembler code, and so on. Both of these will serve well as learning the language they are going to use at the front, while only enthusiasts will be well served by learning some arbitrary levels of basics.

+5
Mar 06 '09 at 15:30
source share

I am not at all convinced that this makes any kind of endorsement to those who, in general, are an obvious C ++ newbie ....

  • Using smart pointers without understanding what is happening under the hood will lead to the creation of a generation of C ++ programmers who lack some basic programming skills.

Are we telling novice programmers that they need to learn assembly language before they read modern programming languages? They clearly do not know what is happening under the hood otherwise.

Should "Hello World" enable I / O subsystem implementation?

Personally, I learned how to create objects before learning to write classes. I think I learned how to use STL vectors before I recognized C-style arrays. I think this is the right approach: "here, how to refer to several almost identical variables using std::vector , later I will show you what is covered under the rug through C-style arrays and new[] and delete[] ."

+4
Feb 20 '09 at 20:56
source share

I see your point of view, but understanding something does not mean that you need to rewrite everything from scratch.

They are not "standard", but they are standard, as the library can get.

It is true that their deployment can be painful (but not all sub-tables require compilation); on the other hand, they have no other dependencies, so I would not worry too much about this part.

+3
Feb 20 '09 at 11:32
source share

I would agree with the point of view of smart pointers. I am starting with C ++, and by asking a simple question about pointer syntax, one of the answers suggested smart pointers. I know that I am not ready to upgrade (I am also not very ready for STL), so in most cases I run away from this offer.

+1
Feb 20 '09 at 12:32
source share

I agree with you, high-level libraries hide things from you. In the short term, this may be a good idea, but in the end, a beginner will have serious gaps in understanding the language.

It’s easy for us, not beginners, to say “just use this library” because we have gone down this long difficult path of learning something difficult, and naturally we want to save someone else from trouble with the same.

Beginners SHOULD struggle to translate their own low-level solutions to problems. And then, when they better understand how their own solution works, they can use a third-party solution, confident that they have an idea of ​​what is happening under the hood. They will use this library better!

I think this is a broader question than just about Boost. I completely regret collecting VB as my first language. If I were just starting out with an ugly one, it’s hard to learn c, I would be much ahead of time where I am now.

+1
Mar 06 '09 at 15:08
source share

Cloud and dynamic ownership of resources is a common basic setting and increase efficiency. It is very well recommended. I use them a lot and they work great.

+1
May 09 '09 at 23:58
source share

Boost is a great library. I really hope that it will expand in breadth and acceptance. Use it, expand and promote.

One of the great features of the .NET community is that it has an excellent base class library. I believe that one of the fundamental problems with C ++ is the minimalistic standard C ++ library. Any place where you intend to develop code, FOSS or corporate, there is a certain set of libraries that are used, since there is no wide standard library. So you end up being a C ++ programmer INSERT_YOUR_COMPANY_HERE and are not necessarily too portable. Yes, you translate design / architecture skills, but there is a learning curve with an understanding of any set of libraries that uses the following place. Where, as a .NET developer, he will mostly use the same class library and can hit the ground. In addition, libraries that are built (and reused) have a wider base for building.

Just as an aside, you can use http://codepad.org to embed code and support boost!

0
Feb 20 '09 at 20:45
source share

I worked for companies that saw boost as a library in order to partially avoid its past reputation as a poorly managed project. I know that everything has changed in the project, but commercial projects that want to use boost should know the source of the code contained in the library, or at least be sure that they will not be responsible for IP or patent infringement,

Unfortunately, the library has this reputation, and it will take some time to exit before it sees widespread use in the commercial sector. I also believe that this is a reason not to recommend it blindly.

0
Feb 21 '09 at 1:55
source share



All Articles