Some Java/C# design flaws

bearophile bearophileHUGS at lycos.com
Mon Feb 1 05:14:12 PST 2010


A list of some Java flaws:
http://c2.com/cgi/wiki?JavaDesignFlaws

To me among those ones the following three ones seem interesting for D:

Every object is a monitor:
http://c2.com/cgi/wiki?EveryObjectIsaMonitor
@nomonitor class Foo {} in D? If you don't use threads this saves a little memory and time.
In LDC there's  pragma(no_typeinfo)  and in future  pragma(no_moduleinfo)  too. They can become @notypeinfo.


Java exceptions should be interfaces:
http://c2.com/cgi/wiki?JavaExceptionsShouldBeInterfaces
I don't fully understand the implications of this, but it seems interesting.


Messy exception hierarchy:
http://c2.com/cgi/wiki?MessyExceptionHierarchy

------------------

About some C# flaws:
http://stackoverflow.com/questions/411906/c-net-design-flaws

Among them the following ones looks interesting:

1. non-nullable reference types as a complement to nullable value types,
10. fix quadratic enumerable behaviour,
11. all collections should have immutable snapshots for iteration (ie. mutating the collection should not invalidate the iterator),
12. tuples are easy to add, but an efficient closed algebraic type like "Either" is not, so I'd love some way to declare a closed algebraic type and enforce exhaustive pattern matching on it (basically first-class support for the visitor pattern, but far more efficient); so just take enums, extend them with exhaustive pattern matching support, and don't allow invalid cases,
20. allow operators in interfaces, and make all core number types implement IArithmetic; other useful shared operator interfaces are possible as well,
22. simplify declaring constructors; I like F#'s approach, but the other post here that requires simply "new" instead of the class name is better at least,


That point 10, "fix quadratic enumerable behaviour,", it's a problem present in Python too.

Bye,
bearophile



More information about the Digitalmars-d mailing list