[mapserver-dev] Modernizing code base: C99 and maybe C++ ?

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Wed Nov 27 13:07:09 PST 2019


There is something that seems to touch C/C++ but not really so closely in https://trac.osgeo.org/mapserver/ticket/545.

I don't write code but what Even writes makes me believe that C++ has some true benefits. +1 if it is possible to make some useful moves  which do not require huge effort with the old codebase.

-Jukka Rahkonen- 

-----Alkuperäinen viesti-----
Lähettäjä: mapserver-dev <mapserver-dev-bounces at lists.osgeo.org> Puolesta Even Rouault
Lähetetty: keskiviikko 27. marraskuuta 2019 20.26
Vastaanottaja: Steve Lime <sdlime at gmail.com>
Kopio: mapserver-dev at lists.osgeo.org
Aihe: Re: [mapserver-dev] Modernizing code base: C99 and maybe C++ ?

On mercredi 27 novembre 2019 11:26:10 CET Steve Lime wrote:
> I don't think anyone has ranted about moving the code-base to C++ 
> before -

And this is exactly was really surprises me. I should really have written that email 10 years ago (well maybe not about C++11
10 years ago :-)), I blame myself for not doing it, but everytime I touch MapServer code base, this is the first thing that comes to mind.
Maybe I've been "spoiled" too much lately with practicing C++11 in GDAL or PROJ, but the syntaxic sugar really lowers the cognitive burden from the language features to the interesting algorithmic part. I can tell you that PROJ 6 would have never seen the light if it had to be written in C89 (some might have seen that as a good outcome maybe :-)). Or I would still be chasing for memory leaks all over the code.
Anyway as a PSC member I think it is my duty to raise the issue, be it in a rough form. This is an "open source" project, for better and worse, so anyone can see by themselves how the code looks like. Eh, isn't that our main differentiating argument w.r.t proprietary software :-) ? And this is probably what a new contributor would do.

> Still, it's likely a lot of work depending on how far it was taken. I 
> mean does this mean turning xxxxxObj structures into proper C++ classes, etc...?
> How would you see pulling off a conversion like that off?

I wasn't even thinking at that. That would be a huuuuge effort. Was more thinking about just using string manipulation facilities locally in functions.
Or using a vector, a hashmap, etc... Something incremental. Then someone bold enough could try to adapt the internal API progressively. Even my apparent joke about renaming the files from .c to .cpp was pretty seriously considered, and could be seen as a positive signal, even if most of it remains mostly in C.

OK, as an example of what C could save us. This recent commit by myself, which I needed when touching a bit the SLD code
It is mostly my reimplemtation in C of what the std::string += operator does.
msStringConcatenate() is fundamentally an inefficient way of concatenating strings.
It has probably O(n^2) performance if you call it to aggregate lots of small substrings.

> Definitely RFC worthy...

I have written long enough RFC lately :-) Deferring on that one. The material is pretty much above.


Spatialys - Geospatial professional services http://www.spatialys.com _______________________________________________
mapserver-dev mailing list
mapserver-dev at lists.osgeo.org

More information about the mapserver-dev mailing list