June 03, 2022

On 6/3/22 4:12 PM, IGotD- wrote:

>

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.

D almost had 2 types for arrays, one that would allow resizing and another that would just be a slice.

The point was to solve the stomping problem. But we fixed it a different way.

Feast your eyes!

https://forum.dlang.org/post/h5nbj3$17is$1@digitalmars.com

-Steve

June 03, 2022
On 6/3/22 13:24, monkyyy wrote:

> no, c > c++ in general because the sanest way to use c++ is as c + one
> or two features

My short list to pick C++ and never touch C:

- Constructor, destructor, etc.
- Templates

> and c++ will be extremely slow to compile and iterate on.

C++ compilation speed is one thing that shows me humans can adapt to any situation and can accept anything. An example: 64-way parallel compilation on 20+ cores and the project builds in 2 hours. :/

Ali

1 2 3
Next ›   Last »