Re: The switch to C++

From: Robert Collins <robertc@dont-contact.us>
Date: Fri, 03 Oct 2003 16:45:49 +1000

On Fri, 2003-10-03 at 07:26, Troels Arvin wrote:
> Hello,
>
> Out of general programming curiosity (I'm in the proces of learning C++),
> I hope that someone will be kind and comment on:
>
> 1. What were the main reasons for the switch from C to C++?

We had decided to move away from C to an OOP language, for programmer
efficiency, and increased flexability. Java wasn't popular amongst the
core...

> 2. Have the reasons proven to be valid?

IMO yes. Areas that have been refactored into reasonable C++, are much
more amenable to extension and tweaking. Consider for example the
per-user delay pools, was relatively trivial - on the back of an OOP
rewrite of the prior delay pools code.

> 3. Do you use STL? If not: Why?

Sortof. There where some concerns about a learning curve for the non C++
savvy amongst us, plus the headache of debugging multi-page errors,
which the STL being templated is prone to.

> 4. Do you use exceptions? If not: Why?

No. Concerns (untested) about overhead for in-stack exceptions. Fatal
errors we already have a robust handling method for. Finally, it's often
the case in squid that the caller of a function is no longer on the
stack, due to the callback orientated nature of squid.

> 5. Has the switch to C++ made the code more portable?

No. Yes. It's really an orthogonal question. Some platforms don't have a
good C compiler - OS/2 for example can't build the squid-cache.org code
for 2.5, only a custom port. Others don't have a C++ compiler. So I
think we've gained what we lost :]. That said, template instantiation on
different platforms promises to be the biggest headache.

> 6. Do you use templates? - In that case: Where may I see
> good examples of their use in the code base?

Yes, in various places. include/List.h for instance. Or include/Array.h.
Or src/Generic.h. or ....

I *hope* all our examples are good :}.

Rob

-- 
GPG key available at: <http://members.aardvark.net.au/lifeless/keys.txt>.

Received on Fri Oct 03 2003 - 00:46:02 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:20:43 MST