Re: [GENERAL] C++ port of Postgres

From: Serge Rielau <srielau(at)gmail(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, dandl <david(at)andl(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] C++ port of Postgres
Date: 2016-08-17 14:07:49
Message-ID: F3B97D95-6DF0-4B38-8ED4-F4F8CA7BEB88@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers


> On Aug 16, 2016, at 10:16 PM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
>
> On 17 August 2016 at 09:49, Andres Freund <andres(at)anarazel(dot)de <mailto:andres(at)anarazel(dot)de>> wrote:
>
>
> You need to include the files surrounded by extern "C" { }.
>
> I'd really like to adopt the convention used by many libraries etc of doing this automatically - detecting a c++ compiler in the preprocessor and wrapping in "extern "C"" .
>
> Having the codebase c++-clean enough to compile with a c++ compiler seems to be the easiest way to maintain that, but means more "extern "C"" droppings in the .c files, not just the headers. Still, pretty ignoreable.
>
Big +1 here,
Just having community code compilable with a C++ compiler out of the box would go a long way.

Beyond that, on my end I have been working with PG now for a year and a half and here is a quick list of what I sorely miss from my C++ days:
* Overloading of functions (same as in SQL) keeps naming clean
* Named parameters (same as SQL) keeps code readable
* Adding new function parameters with defaults so I don’t need to pass in NULL, 0, … at 20 places (again supported in SQL)
* Member functions greatly help organize code
* simple inheritance (as emulated today in node types)

At my old employer we used C++ for the DBMS in various degrees in different components.
That degree was agreed upon in coding standards, so we could pick what we like about C++ and blacklist what we didn’t.
E.g. C style exception handling was prohibited
Default memory management (new) was prohibited.
Instead new() was overloaded and hooked into the DBMS memory manager.
I see no reason why this couldn’t be done in PG.

I can’t comment of compiling on a Rasperry PI, but know that my former DBMS code compiled and ran on Windows, Linux, AIX, Sun, HP, and Mac.

But again, just having the community code compile so proprietary (for now) enhancements could be written in C++ would be huge.

Cheers
Serge

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pete Fuller 2016-08-17 14:46:45 Re: 9.2 to 9.5 pg_upgrade losing data
Previous Message Aleksander Alekseev 2016-08-17 11:40:27 Re: [GENERAL] C++ port of Postgres

Browse pgsql-hackers by date

  From Date Subject
Next Message amul sul 2016-08-17 14:35:28 Re: Bug in to_timestamp().
Previous Message Tom Lane 2016-08-17 13:55:04 Re: drop src/backend/port/darwin/system.c ?