aspose file tools*
The moose likes General Computing and the fly likes 64-bit and 32-bit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "64-bit and 32-bit" Watch "64-bit and 32-bit" New topic
Author

64-bit and 32-bit

Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1527
I opened up this thread after reading threads,

http://www.coderanch.com/t/561219/Servlets/java/Link-Apache-Tomcat

http://www.coderanch.com/t/561217/java/java/bit-bit

But I still want to know,

How does a 64-bit machine differ from 32-bit?

Is it hardware or software that is 32-bit and 64-bit?

Can I say OS is the only software that will be impacted by the machine architecture?

what does Rob mean when he says,


Unless you have to use native code you don't have to worry about 32-bit or 64-bit. Java code doesn't care about this.


while he also says,



I believe that on a 64-bit Windows you need a 64-bit JRE for Tomcat to work.



Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Why did to create yet another thread -- instead of following up on the previous one with almost the same subject?

Never mind, the other questions were slightly different...

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Akhilesh Trivedi wrote:How does a 64-bit machine differ from 32-bit?


64 bit machines are newer. They have wider data paths, wider registers, along with tons features not supported by the 32 bit machine (just because they are newer).

Akhilesh Trivedi wrote:Is it hardware or software that is 32-bit and 64-bit?


Both. Obviously, it is hardware.... but in order to take advantage of these wider instructions and stuff, you need new op codes, so it is software too. Interestingly, most are backward compatible, meaning you can run a 32bit OS on 64 bit hardware. The OS just won't use any of the 64 bit features.

Akhilesh Trivedi wrote:Can I say OS is the only software that will be impacted by the machine architecture?


Again. Yes and no. If you are running a 32 bit OS, then you have no choice, you have to run a 32 bit application (no choice). If you are running a 64 bit application, then in most cases, you can run either a 32 bit or 64 bit application. In general, it is best to recompile (assuming not Java of course) the application to take advantage of the 64 bit instructions.

For Java, there is no difference, the same class files will run on either a 32 bit or 64 bit JVM.

Henry
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Akhilesh Trivedi wrote:what does Rob mean when he says,


Unless you have to use native code you don't have to worry about 32-bit or 64-bit. Java code doesn't care about this.



Java uses class files. When these class files are loaded into a JVM, they are either interpreted, or just-in-time compiled to the native code. In the first case, it will be either a 32bit JVM or 64 bit JVM that interpretes it. And this same JVM will either compile it to 32 bit or 64 bit.

In order words, without changing the class files, it can be optimized for either 32 bit or 64 bit JVMs. With Java, you won't care. It just works. And works optiminally.

Akhilesh Trivedi wrote:while he also says,

I believe that on a 64-bit Windows you need a 64-bit JRE for Tomcat to work.



Not sure. There may be something in Tomcat that detects and configures. I never ran Tomcat on Windows, so will yield to Rob's experience.

Henry
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1527

Thank you so much Henry,
Actually I could not think on whether to continue or not to continue on the same posts. One was more about Tomcat and was lodged in Servlets, and diverting it further to a discussion on 32-bit or 64-bit... I thought better to keep things safe here. Few more queries,

Henry Wong wrote:
you can run a 32bit OS on 64 bit hardware. The OS just won't use any of the 64 bit features.


So running a 32-bit OS on 64-bit is same like running the same OS on 32-bit hardware?

I was in notion applications sit on top of OS. You mentioned about applications being 32-bit or 64-bit.
Where do we see these 'newer' things in applications? in APIs? like separate apis for 32-bit and 64 bits?

Henry Wong wrote:
For Java, there is no difference, the same class files will run on either a 32 bit or 64 bit JVM.
...
without changing the class files, it can be optimized for either 32 bit or 64 bit JVMs. With Java, you won't care. It just works. And works optiminally.


Do we have 32-bit and 64-bit java compilers too? Is there anything like my application compiled on one compiler (say 32-bit or 64-bit)may or may not run on the (say 32-bit or 64-bit) JVM?


Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Akhilesh Trivedi wrote:
Henry Wong wrote:
you can run a 32bit OS on 64 bit hardware. The OS just won't use any of the 64 bit features.


So running a 32-bit OS on 64-bit is same like running the same OS on 32-bit hardware?

I was in notion applications sit on top of OS. You mentioned about applications being 32-bit or 64-bit.
Where do we see these 'newer' things in applications? in APIs? like separate apis for 32-bit and 64 bits?


Basically, 64 bit OSes that support both 32 bit and 64 bit applications detects it as run time, and correctly maps it to the correct 32 bit or 64 bit shared libraries.

I don't know what you mean by "see" as the goal is to make the two versions behave the same -- just compiled differently. Ideally, 64 bit application should run faster as it is processing 64 bits at a time -- and the compiler is dealing with generating different codes for you.



Akhilesh Trivedi wrote:
Henry Wong wrote:
For Java, there is no difference, the same class files will run on either a 32 bit or 64 bit JVM.
...
without changing the class files, it can be optimized for either 32 bit or 64 bit JVMs. With Java, you won't care. It just works. And works optiminally.


