Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 14 of 14
Originally Posted by olivia Just for the sake of curiosity, why is this a problem? I could understand that the opposite situation is causing problems but I don't know about ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,452

    Quote Originally Posted by olivia View Post
    Just for the sake of curiosity, why is this a problem? I could understand that the opposite situation is causing problems but I don't know about this one. If anyone can explain me briefly or suggest a site with some explanation it would be great. On net I just found what you have to do to fix the problem, but no why.
    Writing code that is consistent on both 32-bit and 64-bit systems is a little like writing code that can run on many different operating systems. You need to think about the differences in architectures and code accordingly. This usually means that you will define primitive types that are appropriate for all supported systems, such as uint32_t, uint64_t, int16_t, etc. I have been writing software that is cross-platform for 32-bit, 64-bit, big-endian, little-endian, Unix, Linux, Windows, ARM, etc for many years that has to build/run identically on all such systems. This isn't hard, but it isn't easy! It just takes planning and consideration of the issues involved. Example: I had to write a string hash function that would work identically on all systems and result in the same value on all. So, when operating on big vs little endian machines, the algorithm had to do some nibble swapping to deal with the situation. The result? Calling the string hash function on a Windows PC (32-bit), Unix system (32-bit or 64-bit, big or little endian), etc would result in the same value. Why was this important? Because the hash values were needed to look up data in external hash tables and would work on ANY supported system.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  2. #12
    Just Joined!
    Join Date
    Dec 2009
    Location
    California
    Posts
    98
    Rubberman is correct.

    The problem is that the closer you get to the hardware, the more work there is for the programmer to do. If you think C is bad, you should try assembler. If you really don't want all the headaches of writing portable code in C, then switch to something like java. Java hides the hardware implementation from you and you (generally) don't have to worry about word sizes or byte ordering.

    I used to teach a class on advanced programming in UNIX where we wrote programs that communicated via pipes, message queues, shared memory, and finally sockets (both UNIX and INET domain sockets). Once a few of the more advanced folks had their INET socket programs running, I would tell them to make them work between Linux on Intel and Sun Solaris. That usually slowed them down for a few hours while they figured out Endian formats and the set of library calls needed to insulate the program from those formats.

  3. #13
    Just Joined!
    Join Date
    Aug 2012
    Posts
    5
    Ok, thanks guys for the answer. You see part of my work needs programming, and that wasn't my major, to be honest I had only one exam about programming. So I'm learning now. I would really like to know all the details, and it would be great if you can recommend me a book or something like that, or to suggest a way of improving myself in programming.

  4. #14
    Linux Newbie Syndacate's Avatar
    Join Date
    May 2012
    Location
    Hell..no literally, this state is hell..
    Posts
    192
    Quote Originally Posted by olivia View Post
    Ok, thanks guys for the answer. You see part of my work needs programming, and that wasn't my major, to be honest I had only one exam about programming. So I'm learning now. I would really like to know all the details, and it would be great if you can recommend me a book or something like that, or to suggest a way of improving myself in programming.
    I'm sure in academics people can suggest books all day long, but I don't think they'll do the trick. They might be a good foundation, but that's it, IMO. You really start to learn how to develop once you've read resources, then actually have done it. Just reading about it doesn't particularly help you, it's the "doing it" that helps you, IMO.

Page 2 of 2 FirstFirst 1 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •