POV-Ray : Newsgroups : povray.off-topic : Interesting performance comparison of C#s and C++'s : Re: Interesting performance comparison of C#s and C++'s Server Time
29 Jul 2024 18:25:03 EDT (-0400)
  Re: Interesting performance comparison of C#s and C++'s  
From: Darren New
Date: 22 Jun 2011 15:41:52
Message: <4e024580@news.povray.org>
On 6/22/2011 12:28, Warp wrote:
>    OTOH the slowness of virtual function calls (vs. regular function calls)
> is often greatly exaggerated, based solely on presuppositions rather than
> actual mesurements.

Well, it also depends on the programming language. In a language like C++ or 
Eiffel, you can make it a constant factor slower than a normal dispatch. In 
a language like Python or Smalltalk, where executing the third line of the 
function can change whether the fourth line of the function is a virtual 
dispatch or not, it's much harder to optimize. I suspect the exaggerated 
slowness claims is left over from when "virtual dispatch" meant "look up a 
string in a hash table for each function call" rather than "index into a 
vtable".

>    I wonder when they will add scope-bound objects to Java.

They did. They called it C#. ;-)   (Altho, unlike C++, it's actually 
"instances of scope-based classes" rather than "scope-based objects." And 
even there, that's just the implementation and not necessarily the 
semantics. There's nothing stopping you from allocating value types on the 
heap in a C# implementation.)

My guess is, it'll take a very long time, because unlike C#, people are 
unwilling to change the .class file format. The same reason C# has real 
generics and Java has type-erased generics.

>    First Java wanted to get as far from C++ as possible. It's slowly drifting
> towards it.

Nah. Only performance-wise. These are all performance-oriented things done 
by the JVM after seeing the class file. It's not changing the syntax or 
semantics of Java at all (unlike scope-based objects would).

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.