D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] boost anyone

 

On Thu, Dec 16, 2010 at 8:58 AM, tom <tompotts@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> OK perhaps I should say looking for example uses that dont make some Boost
> libs look like a solution to a problem that doesn't exist other than
> ideologically. There's a lot of 'you do it like this' but no 'why you don't
> do it like that' which for me is often the clue to the whole thing.
> I should perhaps say I'm coming back to C++ after a long absence using other
> OO languages, and I'm finding it the ugliest of the lot- barring PHP I
> guess.
> Tom te tom te tom


What do you want to use boost for/which part of boost are you
interested in? I've used some boost libs but certainly not the entire
set or even come close to using even the majority of the features even
on the libs i do use, its a huge library set.

The boost docs can be very confusing at times and can take a good few
passes and experimentation to understand them. And yes you probably
can do the same thing without them the question is how much extra
code/complexitity will this introduce and how much is then simply
reinventing wheels? and boost is cross platform too and takes into
account various issues with specific compliers and differences with
template handling in versions of MSVC etc, so portability becomes a
lot simpler.

A few examples, boost::signals is one i use frequently, it provides a
nice signal/slot system for application messaging, so interested
peices of code can "subscribe" and recieve a call back when the signal
is sent, then the code emitting the signal does not need to care too
much about who it needs to notifiy it just does a sig() on the event.
Also with boost::bind added in you can use non-static class member
functions as callbacks, as the bind operation can add the implicit
this pointer. All of this can be achieved without using boost but its
such a handy time saving code simplyfing thing that i just use it.

boost::regex is a handly one, although plenty of other regex libraries
do exist, but if you are going to drag boost into your application and
you need regex then its there already (boost::sprit is another boost
regex library)

The various boost smart pointers are also handy, they do a lot more
than the auto_ptr and firends in std by allowing shared pointers with
ref counting and also delete() when ref count =0, and yes again you
could create your own smart pointer class with its own ref counting
with just pure c++ templates and classes.

I do think some of the issue with c++, expecially if you have been off
using newer OO languages is c++'s core is some what lacking many of
the additional features and helpers that boost provides for c++, just
exist, for other languages and because boost is essentially an
extension to c++ using only its built in mechanisms of
templates/overloading etc it can end up a bit clunky.

The one big gotcha i keep comming across with people using boost is
the fact its a c++ library not a c library, so you can't just link a
binary of the boost libs compiled with one compiler version against
your application built with another and then be suprised when it
either fails to link or wierd crashes happen. Sure you can often get
away with it but often you can't  so best practice is use the same
compiler version.

Robin

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq