Skip to main content
GameDev.net gamedev.net
🔒 Locked

Programming Difference in 32 vs 64 bit

Started by Mas0n Jul 27, 2005 at 3:06 PM 16 replies 4.4k views
Original Post
Mas0n
Mas0n
I've been reading the book C++ Primers 4th edition for a while now. The whole book never goes into Win32 stuff. I really don't know much about it at all so bear with me. Will there be a difference between 32 bit and 64 bit programming wise, when Microsoft's new os comes out. Because I heard Longhorn is going to be 64 bit. Does that mean we would be programming in Win64 bit or something lol? I'm extremely clueless to all of that because I have never programmed in it before. Sorry for asking stupid questions but I would like to know :). Thanks, Mason [Edited by - Mas0n on July 28, 2005 1:33:57 PM]
Marmin
Marmin
The Free Pascal compiler (AMD64 version) seems to operate the same as the 32 bit version. For C++ compilers, I wouldn't know.
Pure asm programming, yes there would change a lot..
JoshM
JoshM
You can find just about anything you want to know about windows programming on www.msdn.com.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win64/win64/getting_ready_for_64_bit_windows.asp

Some highlights:

"only pointers expand to 64 bits; all other basic data types (integer and long) remain 32 bits in length."

"Initially, most applications that run on 64-bit Windows will have been ported from 32-bit Windows. It is a goal that the same source, carefully written, should run on both 32- and 64-bit Windows."

Do not cast pointers to int, long, ULONG, or DWORD.
Use the PtrToLong or PtrToUlong function to truncate pointers.

etc...
Mas0n
Mas0n
Thanks, I was looking for something like this. I was reading and I came upon this.

"The result is simplicity and a short learning curve for the developer—writing code for 64-bit Windows is just like writing code for 32-bit Windows."

So basically it's extremely similar to 32 bit, just a few things like the pointers you were talking about. The reason I asked this is that I wanted to be sure that I should learn windows api instead of wasting my money buying a soon to be outdated book.

Right now, I really don't know much about win32 or any of that stuff, but its considered win32 api programming when your using headers like windows.h and winnt.h right? So if I bought a book on how to learn win32, I wouldn't be wasteing my money seeing as how 32 & 64 bit are very similar.

I hope this all makes sense, thanks :)

Thanks,
Mason
gosper
gosper
Everything will stay mostly the same for high level language such as C++. The only difference will be when when programming in ASM.
Name_Unknown
Name_Unknown
There are some differences in Win32 and Win64, if you compile with the 'detect 64-bit issue' it will tell you what they are. Mostly it is the size differences, 64-bit windows uses 64-bit pointers for handles and things. Have not written a 64-bit windows app so I can't tell you what else.

In C/C++ i believe microsoft compiler is leaving int as 32-bit and long will now become 64-bit, which is going to be a pain if you have alot of old code that assumed long was 32-bit.. other than that it shouldn't be a big difference if you didn't assume the sizes of things.