Do we have 32-bit and 64-bit java compilers too? Is there anything like my application compiled on one compiler (say 32-bit or 64-bit)may or may not run on the (say 32-bit or 64-bit) JVM?


No. The java compiler just compiles java to java class files -- and there is only one version.

Henry
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Akhilesh Trivedi wrote:So running a 32-bit OS on 64-bit is same like running the same OS on 32-bit hardware?

Mostly yes. You are running the 64-bit machine in legacy mode. Which always enforces a number of restrictions. The big one is that a 32 bit machine is essentially limited to 4GB of memory. Once upon a time, that was a lot. Today, it is what entry level machines have, serious machines start at 8GB and go up into 64GB and much more.

Depending on details that vary, you may be doing things like wasting half your memory bandwidth.


Most "PC hardware" made in the past 8 or so years is all 64 bit. OS-X has always been 64 bit. Windows users are slowly starting to use 64 bit code.
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1527
Thanks Henry. By "see" I mean "feel". Where we-the application writers/programmers are affected or where do we 'feel' the difference.

I had a 32-bit hardware, I installed the one and only 32-bit OS, we had a compiler, we wrote applications, say in C. The application was compiled, (from english to opcodes/assembly), the os then took the opcodes and instructions were executed. This is how my program actually ran. Correct me, if I am wrong or missing something.

I then got a 64-bit hardware, I installed 64-bit OS. Now, where did things change? What is a 32-bit application? Do I write a "64-bit" application now? Or I still write the same application, but compiler checks and choses/upgarades to generating 64-bit opcodes.

You said for java, it is all taken care under the hood. In case, if I am not a java programmer and say a windows programmer, will I have to a make a choice on my coding-style for 32-bit or 64-bit? I presume, it would depend which kind of application I am writing, like device driver kind or something else.

Henry Wong wrote:
No. The java compiler just compiles java to java class files -- and there is only one version.


You mean one version of the class file or one version of the compiler from say 1.4 to till Java 7?

Pat Farrell wrote:
Thanks Pat, OS-X info was new to me. And probably windows has always been paired mostly with Intel.

Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Akhilesh Trivedi wrote:You mean one version of the class file or one version of the compiler from say 1.4 to till Java 7?


I am not Henry, but Java byte code files run on any later JVM. Its a design feature from the start. Your Java 1.4 output (.class files, or .jar files) will run fine on any JVM, old or new, 32 bit or 64 bit.

I don't believe anyone writes device drivers in Java. They are usually written in C, they are small, and have to be hardware specific. Java is all about being hardware independent.

Back when it was first released (1993 or so) Windows NT ran on three wildly different architectures: Intel 386/486, Dec Alpha, and Mips. But the Alpha and Mips market never took off, and over the years, Microsoft dropped support for non-X86 chips. This forced AMD to make its improved CPUs be backward compatible with Intel. During the first few years of this century, AMD's chips were flat out faster, in addition to being cheaper than Intel's. After a few years, Intel caught up, and recently has had the performance lead.

Naturally, as Intel caught back up, other issues came up. The rise of mobile platforms (smartphones, tablets, etc) means that pure performance is not the number one priority. These days, energy efficiency is critical for battery life. So the mobile world is all ARM chips, not Intel. Microsoft has announced that Windows 8 will run on ARM architecture.

The sooner the Intel X86 architecture dies completely, the better, IMHO.

Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1527
Oh thanks Pat, I also have almost same picture of Java on being hardware independent.

I first heard AMD in 2003 or so, until then everyone around purchased and also suggested, intel processor with windows OS. Which processor? Intel, what is latest? Pentium was the answer. I think pentium 5 was at peek and just then, AMD processors were around. My friends had AMD as 'next' choice immediately after intel. In those days, desktops were too few, today though desktops are cheaper, people prefer laptops, unless you are a die-hard gamer. There is a gaming-center at a distance, and whenever I am there, I see cartons of graphic card and processors lying around, and they are mostly AMDs.

Pat Farrell wrote:
The sooner the Intel X86 architecture dies completely, the better, IMHO.


If you are talking about X86 architecture, I don't know, but if you are talking about Intel, I think that will never happen unless something rash happens.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Akhilesh Trivedi wrote:If you are talking about X86 architecture, I don't know, but if you are talking about Intel, I think that will never happen unless something rash happens.


More than a decade ago, maybe 15 or more years ago, Intel knew that the X86 architecture was not scalable for the future. That is why they jumped to Itanium. But that failed, so they stuck with X86. AMD was crushing them. Good thing for Intel, they were making cubic dollars on their chips, so they put effort in and made them faster.

Faster is no longer the game. Low power is the game, and Intel doesn't yet have a play in that space. They know it. But to win, they have to throw away X86, and that is hard when you are making billions selling X86

How is this for rash: the PC is dead. No one cares about PCs anymore. Mobile is the future.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 64-bit and 32-bit