C is Brittle D is Plastic

Dennis dkorpel at gmail.com
Sun Mar 22 11:56:00 UTC 2026


On Sunday, 22 March 2026 at 04:47:41 UTC, Walter Bright wrote:
> Another source of slowdown in C that became apparent over the 
> years is C is a brittle language, rather than a plastic one.

Another example where D shines in this regard is UFCS allowing 
you to turn fields into methods and vice versa:

```D
struct S
{
     ubyte* ptr;
     ubyte* end;
     size_t length() => end - ptr;
}
```

```D
struct S
{
     ubyte* ptr;
     size_t length;
     ubyte* end() => ptr + length;
}
```

You don't need to change `.end` into `.end()`, `.end` works on 
both fields and methods.


More information about the Digitalmars-d mailing list