Someone should tell him about D...

IGotD- nise at nise.com
Fri Jun 3 20:12:01 UTC 2022


On Friday, 3 June 2022 at 19:24:03 UTC, monkyyy wrote:
> On Thursday, 2 June 2022 at 17:42:42 UTC, IGotD- wrote:
>> I know it's a bit strange because C++ is actually much better 
>> than C (not even mentioning the security hazards). That's why 
>> I like D because in this case it's much better than C++.
>
> ?
>
> Isnt c++ extremely slow? Like c++ adopts every feature and like 
> thats .... fine; but it can never be good

When it comes to strings? Depends what you are doing and how you 
are doing it. C++ made a strange decision to include the null 
terminator at the end of the strings even if it isn't really 
necessary. The result is that you cannot slice strings and can 
lead to unnecessary deep copies. In order avoid this C++ invented 
string_view and associated literals. Now you suddenly have two 
types of strings and if you make an API you might have to support 
both string and string_view. This is one of the crazy things with 
"modern C++". Still it is more user friendly than the old C 
library strings which also are prone to buffer overflows.

D in this case did the right choice not including the null 
terminator so that you can slice strings all you want and no 
extra string view.


More information about the Digitalmars-d mailing list