> On 9 Apr 2025, at 11:41, russ.go...@gmail.com wrote:
> 
> I’ve heard that there is a desire to migrate the GnuCash code base to C++. 
> This is something I was thinking of looking into but don’t want to put in the 
> effort if this is not something that would be accepted by the gatekeepers.
>  
> I think the first step is to not refactor the code at all and just do the 
> minimal required to use the C++ linker for linking the executables and to 
> convert the cmake projects to use C++ compiler for all the (mostly C) code. 
> Then once all the code is using the C++ compiler we can start to prioritize 
> which portions of the code should be redesigned to be full-fledged 
> object-oriented projects.
>  
> I think this is work I could do w/o impacting any of the real development 
> going on but provide value down the road, but wanted to check-in first

Russ,

It should be so easy.

We’ve been migrating code to C++ in bits and pieces for years. Mostly we 
convert a file to build with C++ then poke at the internals, replacing 
containers with STL ones, converting raw loops to STL algos, using lambdas and 
range-for and constexpr and so on. In a few cases we’ve done full-on rewrites 
with templates and std::variant and such. There’s still plenty of that sort of 
work to do, so dive in. Please start with a smallish peripheral-ish class 
(meaning one that not a lot of other code depends on) so you don’t lose too 
much time if you need to course-correct.

Be sure to read https://wiki.gnucash.org/wiki/C++ and 
https://wiki.gnucash.org/wiki/CodingStandard before you start. Keep in mind 
that in nearly all cases the C++ must be wrapped in C access functions so that 
the C parts can call the C++ parts, and that no exceptions can escape the C++ 
boundary. Another thing that you need to be aware of is that most of libgnucash 
is also mapped to Guile/Scheme and large parts to Python using SWIG. So far 
we’ve only redone the SWIG bindings for the all-in C++ rewrites: As long as the 
C API remains then no SWIG changes are needed. The bindings live in the 
imaginatively-named `bindings` directory tree.

Not all of the C classes have good test coverage so you might want to start off 
writing some tests.

Are you familiar with the GObject type system?

Regards,
John Ralls


_______________________________________________
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to