Thursday, December 16, 2010

Boost Library Learn - Wisdom + perseverance = omnipotent - Garden blog

 Regardless of when you start, it is important not to stop after the beginning of the more famous
Boost There are several libraries:
Regex regular expression library
Spirit LL parser framework, using C + + code directly expression EBNF
Graph graph components and algorithms
Lambda place called anonymous function objects define short, it is useful functional features
concept check check in generic programming using templates concept
Mpl meta-programming framework
Thread portable multi-threaded C + + library
Python to C + + classes and functions into
Pool mapped to the Python memory pool management
smart_ptr 5 of intelligent pointers, smart pointers must-read study .
Boost library full Development Guide: Inside the C + + What components used STL? which components used Boost?. the complexity of various operations and the possible failure scenarios iterator. If there is an experienced programmer, I will ask shared_ptr thread safety, the consequences of circular reference and how to avoid, weak_ptr the role. If these are answered quite well, and further also want to ask how thread-safe reference count, how to customize the deletion and so on. these issues so that I can quickly identify the level of the other C + +.
The reason I asked in an interview Boost, because indeed many of the components of which can be used for writing maintainable product code. Boost library contains nearly a hundred, many of them have practical value for the best. each person is different tastes and technical background, the trade-offs are not the same on the Boost. In my personal experience, the first library you can use absolutely harmless, such as noncopyable, scoped_ptr, static_assert, etc. These libraries are relatively easy to learn and use, easy to start. Second, some features its own is not difficult to implement, just Boost provides a ready-made in the code, it may wish to use, such as the date_time and circular_buffer and so on. Then, in the new project, for messaging and resource management could be considered a more modern way, as with a function / bind in some cases The following virtual functions as a library instead of the callback interface, with the object of shared_ptr thread-safety callbacks and so on. This will affect the whole process between the two design ideas and style, you need to take into consideration, if the proper use of smart pointers, in modern C + + program generally do not appear in the delete statement. Finally, some of the poor performance of the library remain vigilant, such as lexical_cast. In short, everyone in the project team members understand and use, based on the introduction of ready-made Boost appropriate components to reduce duplication and improve productivity.
Boost is a treasure, both of which can be directly used in the code, but also the design ideas worth learning. One example: regex regular expression library for thread-safe processing. early RegEx class is not thread safe, it is the not change (immutable) and variable (mutable) data, the former can be safely shared across threads, while the latter can not. such as the regular expression itself (basic_regex) and the result of a match (match_results) are immutable; and match action itself (match_regex) related to status updates, is variable, then re-enter the function with their packages, to keep the data leaked to other threads. It is reasonable because such a distinction made, regex in normal use when not locked.
Donald Knuth in , then to nothing interesting to say about this career. In other words, of course, we emphasize the work Do not reinvent the wheel, but as a qualified programmer, should have the ability to self-made wheels. non can not and is not do so.
C / C + + language is a major feature is its standard library can use language itself to achieve. C standard library strlen, strcpy, strcmp series function is teaching and practice of good topics, C + + Standard Library complex, string, vector is is a class, resource management, a great demonstration of the template programming. In-depth understanding of STL implementation, the use of natural Shoudaoqinlai STL, and can automatically avoid some errors and inefficient use.
for Boost, too, when used to eliminate concerns, in order to use more smoothly, and sometimes we need a proper understanding of their internal implementation, validation and even write a simplified version for comparison. However, because the code uses Boost application development day is not a common high-level syntax and techniques, and in order to span multiple the platform and compiler and extensive use of preprocessor macros, read the Boost source code is not relaxing, you need to 下一番功夫. On the other hand, if you indulge in these interesting details of the underlying forget what is supposed to solve the problem, I am afraid the forest for the trees.
Boost Many of the library is based on the paradigm of generic programming to design, for people who are familiar with object-oriented programming is concerned, may face a change in thinking. For example, you have to know that generic programming sets of terms, such as concept, model, refinement, it is easy to read Boost.Threads document description on the various locks. I think, for people familiar with STL design philosophy, this is not a big problem.
in some areas, Boost is not the only choice, not necessarily the best choice. For example, the source code to generate formulaic, I preferred to use a scripting language to write a short code generation process, rather than Boost.Preprocessor; to C + + program embedded domain specific languages, I preferred to use Lua, or other language interpreter, without Boost.Proto; C + + program to use context-free grammar parsing, I preferred to use ANTLR to define the lexical and grammatical rules and generate the parser ( parser), but not Boost.Spirit. In short, the mind must be calm when using Boost, not rivalry to transform the C + + language. it helps to improve the productivity of that part of the function into full play, so the project benefited from is the key.
To learn Boost, in addition to its official website to read the documentation, samples and source code, the best to have a more comprehensive read Chinese books on hand at any time. For developers who are not fluent in English, it is fortunate that extreme. You the hands of this . got this manuscript, I read Rough is fine to read it, on the whole, of high level, but also very pragmatic, C + + and Boost on the understanding and use is in place, I learned from this book is not little new knowledge. For this reason, I am pleased to want to learn Boost library developers Kaopu recommend this book.
(Please make your evaluation of the article)
the most simple to read format:
Day one hundred twenty-three thousand four hundred fifty-six Statistics

No comments:

Post a Comment