[gdal-dev] Starting a discussion on style and coding guidelines

Tim Keitt tkeitt at utexas.edu
Sat May 7 14:57:20 PDT 2016


http://www.keittlab.org/

On Fri, May 6, 2016 at 2:47 PM, Mateusz Loskot <mateusz at loskot.net> wrote:

> On 6 May 2016 at 21:55, Kurt Schwehr <schwehr at gmail.com> wrote:
> > My belief is that for this particular proposal, we should not have the
> > C++11/14 discussion unless the best overall solution requires a newer
> > version of C++.  The solution I propose to be the best works in C++03 and
> > newer.
>
> Simply, the initial proposal was quite confusing.
>
> The 'title' said indicated it was "mostly focused on C++11/14 & C99/11",
> while the content mentioned mostly the std::vector as malloc'ed arrays
> replacement.
>
> Considering current codebase, GDAL is written in C and compiled in C++.
> The only major C++ feature used in GDAL is classes and polymorphism.
>
> I'm not sure if the facts mentioned in the proposal, namely
> "Want to focus on maintainability and readability of code",
> is meant to be a fact or a goal.
> If you ask any seasoned C programmer for opinion, I bet she will
> consider GDAL codebase as clear and readable.
> If you ask a C++ programmer, the answer might be different.
>
> IMO, I doubt any C++11/14 feature will increase the current code,
> unless it is considered to ditch many of CPL features and replace
> them with C++ standard features (string bashing operations, string
> containers,
> containers for other types, threading API, etc.).
>

That's exactly my preference. For those of us who have to remember too many
things, using the standard library is a godsend because it is exceptionally
well documented online and used in many places.


>
> Certainly, any new line to be written may benefit from auto,
> constexpr, using, nullptr, range loops - but for a "C with classes"
> codebase as GDAL, it would be cosmetic improvement, if any.
>

It is true that unless you refactor along the lines of Boost, then these
features are not used as effectively.


>
> Surely, the override and final will help compiler to catch potential bugs.
> Also, C++11/14 compilation mode is generally stricter, so it might
> help to catch bugs.
>

My experience with C++11 is that it is vastly less error prone and more
readable. But of course there is a big cost to rewriting code, so I
understand the conundrum.

THK


>
> Simply, the whole proposal is becoming vague.
>
> Best regards,
> --
> Mateusz Loskot, http://mateusz.loskot.net
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160507/1c355594/attachment-0001.html>


More information about the gdal-dev mailing list