Thoughts about D

Ola Fosheim Grostad ola.fosheim.grostad at gmail.com
Mon Nov 27 06:12:53 UTC 2017


On Monday, 27 November 2017 at 05:11:06 UTC, Neia Neutuladh wrote:
> You might say that I could use C++ style manual memory 
> management and get even better performance. And you'd be wrong.

No... Not if you do it right, but it takes more planning. I.e. 
Design. Which is why scripting and high level languages dont use 
it.

> std::string does the same thing. So if I reimplemented subtex 
> naively in C++, its performance would be closer to the C# 
> version than to the D version.

You meant stupidly, you would rather use std::string_view for 
string references in C++. std::string is a library convenience 
type that typically is only used for debugging and filenames. If 
you want performance then it really isnt possible to make do with 
a fixed library type for strings so in a realistic program people 
would write their own.

> I could probably get slightly better performance than the D 
> version by writing a special `stringslice` struct. But that's a 
> lot of work,

No...

> On the whole, it sounds like you don't like D because it's not 
> C++. Which is fine, but D isn't going to become C++.

Sure. But maybe you shouldn't use a tiny 400k input when 
discussing performance. Try to think about how many instructions 
a CPU executes in 50ms...

If you dont know C++ then it makes no sense for you to compare 
performance to C++.



More information about the Digitalmars-d mailing list