Re: Java's performance far better that optimized C++

From: Ioannis Vranos (ivr_at_guesswh.at.grad.com)
Date: 06/20/04


Date: Sun, 20 Jun 2004 01:53:49 +0300

valentin tihomirov wrote:

>

Knowing that such discussions never end, here is my answer:

> In java, we have a rich abudance of neat classes. In VC++ (I have no
> experiance with other IDEs, but MS's studio is an acknowledged leader) we
> have a huge number of types, classes. Documentation is huge and of ugly
> quality, it is not possible to understand how working a method without
> trying it. Two my collegues (newbies but MFC fans) was trying to use sockets
> to pass a file, it has taken them a whole week to choose socket class and
> make it working. I should have given them a link to java sockets tutorial
> just for them to understand what is a socket. MSDN (these 3 gigs of stuff)
> contains huge number of incomplete and contravertial manuals.
> IDEs. I preferer an IDE that is aware of my code structure. VC is a notepad.
> It cannot even find the definition of a variable (shows you a list of
> candidates). Intellij checks your code when you're typing.

MFC etc. are system extensions and not part of the language
specification. VC++ is just a compiler of many.

However regarding the above, I know .NET programming and not MFC and in
.NET it is very easy to create a web service for example and VC++ 7.x
include intellisense.

Again it has nothing to do with C++, and if the Java framework was open
to other languages, we would be able to use it with C++.

>
> Compiler. C++ has extremely slow compiler (it produces tremendous amounts of
> info and processes them). The compiler is extremely stupid. You can create a
> class (in a file) which is compilable. The class stops compiling once
> attached to a project. Compiler shows a stupid message like "something
> expected". Finally, you realize you have forgotten to put a closing parensis
> in some another file of the project. I favor any lang withour includes.

And using what else instead?

> Often messages like unresolved method appear and compiler cannot point to
> the line.

?

> The need for .h files bizzare, interface must be typed twice. Complicates
> modifications.

No it eases modifications. Assuming that you place declarations inside
.h files only, you can change the definitions and not need to recompile
the whole project, but only the modified files as far as the
"signatures" remain the same.

>
> Exceptions. not handeled exception shows you a reasonable error message and
> stack trace. It is allows to locate an error without using an IDE debugger!

It depends on the platform, the same things happen with my compiler. A
stack trace is provided.

>
> GC. Hard to debug problem, no memory leaks are guaranteed.

If you program using the "resource acquisition is initialization
technique", the result is bullet proof code with optimum space and time
efficiency.

[Reference: "The C++ Programming Language" 3rd Edition or Special
Edition, pages 365-367]

However I have GC in my .NET programming.

 From "The C++ Programming Language" 3rd Edition or Special Edition:

"C.9.1 Automatic Garbage Collection

When this regular approach isn’t sufficient, the programmer might use a
memory manager that finds unreferenced objects and reclaims their memory
in which to store new objects. This is usually called automatic garbage
collection, or simply garbage collection. Naturally, such a memory
manager is called a garbage collector.

The fundamental idea of garbage collection is that an object that is no
longer referred to in a program will not be accessed again, so its
memory can be safely reused for some new object. For example:

void f()
{
  int* p = new int;
  p = 0;
  char* q = new char;
}

Here, the assignment p=0 makes the int unreferenced so that its memory
can be used for some other new object. Thus, the char might be allocated
in the same memory as the int so that q holds the value that p
originally had.

The standard does not require that an implementation supply a garbage
collector, but garbage collectors are increasingly used for C++ in areas
where their costs compare favorably to those of manual management of
free store. When comparing costs, consider the run time, memory usage,
reliability, portability, monetary cost of programming, monetary cost of
a garbage collector, and predictability of performance."

>
> Exceptions+GC+sandbox is time saver in application programming and paramount
> in erterprise programming. Therefore, MS has to invent C#.
>
>
> If I need to program for performance, I'll use Delphi for win; it beats VC++
> by all the params (it is java in spirit but concept is native compilation +
> no GC). The resulting code is faster. In last week I have won a bet with my
> VC++ fan collegue (it was his idea) implementing bubble sort algorithm. In
> addition, woring directory is tiny, tens of kilobytes and some files vs.
> tens megabytes and some directories of files per project.

:-) Ok if you like Delphi better, use Delphi then. However I think VC++
produces more optimised code and there are other C++ compilers too like
GCC ports for Windows (MINGW, DJGPP), etc.

