Post about comparing C, C++ and D performance with a real world project

Daniel Kozak kozzi11 at gmail.com
Thu Dec 7 21:38:57 UTC 2017


Yes using FILE* directly could be the way.  But using file.rawRead is still
possible. But it is better to use static array with length one. Other
problem is with string.  It would make sense make it out instead of ref and
change it to empty string and use RefAppender.

Dne 7. 12. 2017 9:00 odp. napsal uživatel "Steven Schveighoffer via
Digitalmars-d" <digitalmars-d at puremagic.com>:

> On 12/7/17 1:26 PM, Daniel Kozak wrote:
>
>> This is not about write the best D code. It is about similar code to
>> perform same. However when I looked at the D code it is not good port of
>> C/C++. He made many mistakes which make it slower than C/C++ counterpart.
>> One example is read_one_line function:
>> C++: https://github.com/jpakkane/pkg-config/blob/cpp/parse.cpp#L60
>> D: https://github.com/jpakkane/pkg-config/blob/d/parse.d#L57
>>
>
> Wow, interesting that D uses less memory with that continue new char[1] in
> there!
>
> Kind of funny that he didn't just use FILE * directly, it's totally
> available in D :)
>
> -Steve
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20171207/c0ab22bb/attachment-0001.html>


More information about the Digitalmars-d mailing list