Posted on June 21, 2007
Q: Why is non-virtual the default in C#?
Anders Hejlsberg: There are several reasons. One is performance. We can observe that as people write code in Java, they forget to mark their methods final. Therefore, those methods are virtual. Because they’re virtual, they don’t perform as well. There’s just performance overhead associated with being a virtual method. That’s one issue.
—–
Fuck. Number one reason is performance. Well, if performance is so crucial then mark them as final, most of the time it is not an issuse. I’m using a virtual machine and JITed code, if speed was so crucial I would have used C. And Java has reasonable performace once it is running, I never had to complain about method call overhead.
They could have asummed that the method is non-ovewriteble by default and deoptimised the code in run-time first time it is overwriten. Or something like that.
In one book they said not to have an empy constructor because of the performance. Well couldn’t compiler detect an empty constructor? Doesn’t it create one by default? Fucking premature optimizations.
I’m so glad that my next project will be in Ruby.
Filed Under Uncategorized |
Leave a Comment
If you would like to make a comment, please fill out the form below.