- What is the difference between building a .NET project to target 32-bit or 64-bit?
- Are there computers that aren't able to run 32-bit programs and only 64-bit?
- Do x64 programs run twice as fast?

- 213
- 1
- 12
-
12Duplicate of http://stackoverflow.com/questions/607322/what-are-the-advantages-of-a-64-bit-processor, which I unfortunately can't flag because it's on SO, not Programmers. – Mason Wheeler Mar 03 '11 at 19:19
-
Tangentially related minirant: I hate AMD for extending x86 to 64 bits (barely an improvement) when Intel had custom-designed Itanium for 64 bits. The performance difference was huge. But everyone took the easy path with backwards compatibility, and the rest is history. – Matthew Read Mar 03 '11 at 19:56
-
3@Matthew Read: Itanium failed spectacularly in the marketplace because the ISA was notoriously difficult to write compilers for. The HPC market had all but given up on it long before AMD introduced their extensions. – greyfade Mar 03 '11 at 20:24
-
4@Mathew you could say that about Intel! If it wasn't for backward compatibility we would be working on CPUs with sane instruction sets and network byte order – Martin Beckett Mar 03 '11 at 20:24
-
3@Matthew: Have you ever looked at the Itanium instruction set? What a nightmare! Moving instruction scheduling out to the compiler was a Bad Idea. If you want a good 64-bit model, look to DEC's Alpha. – TMN Mar 03 '11 at 20:26
-
3@Mathew, do not underestimate the importance of a platform being backward compatible. – Mar 03 '11 at 20:58
-
2@Mason - that has been happening a lot lately. I suggest going to SO and flagging all these questions to be moved! – Nicole Mar 03 '11 at 21:19
-
@MasonWheeler For duplicates on both SO and Pro, I flaged both with a reference back to the other. The mods fixed it. – Guy Coder Sep 16 '12 at 13:03
-
Code runs faster in 64bit systems. – Badar Sep 16 '12 at 14:16
-
@Badar - not necessarily, without clever cache optimisation by the compiler a lot of code would run significantly more slowly. – Martin Beckett Sep 16 '12 at 20:34
-
Question 2: Any iPhone for ages, any modern Mac. 3. If there is one single 32 bit app left, it will eat up tons of resources because 32 bit versions of libraries and frameworks need to be pulled in. – gnasher729 Oct 04 '20 at 07:01
3 Answers
The only real difference you'd notice when using a HLL is going to be code size, and discovering that some features/libraries aren't available for x64 yet. Oh, and x64 code tends to be less performant, at least under .NET. The app I'm working on runs about 20% faster when I compile for x86. I don't know if it's because I use more bus bandwidth moving 8-byte quantities around, or if there's some "chunking" going on to adapt 32-bit APIs to 64-bit.

- 11,313
- 1
- 21
- 31
-
11Not so much the bus bandwidth of the moves as the fact that if you deal with 64-bit quantities vs. 32-bit, you've effectively cut your cache sizes in half. – Brian Knoblauch Mar 03 '11 at 20:39
-
-
3Particularly with reference-heavy .NET where *everything* is a pointer (reference). – Dean Harding Mar 04 '11 at 00:00
At the level you are talking about (.NET) there is very little difference. When you are using completely managed code the JIT will automatically compile your code and it will work pretty much the same, with different performance characteristics. For some things it will be faster (processing a lot of data, data could be processed in 64 bit chunks, more registers available etc), and for others slower (64 bit data (ie pointers) is slower to load into the cache for starters, meaning more data and slower transfers from main memory).
You only really have to worry about the difference when you use unmanaged code. This blog has a good run down of the issues.