>>The programming world is multi paradigm and multilingual. When you
>>understand this, it will be good for you.
>
> I do not agree. For any purpose there should be only one tool (language).

And punish anyone else who dares to create a language? :-)

> I
> know many langs from different groups (general-purpose, asms, SQL, scripts,
> hardware description langs), SystemC will be the next step. Langs in one
> group are competitors. However, we cannot support/learn all of them, in each
> group must exist only one. As I'm idialist, I want these to be simple yet
> powerfuls ones. I don't like when far from the best langs (C++, english)
> suppress others. The fact that english is overly complicated is not just my
> feeling, it is info from lingusits on EU, it is very irregular. I have the
> same considerations about C++ (the compiler approves).

So you can talk the language that you like and program in the language
you like, while letting anyone else use whatever he likes too.

> All C++ programmers are sure that C++ is faster than Delphi (I have shown on
> bubble sort example it is false). I see the troubles that VC++ collegues
> experience, like converting int to str or loading/showing icons dynamically.
> I show code can be written tens of times faster in Delphi and it executes
> faster but they go on writing VC++. It is not fanatism; these are
> misconceptions + pragmatism. My collegue who lost the bet still tells it is
> not possible that Delphi compiler produces fater code. I do will not insist
> that it is faster in general but any peformance differences < 20% are not
> observable anyway. In addition, they merely ignore any not popular
> opportunities. It is the client who knows that C++ rules the wolrd, he has
> huge number of C++ code lines and mandates the tool. Do you choose the tool
> yourself?

This is quite useless discussions since all those compilers including
Java ones are all written in C++...

> When considering languages, there is one important parameter which is more
> important than language complexity (learning curve), development effort and
> execution performance all together. It is the number of "language carriers".
> Looking into the future, this means that number of language carriers will
> rise with no chances for alternatives. This makes me unhappy, because as
> idialist, I know that in presence of a more effective tool it makes sense to
> go on using an adopeted one only in short-term perspective. Adoptation of a
> new (more efficient) technology gives considerable benefits in the
> long-term.
>
>
> But all we live today and have habits. All I have written here is useless,
> because nobody agree/cares. Further discussion is really useless.

Well it is, since everyone will stick whatever he likes more, as far as
it produces results, and I can see nothing bad in this. For example if
one wants to make some simple number addition programs I see no reason
why it would be bad to use qbasic.

Regards,

Ioannis Vranos



Relevant Pages

  • Re: A few newbie garbage collection questions
    ... Things have finally arranged themselves in my programming life that the ... If I plan to use garbage collection, do I just drop everything that I ... GC does not free you from having to think about memory ... The Garbage Collection Programming Guide talks about what you have to do ...
    (comp.sys.mac.programmer.help)
  • Re: A Tale of Two Memory Managers (long)
    ... If nobody cared how long a .NET app took to load, sure, the JIT compiler ... > memory managers. ... slowness of .NET code hasn't been caused by garbage collection but by ... memory leaks at all. ...
    (borland.public.delphi.non-technical)
  • Re: C garbage collection -crazy idea
    ... then is it not a garbage collection (in the first place, ... How is the compiler supposed to know /where/ to add the `free` call? ... There are many examples where the results of malloc() are or can be ... memory is returned from the scope no call to free has to be performed. ...
    (comp.lang.c)
  • Re: sPARTADOS X
    ... > Could be a Keith Ledbetter cross compiler, like I said foggy memory. ... > I am 90% sure the source code for SDX was specific to the compiler which ... > running a BBS or programming it was the tool to have. ...
    (comp.sys.atari.8bit)
  • Re: savefile design
    ... programming time may not be. ... promote as an alternative to garbage collection. ... more to life than memory. ... Messy data structures are harder to understand ...
    (rec.games.roguelike.development)