D vs C++

bearophile bearophileHUGS at lycos.com
Sun Dec 26 00:53:46 PST 2010


foobar:

> Structured programming is considered a huge improvement over gotos and spaghetti code and I thought that OO is considered better than Structured programming.

Unfortunately both biological evolution and software evolution are not a March of Progress :-) So OOP doesn't automatically mean "better". Well written OO code is better for certain kinds of large programs. There are other situations where OO leads to equally good or worse code. In some situations in D2 I prefer to use a functional style with mostly pure functions instead of OOP.


> Isn't using polymorphism considered usually better than explicitly maintaining a switch statement?<

This is sometimes right, expecially if your compiler is able to perform devirtualization, or if that part of your code doesn't need max performance. Sometimes replacing a little switch with a lot of polymorphic code doesn't make the code simpler to understand.

Bye,
bearophile


More information about the Digitalmars-d mailing list