[OT] Sharp Regrets: Top 10 Worst C# Features

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 23 18:53:21 PDT 2015


On Sunday, 23 August 2015 at 02:39:03 UTC, Walter Bright wrote:
> On 8/19/2015 5:00 AM, Timon Gehr wrote:
>> Classes are reference types in C# as well.
>
> This is hardly innovation. C# took that feature from Java, and 
> it's likely much, much older than that.

Without looking it up, I would have assumed that any language 
that's heavily OO like smalltalk would have classes be reference 
types simply because OO and value types really doesn't makes 
sense. And C++ has issues due to the fact that it allows OO types 
to be used as value types (i.e. object slicing). So, I would 
expect that while C++ is what made OO big, it's probably the 
oddball language with regards to how it allows OO types to live 
on the stack instead of the heap. LOL, but of course, we'd have 
to actually do some research on older OO languages to be sure of 
that. Still, the nature of OO screams reference types, so it's 
pretty natural for classes to be reference types. You just lose 
out on the nicety of being able to create a polymorphic type on 
the stack for the cases where you don't actually need to use it 
polymorphically, but at least in theory, std.tyepcons.Scoped 
solves that problem, and for the most part, separating types are 
polymorphic and those that aren't seems to be a big win. It 
forces people to actually think about polymorphism instead of 
just making everything polymorphic, so you tend to end up with 
cleaner, more efficient code. At least, from what I've seen with 
D, that's how it seems to be, and I'm very glad for its 
separation of structs and classes.

- Jonathan M Davis


More information about the Digitalmars-d mailing list