Thread: What does it mean for a library to be portable?

  1. #1
    Registered User
    Join Date
    Apr 2010
    Location
    Vancouver
    Posts
    132

    What does it mean for a library to be portable?

    For example someone told me that Qt is a portable library for developing GUIs that keeps the appearance the same across platforms.

  2. #2
    Registered User
    Join Date
    Mar 2010
    Posts
    583
    I disagree. I think "portable" is about being able to rebuild your C/C++ source code unmodified on a different platform/OS. E.g. don't use Windows-only library functions, don't assume pointers are 32 bits, etc.

    Qt is cross platform -- it's supported on loads of platforms, architectures and operating systems. You *would* have to recompile the binaries if you moved between platforms though.

    Quote Originally Posted by Qt website
    Qt is a cross-platform application and UI framework. Using Qt, you can write native and hybrid applications once and deploy them across desktop, embedded and mobile operating systems without rewriting the source code.
    This is a very useful thing!

    The only realistic way you can get around platform dependencies is to run on top of a virtual machine -- like Java does. That has its own problems (large runtime needed, debatable performance (I say Java programs perform horribly - but Java zeolots have assured me that I'm imagining it)).

    Quote Originally Posted by c_weed
    For example someone told me that Qt is a portable library for developing GUIs that keeps the appearance the same across platforms.
    Not exactly. For example, the standard "open file" common dialog looks different between platforms. Last time I used Qt (about 7 years ago) it seemed to be a bit ranodm as to whether you'd end up with an OS standard file open dialog or a Qt non-OS-specific one. I'll consider this problem "fixed" if they now always use the OS dialog -- so identical GUI isn't always a good thing IMO.

    Qt provides a bunch of other stuff too like threading and socket support - other things it's good to have a cross platform version of.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by smokeyangel View Post
    Java zeolots have assured me that I'm imagining it
    those still exist? I see nothing in java about which to be zealous.

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by smokeyangel View Post
    I disagree. I think "portable" is about being able to rebuild your C/C++ source code unmodified on a different platform/OS. E.g. don't use Windows-only library functions, don't assume pointers are 32 bits, etc.

    Qt is cross platform -- it's supported on loads of platforms, architectures and operating systems. You *would* have to recompile the binaries if you moved between platforms though.
    I'm not sure I agree with your definition of portability, but never mind. Assuming Qt to be "cross platform," what it does enable is portable GUI programs. The clients who use Qt gain portability by using it -- you *can* just recompile on another platform, at least if you're using Qt the right way and not making non-portable assumptions of your own.

    The same can be said of the C library itself. It is not itself portable (its whole purpose being to interface to an arbitrary OS), but it enables portability in the programs which use it.

    At some point all code which does anything useful to human beings has to interface with something that isn't standardized. The question is at what layer that interface occurs.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    583
    Quote Originally Posted by Elkvis View Post
    those still exist? I see nothing in java about which to be zealous.
    Mmmm! A guy a few years back nearly convinced me that Java was faster than native code - he was just so determined. Then I went back to my desk and started Eclipse, and... no. To be fair though it might be wonderful to program in - I've never done anything "real" in it.

    Quote Originally Posted by brewbuck View Post
    I'm not sure I agree with your definition of portability, but never mind.
    Fair enough -- I think it's debatable. The source of all truth Wikipedia says that a "portable application" is one that can be moved between systems, and "software portability" is the ability to recompile.

    Qt is definitely the latter, but as you say, so is the C library.

    Assuming Qt to be "cross platform," what it does enable is portable GUI programs. The clients who use Qt gain portability by using it -- you *can* just recompile on another platform, at least if you're using Qt the right way and not making non-portable assumptions of your own.

    The same can be said of the C library itself. It is not itself portable (its whole purpose being to interface to an arbitrary OS), but it enables portability in the programs which use it.

    At some point all code which does anything useful to human beings has to interface with something that isn't standardized. The question is at what layer that interface occurs.
    Indeed, well put!

  6. #6
    Registered User
    Join Date
    Apr 2010
    Location
    Vancouver
    Posts
    132
    So in a sense if the objective is to make a GUI that appears the same on all OSs Java may be the better option than using Qt?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Portable binary file I/O library attempt
    By lost_in_code in forum C Programming
    Replies: 12
    Last Post: 07-09-2011, 04:34 PM
  2. HTTP with Portable Component Library
    By karas in forum C++ Programming
    Replies: 1
    Last Post: 02-27-2006, 10:28 AM
  3. Replies: 3
    Last Post: 09-01-2005, 11:47 AM
  4. What's a portable graphics library?
    By dwks in forum Game Programming
    Replies: 2
    Last Post: 07-06-2005, 03:13 AM
  5. Portable Audio Library
    By CornedBee in forum C++ Programming
    Replies: 2
    Last Post: 05-19-2005, 02:09 AM