Inherent code performance advantages of D over C?

Paulo Pinto pjmlp at progtools.org
Mon Dec 9 04:12:57 PST 2013


On Monday, 9 December 2013 at 10:03:31 UTC, Szymon Gatner wrote:
> On Monday, 9 December 2013 at 09:58:01 UTC, Paulo Pinto wrote:
>> Not when writing portable code.
>>
>> Nowadays I just do JVM/.NET stuff, but I still remember the
>> headaches of writing portable C and C++ code across commercial
>> UNIX systems during 1999 - 2001.
>>
>
> Don't know about C much but writing portable C++ is not a 
> pleasant task, especially now, when you really want to use 
> C++11 features. Saying that nobody cares about portable code is 
> of course completely ignorant. I would even say that today it 
> is more relevant that single-platfrm code.

Many people in the open source world equate writing portable C
code with using gcc and clang across Linux/BSD distributions,
while complaining about Windows.

However when using commercial C compilers across many systems.
The C language standard is full of undefined behaviors that will
bite you, once you start using multiple vendors.

Then there was the POSIX standard, with its own set of undefined
behaviors and vendor specific extensions.

Additionally when I was in this project, some of the C compilers
were still midway between K&R and ANSI C compliance.

Thankfully most of the application was written in TCL with OS
specific C bindings.

As for C++, it has been always like that. One of the reasons I
liked Java so much in the beginning was it is a C++ like
language, with Pascal like safety, that I could use everywhere
without having #ifdef everywhere on my code, always wondering
what language constructs would be supported.

Writing portable C++ code before the C++98 standard was finalized
was a guessing game of what each compiler supported what, and how
far it was from the ongoing draft.

So if you wanted to play safe, the C++ code was basically a
better C with in-house developed classes.

--
Paulo


More information about the Digitalmars-d mailing list