WinNT was 64-bit on Alphas and Itaniums I think so it is not the first Win64, I have a book on Windows 2000 that mentions Win64 programming it is about 5 years old too.
"It's such a useful tool for living in the city!"
Mas0n
Mas0n
Yeah thanks for all the responses guys. Once I finish this book I'll most likely move onto win32 api. I don't have a 64 bit computer so I'll just learn win32 for now. Once Longhorn comes out, I'm going to buy a new computer seeing is how the processor I want is around 700 dollars alone :(.

Thanks,
Mason
ext
ext
ext
ext
I heard Longhorn will support the winapi and directx but with Longhorn the new api will be NET2 and there will be a new Version of DirectX( version 10) with a new name and structure.
Microsoft will still support the old APIs, but there'll be new ones, too.

Monder
Monder
The replacement for Win32 in Longhorn is WinFX which is a .net API. The new name for DX will be WGF (Windows Graphic Foundation) AFAIK.

Mas0n: Once you've finished your book I'd advise doing something other than learning the Win32 API. I think there's little point in learning it as it's old and getting replaced by newer things (e.g. WinForms) and you'll probably never need to use it. Your time could be better spent on other areas.
Ivo Leitao
Ivo Leitao
Quote:
Original post by Monder
The replacement for Win32 in Longhorn is WinFX which is a .net API. The new name for DX will be WGF (Windows Graphic Foundation) AFAIK.

Mas0n: Once you've finished your book I'd advise doing something other than learning the Win32 API. I think there's little point in learning it as it's old and getting replaced by newer things (e.g. WinForms) and you'll probably never need to use it. Your time could be better spent on other areas.


The problem is that windows form will be replaced by Avalon in the Longhorn. We are right now in the middle of a big technological change in the windows api's...

Mas0n
Mas0n
Monder: "Once you've finished your book I'd advise doing something other than learning the Win32 API. I think there's little point in learning it as it's old and getting replaced by newer things (e.g. WinForms) and you'll probably never need to use it. Your time could be better spent on other areas."

Oh, see thats what I was worried about. Ok so I should avoid learning windows programming until longhorn comes out. What is a good thing to do after I finish this book. Right now I'm reading C++ Primer 4th Edition.

Thanks,
Mason
ext
ext
You can learn a platform independent GUI Api instead, for example wxWidgets, gtkmm or QT
Spoonbender
Spoonbender
Quote:
Original post by Monder
The replacement for Win32 in Longhorn is WinFX which is a .net API. The new name for DX will be WGF (Windows Graphic Foundation) AFAIK.

Mas0n: Once you've finished your book I'd advise doing something other than learning the Win32 API. I think there's little point in learning it as it's old and getting replaced by newer things (e.g. WinForms) and you'll probably never need to use it. Your time could be better spent on other areas.


I agree, although for a different reason.
Once you finish a C++ book, you're just not ready to start learning an API like Win32 (or anything else, for that matter)
When you finish your game, you should spend ages making text-based programs. The important thing is to learn C++ properly. Not just in the "I've read and understood a book"-sense, but the "I know the language, and I could essentially solve any problem using this"-sense.

You need to get to the point where you just don't care whether you have to use Win32, WinFX, OpenGL, SDL or any other API, because you know it's just a matter of calling a few differently-named functions, and all the logic in your program will be the same anyway.

Starting on learning any API before that, will just end up frustrating you, because you don't really understand what's going on under the hood, and so you have no clue how to fit it all into your code, or what to do when there's no tutorial telling you exactly what to write.
Mas0n
Mas0n
Yeah, I understand that too. I should've probably reworded how I said that. I've already started working on text based games. I just finished tic tac toe yesterday. I sumed up all the things I learned such as subscripting n such and made the game without help from the book. This way I actually know what I should be using when a problem comes along. I probably will end up waiting till longhorn comes out before I go onto win32, but I think that I will need a new book before its released, seeing how i still have a year n half to go.
Plasmadog
Plasmadog
There's no point avoiding learning something just because something else will come along later. If you do that you will never get around to anything because there's always something new on the horizon. Learning anything related to programming in Windows will be of some benefit later, even when the API changes.

Hell, I reckon learning anything about any API will have some benefit later, because the more APIs you have experience with, the easier it is to learn a new one.
You are not the one beautiful and unique snowflake who, unlike the rest of us, doesn't have to go through the tedious and difficult process of science in order to establish the truth. You're as foolable as anyone else. And since you have taken no precautions to avoid fooling yourself, the self-evident fact that countless millions of humans before you have also fooled themselves leads me to the parsimonious belief that you have too.--Daniel Rutter
first_log
first_log
First, 64 bit programming in windows is only somewhat related to the windows api. The win32 api is a set of function calls to the underlying windows operating system that allows you to do things like create threads, processes, and mutex (mutii, mutexen, mutexes?). 64 bit programming includes greater memory addressing and things like an increase in pointer size.

So it seems that you could keep the api interface mostly the same while having a 64bit environment.

Of course the windows api will probably change with a new version of windows, but I doubt that microsoft is going to completely throw away years of development. The interface will undoubtedly change. The interface is what you will see, it is the name of the functions that you will call and their parameters and return types. Even though that may change, many of the fundamental concepts like threads and inter process communication will stay the same.

As a short answer, I dont think it is a waste of time to learn the windows api, even though it will certainly change in the future. The concepts that you will need to learn to use it will serve you for as long as you are programming. Learning the api will involve a lot of reading about operating systems. I recommend that you buy an operating system book next if that is what you are interested in. I don't mean a "Programming windows" book, I mean a generic overview of operating systems, what they are, how they work etc. If in doubt find a college OS class website and get that book. It may be expensive but it should contain a good overview of OSes and include windows and unix excercises using their respective apis.

Check out http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/windows_api_reference.asp

Second, after completing an introductory c++ book I would recommend what a previous poster said, and that is to really learn the language. Write programs, any programs. Learn to use the debugger. Stepping through the debugger will teach you more about your code, your language, and the way computers work.

Think about your program and how hard it would be to add a new feature or change the way something is represented. What if you used a linked list instead of an array? Would you have to rewrite dozens of lines of code? Begin to think about how the pieces of your code interact, what they depend on. I find that the languages themselves are not so hard to learn given enough time, it is the design of software that is the tricky part.

Lastly, these are some topics that I would consider indespensible for any programmer in order of decreasing importance.

A language which you have started on and all that includes. I/O, memory management, control structures. My personal opinion is that Java is easier to learn and a lot less work, but c++ will really teach you about what is going on inside the computer.

Data structures, arrays, linked lists, queues, maps... Any program has tons of them. What are the tradeoffs? When do you pick a list over a vector?
A gui toolkit and event driven programming.
Any api to get used to working with them. Win32, a gui, graphics api...
Design patterns will blow your mind.

Maybe this all seems like a lot of work, and it is, but its worth it. If you enjoy programming and learning the hours at the computer will fly by.

Good luck.
Mas0n
Mas0n
So learning the Os that I am programming for would be a wise decision? Well if I was to do that, once again wouldn't I have to wait for longhorn to be released since how the os works is going to change. I'm sure it won't be changed dramatically, but I'm not exactly sure what to think.

Imo, by the time im done reading this book, I'll most likely spending a long time learning how to use what I learned to make text based games and apps like posted earlier. I need to take in all the elements I've learned and figure out how to use them like how first log was saying, should I use a vector, or an array kind of thing. I've already made decisions like that when I made tic tac toe. I decided to use an array because I knew it was a fixed size and that an array was faster. Other times, vectors might be more useful.

It's a tough decision if I should learn win32 api because I have people saying its a good programming experience and that win32 is gunna be nearly the same when 64 bit comes out, but I have a few saying otherwise. My thought is, is that win32 will be a good experience in coding in general. I'm still not exactly sure.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.