C++ sucks

Martin Naef EMAIL HIDDEN
Thu Nov 22 19:43:48 CET 2007


Hi Peter

Peter Korsten wrote:
> Yes, but here comes the next problem: speed. With C, specifically on 
> Unix, I can mmap() a file and it magically appears as a bit of memory, 
> without any effort from my side. Since you need to be jumping through 
> that memory, you'll be looking at pointers - a concept that Java lacks. 
> So I'd be looking at C, or C++.

Let's just hope that data values are properly aligned, unless you're 
sure your code never runs on anything but x86 CPUs... But yes, it's a 
nice way of accessing files.

> In C++, you can't have an abstract base class (which for me means 
> without any private members), implement it in another class, and use 
> that implementation whilst pretending it's still the interface. In Java, 

Why not? The only place where you need to know what it is that you're 
instantiating is the new call. And that's easily hidden using a factory 
design pattern.

> you can stick that interface in a template class, but my Sun Studio 11 
> compiler started complaining that it couldn't instantiate a 
> vector<PetersClass> because PetersClass was abstract.

Ahh, I see - that's a pecularity of the standard template library in 
that case. What stops you from using a vector<PeterClass*> instead? This 
is probably going to be miles more efficient anyway, because a vector of 
  large classes is rarely efficient. You might also be able to get 
around that problem by providing your own allocator class.

Oh, and BTW: You're using a feature (template classes) that Java lacks 
in the first place...

Bye
Martin

-- 
http://www.navisto.ch
http://www.myspace.com/navisto



More information about the music-bar mailing list