Wireshark-dev: Re: [Wireshark-dev] Idle Thought - Compiling with C++
From: Evan Huus <eapache@xxxxxxxxx>
Date: Sat, 9 Feb 2013 17:24:39 -0500
On Sat, Feb 9, 2013 at 1:50 PM, Guy Harris <guy@xxxxxxxxxxxx> wrote:
>
> (Subject line changed to match what you presumably intended.)

Yes, thank you.

> On Feb 9, 2013, at 6:41 AM, Evan Huus <eapache@xxxxxxxxx> wrote:
>> This just occurred to me as I was reading an article on GCC (which has
>> recently migrated to using a C++ compiler, despite still being mostly
>> written in C). I haven't given it a great deal of thought yet, but I
>> figured I'd bring it up and see what general opinion was.
>>
>> At a first glance, building Wireshark with C++ compilers would give us
>> two major benefits:
>
>         ...
>
>> - Built-in exceptions. This would be additional migration work, but it
>> would permit us to drop a non-trivial amount of code that we currently
>> own in order to do our own exceptions.
>>
>> Note that I'm not suggesting we start writing Wireshark in C++ (that's
>> an entirely different debate), but that we could compile using C++
>> compilers, and then potentially sneak in a few C++ constructs where we
>> used to roll our own.
>
> Presumably by "start writing Wireshark in C++" you mean "rearchitecting Wireshark as a C++ program", as once you've snuck in one C++ construct you're writing in C++. :-)

Fair point.

> Note that some of Wireshark, i.e. the Qt GUI part, is already written in C++, and at least one third-party Wireshark plugin, i.e. the WSGD packet description language plugin:
>
>         http://wsgd.free.fr
>
> is written in C++.

I was aware of the QT GUI, but not of the extension. As far as I'm
aware, Gerald's been doing the vast majority of the QT work, so I
didn't want to take that as indicative of a general interest.

> See also
>
>         http://hub.opensolaris.org/bin/view/User+Group+rs-osug/evan-adams
>
> The Old Man and the C
> Evan Adams
> Sun Microsystems
>
> Abstract
>
> "You can't teach an old dog new tricks" goes the old proverb. This is a story about a pack of old dogs (C programmers) and their odyssey of trying to learn new tricks (C++ programming).
>
> C++ is a large, complex language which can easily be abused, but also includes many features to help programmers more quickly write higher quality code. The TeamWare group consciously decided which C++ features to use and, just as importantly, which features not to use. We also incrementally adopted those features we chose to use. This resulted in a successful C++ experience.

Very interesting article - I agree with most of it. I personally have
some C++ experience (though less than I do pure C), but I have no idea
what kind of experience with it others have. I do think that slowly
and carefully adopting certain limited features of it would make our
lives easier, though honestly the primary reason I suggested it was
because of how fed up I am with MSVC :)

Evan