Hacker News new | ask | show | jobs
by Ideka 4157 days ago
(The following mostly applies to C#.)

> Objects containing the same values should be equal by default.

Sounds good, but it's a tricky issue. Equality must be checked between all values of both objects. This can take long, as objects can have many values and may contain references to other objects which may in turn contain references to other objects and so on. Object references might even be cyclical. Not impossible to account for but quite tricky.

And how about get/set properties? These must be checked as well, even though many will be just "mirrors" of private or protected properties, and others might be calculations based on other properties (like the area of a circle).

> Comparing objects of different types is a compile-time error.

Accounting for inheritance, I assume.

> Once created, objects and collections must be immutable.

This sounds like a terrible idea. Wouldn't objects be to even modify their own properties?

> Objects must always be initialized to a valid state. Not doing so is a compile-time error.

> No nulls allowed.

Nulls are useful. The problem here comes from not knowing whether something may be null or not. The solution would be only allowing Nullables to be null, and enforcing anything that's not a Nullable to be initialized.