Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Java versus C Speed Comparison

Author: Matt Taylor

Date: 17:16:05 01/07/03

Go up one level in this thread


On January 07, 2003 at 18:33:28, Russell Reagan wrote:

>On January 07, 2003 at 12:37:18, Matt Taylor wrote:
>
>>Likewise are C/C++ compilers that target 32-bit machines, are they not? The
>>difference here is that Java had 64-bit types from its release. Therefore the
>>compilers are more likely to pay attention to use of 64-bit types and produce
>>better 64-bit code.
>
>That sounds nice, but it also sounds flawed. One doesn't necessarily lead to the
>other. Just because it was there doesn't mean they spent significant amount of
>time optimizing it (as if like they could beat machine code optimizations
>anyway).
>
>I also question whether or not java had its beginnings before C/C++ compilers
>started to support 64-bit types. The issue is not whether 64-bit types were a
>part of the standard specifying the language. Java has been around since 1995 or
>so, and you mean to tell me that since the 1960's when C was created, no one
>ever found it necessary to add a 64-bit type to a C compiler? I find that one a
>little hard to swallow.
>
>In any case, I think you're making quite a stretch to over sell java.

I do not work for Sun, and I'm not trying to sell Java. I do not even like Java
because I consider the language to be fundamentally flawed.

Java did not start in 1995. Java started as Oak sometime in the early 90's or
late 80's. In 1995, the HotJava browser was written in Java. This attracted
attention, and it lead to Java becoming a significant language.

If you read the C standard carefully, the size of short, int, and long were not
defined when Kernighan and Ritchie worked on it. The int datatype is meant to be
the optimal machine datatype, not necessarily 32-bits or whatever.

Traditionally C/C++ compilers on IA-16 used a 16-bit short, 16-bit int, and
32-bit long. On IA-32, they used a 16-bit short, a 32-bit int, and a 32-bit
long. GCC uses long long for a 64-bit datatype, and VC uses __int64. When I last
used Watcom and Borland, they did not support 64-bit integers at all.

The fact here is that compiler writers are not stupid. They pay attention to
language elements that are heavily used. They spend their time optimizing
frequently-used constructs. Profiling an application for hotspots is the same
idea.

As a result of lack of support, lack of portability, and lack of general
usefulness, native 64-bit datatypes in C aren't heavily used. Even then a lot of
programs choose to emulates 64-bit math with native 32-bit datatypes. Java is a
different story. When you define types to be a specific size, people will rely
on that. The use of 64-bit types will encourage compiler-writers to produce
efficient code.

-Matt



This page took 0.02 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.