View Single Post
Posts: 1,255 | Thanked: 393 times | Joined on Oct 2009 @ US
#56
Originally Posted by v13 View Post
Both sites seem like FUD to me.

The first site doesn't compare the languages at all. It just compares different algorithms: The java's algorithm and the author's algorithm for each example.

For god's sake, who allocates a matrix that will hold integers in C++ like this (matrix.cpp):
Code:
int **mkmatrix(int rows, int cols) {
    int i, j, count = 1;
    int **m = (int **) malloc(rows * sizeof(int *));
    for (i=0; i<rows; i++) {
	m[i] = (int *) malloc(cols * sizeof(int));
	for (j=0; j<cols; j++) {
	    m[i][j] = count++;
	}
    }
    return(m);
}
Not only he could just have done:
Code:
return malloc(rows*cols*sizeof(int))
and accomplish a 1000-times faster program, he uses malloc instead of new in a C++ program.

As for the second site, writing something like this:

makes me stop reading (why mention pointers when talking about C++? where are your references?). But I continued:



at this point the author compares the internal memory allocating method of the c library with the C (and C++) language. That's totally wrong and can be proved by looking at glibc and montern operating systems: glibc used not to free memory at all but instead re-use it (what the author wants) but that was changed and now it lets the kernel manage the memory more efficient. In fact, since all memory is virtual (and most of the time it is split in 4KB pages), there is no guarantee that two consecutive memory addresses will in fact be consecutive (or in cache). Of course, all these are operating system dependent and the OS tries to do its best. Java just builds a layer on top of this.

OK, Java's speed is acceptable, but the sites should have more serious claims...

p.s. I could keep commenting on almost all lines of those sites for hours, but you get the point
Hey, you seem to know your stuff- want to make a Turbografx emulator for the n900? Galaga 90 and Blazing Lazers are religious experiences