|
| 1 | +[/ |
| 2 | + (C) Copyright 2010 Dean Michael Berris, Glyn Matthews. |
| 3 | + Distributed under the Boost Software License, Version 1.0. |
| 4 | + (See accompanying file LICENSE_1_0.txt or copy at |
| 5 | + http://www.boost.org/LICENSE_1_0.txt). |
| 6 | +] |
| 7 | + |
| 8 | +[section:pitfalls Common Pitfalls] |
| 9 | + |
| 10 | +There are a number of common pitfalls one gets to when implementing a |
| 11 | +header-only network library. Some of these are briefly discussed in this |
| 12 | +section. |
| 13 | + |
| 14 | +[heading Linear Explosion] |
| 15 | + |
| 16 | +The linear explosion comes up when you start supporting a lot of different tags |
| 17 | +through the tag dispatch mechanism. There is a temptation to implement support |
| 18 | +a whole slew of tags and the associated variations brought about by these tags. |
| 19 | +Because of this as soon as you start mixing and matching tags you get to a point |
| 20 | +where where there can be a lot of tags and a lot of specializations. |
| 21 | + |
| 22 | +To manage linear explosion, using a moderately robust template metaprogramming |
| 23 | +library like Boost.MPL should be used to remove much of the repetition and |
| 24 | +manage the growth of the variations/combinations. |
| 25 | + |
| 26 | +[heading Compile Time Toll] |
| 27 | + |
| 28 | +Due to the nature of template metaprogramming and the current state of compiler |
| 29 | +technologies, the cost of going header-only can be considerable during |
| 30 | +compilation. It is no secret that template metaprogramming takes a lot out of |
| 31 | +the compiler because the template implementations of most of the popular |
| 32 | +compilers were not built to handle template metaprogramming. The state of the |
| 33 | +art when it comes to compiler technology is changing in C++ with the promise of |
| 34 | +faster, more efficient, and more robust template metaprogramming support. |
| 35 | + |
| 36 | +Aside from doing as much as you can to optimize the compilation times of |
| 37 | +template-based programs, the only solution really is to wait for (or to actually |
| 38 | +help) compilers to get faster and better when compiling template-heavy code. |
| 39 | + |
| 40 | +[heading Contribution Barrier] |
| 41 | + |
| 42 | +Currently there are not a lot of C++ programmers who understand how to do |
| 43 | +template metaprogramming as well as implement efficient network utilities. There |
| 44 | +are a lot of C++ programmers who are looking for an using libraries to make |
| 45 | +network programming easier at a higher level. The disparity between the users |
| 46 | +and the developers can be considerable, and using a relatively niche technique |
| 47 | +like template metaprogramming in the implementation of the library proves to be |
| 48 | +a significant contribution barrier. |
| 49 | + |
| 50 | +Because cpp-netlib is a project that has in its stated goals the implementation |
| 51 | +and the distribution of a header-only collection of network-based libraries, one |
| 52 | +solution to the issue is in the education and dissemination (and documentation) |
| 53 | +of the techniques used and the rationale for why these techniques are used in |
| 54 | +cpp-netlib. This is the goal of this paper and in the future editions of this |
| 55 | +paper. |
| 56 | +[endsect] [/ pitfalls] |
0 commit comments