- 1,273
- 11
- 14
-
You don't have 64bit data unless you specify it. Pointers are promoted to 64bits, but ints and floats stay the same. Almost all 32bit systems support 64bit float (double), and many supported 64bit int (long long). 64bit also opens up the newer features, including more user visible registers. – Omega Centauri Mar 03 '11 at 22:31
-
@Omega, Pointers are data. They have to be moved in to the cache to be used. Running on 64 bit means that every reference or dereference could potentially move one or more of these in to the cache, and it also expands every object that contains references. But you are correct that the statement halves is incorrect. I will change that. Thanks. – Dominique McDonnell Mar 03 '11 at 23:33
-
In my experience pointers aren't very common. But I don't do OOP, and I had a really painful early experience with bad pointers, so I only use them when absolutely necessary. So IMO pointers don't take up very much address space. OTOH modern compilers generate lots of loop unrolling, loop peeling and special case code, so the code size can become quite large. – Omega Centauri Mar 04 '11 at 16:53
-
1@Omega, every time you reference a complex object instance in a managed language you are using a pointer under the hood. – Dominique McDonnell Mar 06 '11 at 22:22
The .Net Programs that will be written for 64bit systems will have larger address space, and so will be much faster than x86-32 bit based programs. Also latest .NET Language compilers produce much optimized code. JIT is also improved in recent years and now you can do Multi-core JIT optimization. Debuggers are also improved. Meanwhile, better and optimized code is produced for 64bit - based systems.

- 549
- 4
- 9
-
Not really. As the top comment referenced over a year ago, x86-64 has a vastly better register set and cannot be considered an "extension". Next, address space doesn't make programs faster. Then, their market share. 64 bits is currently leading, 32 bits the minority (Steam inventory, Aug 2012). – MSalters Sep 17 '12 at 13:27
-
This (http://en.wikipedia.org/wiki/X86-64) says X86-64 is an extension of x86. May be address space does not affect programs run slow directly, but can affect memory which will make program run slow. In 64bit systems development, you may have few more jobs but not a big figure. For job market don't just see advanced countries but take third world countries into countries too. For good reference, check out: http://arstechnica.com/features/2008/09/x86-64/. – Badar Sep 17 '12 at 14:11
-
2You're quoting a 4 year old article. There are virtually no 32 bits x86 processors produced today, in 2012, and that incldues the low-end CPU's aimed at third-world countries. – MSalters Sep 17 '12 at 14:15
-
In 3rd world countries, which is a large proportion of the world population, they use these system regularly. Even though new systems do come, but rate of purchase is not good as compared to mobile systems. – Badar Sep 17 '12 at 14:17
-
@Badar Doubtful. I see 64-bit processors for low and mid-range computers here in Latin America. I tend to agree 32-bit CPUs are gone, at least for desktops and mid-range laptops. – Andres F. Sep 17 '12 at 16:09
-
@AndresF. New systems do come in 64bit and looks ok. But not everyone is upgrading. Most people I have seen use P4 without 64bit or HT-enabled. People purchase new laptops and keep old desktops, and use both. Actually, this talk is not about the price of Processors, but Processor+OS+.NET Environment that can affect a program written in a .NET language. Please, read this the OP's Question. – Badar Sep 17 '12 at 16:52
-
@Badar Uh? Who talked about the price of anything? I just said there are almost no 32-bit systems that I can see in my country. Some rusty old desktops are still running 32-bit processors, but nobody actively targets them anymore. So you're wrong: 64-bit CPUs are definitely not "new", and their marketshare is huge. – Andres F. Sep 17 '12 at 17:28
-
-
I just talked about CPUs in terms of theory, just as I was talked at college. If you want to talk about Research, then I should tell you 128-bit systems are being researched and will be here soon. For example: The IBM System/370 could be considered the first simple 128-bit computer, as it used 128-bit floating point registers. – Badar Sep 25 '14 at 14:59
-
I will believe a CPU is 128-bit when it has 128 bit integer registers and a 128 bit address space. FP, MMX, SIMD, etc. registers have historically been larger than the "bitness" of a CPU for a long time. – Sep 25 '14 at 16:41
-
Heck, Intel is discussing AVX-512 already. 128 bits pointers (which is the really relevant bit) won't happen in our lifetimes. Not enough atoms on earth. – MSalters Sep 25 '14 at 19:51