Slashdot Mirror


Applications and the Difficulties of Portability?

insane_coder asks: "I'm a software developer who writes a lot of freeware utilities in C/C++ which are all cross platform and work well. Lately some of my users have been pestering me to stop wasting precious development time supporting minority OSs like Linux, and get more work done for the majority — the Windows users. Now all of my utilities are simple tools that perform various operations on files such as compression or rearranging. I've also made a few frontends for them using the excellent Qt library to allow the user to select a file and process using a simple GUI. In the dozens of applications I wrote, most of them several thousand lines long, I haven't written a single conditional for any particular OS. When I release, I just compile each app for all the OSs I have access to and post them on my website. I barely expend any effort at all to achieve portability. So the question I have to ask is: Why do the masses perceive portability as something that requires effort and a waste of time?" "Most applications don't do anything fancy or need to talk to devices and therefor there is no need to do anything special other than compile them on a particular OS to run on that OS. So why are there so many simple apps using native APIs to do simple things like file reading instead of the standard ones? Why are we projecting an image that one must go out of their way or switch to a different language in order to achieve portability?"

32 of 145 comments (clear)

  1. It's Windows development tools by Todd+Knarr · · Score: 4, Insightful

    It's the Windows development tools. By default they generate code that uses tons of Windows-specific APIs that aren't portable to anything but another version of Windows (and sometimes not even then). If you start with OS-specific code, then yes supporting other OSes looks difficult. Combine this with Microsoft's business need to make portability look as difficult as possible to discourage developers from aiming for it and the results are predictable.

    1. Re:It's Windows development tools by borfast · · Score: 5, Interesting

      Exactly. Add to that some ignorance from those people who say it's difficult to write portable code (perhaps because they have only ever been exposed to that confusion of code generated by MS tools) and you get a mass of people who are willing to sacrifice the minorities for... well, for nothing, really, because they won't get anything more than they already do - but they don't know this. They think that dropping support for other platforms will allow the developer to focus more on the functionality or stability of the software.

      And these people are not necessarily your average fresh-out-of-school programmer. Sometimes even people with several years of experience fall into this category and refuse to work on cross-platform code because they say "it consumes more resources". An example I have dealt with recently is Garage Games and their Torque line of products.

      Garage Games makes game engines and they used to announce on their website that their game engines run on Windows, OS X and Linux. Long story short, the Linux version is far from the quality of the Windows and OS X counterparts (when it runs at all) and the company dropped Linux as a supported platform, "because it consumes too many of their resources". Instead, the Linux version is now supported by the community - but it bears the same price tag, nonetheless...

    2. Re:It's Windows development tools by radtea · · Score: 5, Interesting

      It's the Windows development tools...Combine this with Microsoft's business need to make portability look as difficult as possible to discourage developers from aiming for it and the results are predictable.

      Amen.

      I write only portable code (currently very happy with wxWidgets, and have used Qt in the past) but MS fud is so thick that I have at times had to convince clients that using platform-neutral code would be faster than an "all Microsoft solution."

      I've also encountered an amazing number of developers who have no real interest in writing good software. They simply want to do things the easiest way possible that requires the least thought, and MS caters to those people and always has.

      There is a delightlful ancedote told in a book by one of the guys who was deeply involved in the first Visual C++ release (the old C7.) At the time Borland owned the C++ compiler market on Windows, and MS was playing catch-up big time. The marketing people realized that the technical goodness and standards-conformance of the Borland compiler was only of interest to a small core of die-hard techies. The much larger market was C programmers who wanted to be able to call themselves C++ programmers. Thus were the Visual C wizards born. They made it easy for people who had no clue to create "classes" and pretend to get it (while putting everything into a single procedural method.) I wish I could recall the name of the book--it was one of the most unselfconsiously arrogant memoirs I have ever read.

      One response to the false belief that cross-platform code is not cheaper than single-platform code is to make the point that writing cross-platform code is quite different from porting code from one platform to another. Another is to remind people that we are dealing with Turing complete machines, so all functionality is always available on all platforms. This isn't actually relevant, but it will shut people up who don't know what they're taking about, and if we have anything to learn from MS it is that substance and quality mean nothing when put alongside a catchy argument.

      --
      Blasphemy is a human right. Blasphemophobia kills.
    3. Re:It's Windows development tools by achacha · · Score: 2, Interesting

      There are too many things you give up when writing portable GUI code, Qt is ok, wxWidgets is ok, Swing is ok, AWT sucks; using native GUI elements is by far superior. For example, to write a windows app that uses dockable floating toolbars that are easily customizable and contain custom controls within them is relatively trivial with windows and extremely painful if not impossible with ohers because such behavior is not native on other OSs. While you can get portable GUI apps to be very functional, it requires more work to extend the lowest-common-denominator tools.

      In the end it is not a question whether it can be done but rather how much work will it take to make it very usable and portable at the same time. I did it for a small app that ran on Windows, OSX and KDE as expected, looked a bit off on Gnome, then after getting Gnome right, OSX controls would not align, and so on. Eventually I just gave up with having to maintain 4 different VMs just to validate things work and now I just stick to WinXP/200x and work more on developing and less on making things portable. It's a matter of preference.

    4. Re:It's Windows development tools by N3Roaster · · Score: 2, Informative

      Have you taken a look at Qt recently? If I'm understanding your example correctly, that's fairly trivial in the Qt 4.x series as well. You can even customize them with CSS-like stylesheets.

      --
      Remember RFC 873!
    5. Re:It's Windows development tools by petard · · Score: 2

      You mean like this, available in C++ and Python for Windows, Mac and Linux?

      --
      .sig: file not found
    6. Re:It's Windows development tools by insane_coder · · Score: 2, Interesting

      I wrote some complex GUI code with Qt, and found it much easier than any APIs I saw for Windows. From what I've seen, it requires less work to use Qt.

      Overall I see Win32 API is just complex. I once was reading up on MSDN about how one would go about processing stdout from a child application. They presented like a 50 lines solution using many tricky looking calls. I ended up writing functionily identical code using POSIX functions like dup2() and fileno() (which Windows in fact does support right out of the box), in a dozen simple lines, and it was portable to boot.

      --
      You can be an insane coder too, read: Insane Coding
    7. Re:It's Windows development tools by segin · · Score: 2, Informative

      The POSIX subsystem is used by nothing but Services for Unix, and SfU applications cannot use native Win32 functions.

    8. Re:It's Windows development tools by A+beautiful+mind · · Score: 2, Insightful
      Add to that some ignorance from those people who say it's difficult to write portable code (perhaps because they have only ever been exposed to that confusion of code generated by MS tools)
      There are levels of portability and I wouldn't especially call code written for Windows, linux , osx/bsd "portable". Personally I think that portability has a natural tendency to emerge from already well written code. Most of what you call not portable is _downright stupid_ generally. Well, in most cases. Portability is very much similar to robustness. Things like, not assuming line ending to be "\n", etc.
      --
      It takes a man to suffer ignorance and smile
      Be yourself no matter what they say
    9. Re:It's Windows development tools by truedfx · · Score: 2, Informative

      In many languages, notably including both C and C++, line endings are always "\n". Even on Windows. All you have to do to make your application portable to Windows is make sure you open text files in text mode, and not in binary mode. The standard library will then make sure to change line endings as necessary if they are not externally represented the same.

    10. Re:It's Windows development tools by Todd+Knarr · · Score: 2, Informative

      It's Posix-compliant at the most minimal level. When Microsoft designed the subsystem, it had one goal: be able to check off the "Posix compliant" item on the government purchasing checklist. It did not want Posix apps developed, because that would be against Microsoft's business interests, but it needed that compliance to technically qualify for government contracts. So it implemented the absolute minimum it had to to get the minimal certification and no more. And minimal Posix compliance is minimal indeed, being aimed at embedded devices.

    11. Re:It's Windows development tools by Ramses0 · · Score: 2, Informative

      Might it be this one: Rapid Development by Steve McConnell?

      I remember that story quite vividly as well: "When doing market research, we realized that mediocre people didn't want a real C++ compiler, they just wanted C++ on the box and *.cpp file extensions so they could bill themselves out ($$$) as C++ programmers. We then spent the next 5 years fixing all of our dork-isms in the C++ compiler to bring it up to standards, but that didn't matter because we had already crushed our competition by making flashy-promises and code wizards and being first to market with a non-compliant compiler." (or something to that effect).

      --Robert

  2. Portability Isn't Hard by RAMMS+EIN · · Score: 5, Informative

    For the most part, portability isn't hard. You can write pretty much all the functionality of your software without getting into platform-specific issues. Generally, the higher the level of abstraction a languages is at (assembly C Python), the easier it gets. Of course, you do have to use standard APIs and avoid platform-specific ones (win32, GNU extensions, etc.) Things that have caused trouble for me in the past:

      - Sockets (BSD sockets vs. Winsock's almost-compatible variant); this is not a problem in most higher level languages
      - GUIs (there isn't really a standard; perhaps wxWidgets?)
      - Threads (POSIX threads vs. whatever Windows has)
      - Processes (fork, AFAIK, really doesn't exist on Windows)

    If I need any functionality that isn't readily portable, I usually target POSIX or BSD, which makes my code portable to many *nix variants, and Windows using Cygwin.

    Of course, there are also a whole bunch of cross-platform libraries out there, like glib, the APR, SDL, Qt, ...

    --
    Please correct me if I got my facts wrong.
    1. Re:Portability Isn't Hard by Twylite · · Score: 5, Informative

      I think you've identified on most of the major areas that cause portability problems, with the possible exception of endianness. Since I actively maintain software under Windows, Linux and Solaris, let me add some comments:

      If you're developing a GUI application then a decent GUI library will handle most of your problems. Libraries like wxWidgets and QT provide cross-platform GUI widgets as well as thread creation and synchronization primitives. They usually also provide socket abstractions, or you can use another cross-platform library like ACE.

      Things get more hairy when you enter the realm of server applications and high performance. Software written for *nix is pretty much straightforwardly portable to Windows, but not the reverse.

      The difference is in the schedulers, which affects processes, threads, synchronization, and blocking and non-blocking IO. In a nutshell the Windows scheduler deals with threads and not processes, is a fair scheduler, and a thread can block on multiple conditions simultaneously.

      That should be a lot to digest, so let me try to explain that statement and its implications:

      First a disclaimer: I am going to talk about *nix in generalisations, because both Linux and Solaris support a variety of schedulers and the default scheduler can change between versions, and userland and kernel threading libraries behave very differently.

      ONE: The Windows scheduler schedules threads. Processes are merely containers for threads and their address space, access tokens, etc. Processes are not scheduled. This means that a multithreaded process on Windows has fundamentally different time sharing characteristics to a *nix application. The characteristics would be most similar to a multiprocess application in the *nix world. Most *nix schedulers I have encountered schedule processes first, then schedule threads within the process.

      TWO: The Windows scheduler is "fair" -- it is a multilevel queue with round-robin at each level. Threads with a higher priority will always preempt those of a lower priority, and priority elevation is used to prevent starvation.

      A number of *nix schedulers use a n adaptive algorithm that favours historically busy processes. This means that a producer-consumer approach may work well on a Windows system, but experience high latency on *nix (note: not reduced throughput under load, but increased latency). Such an approach can work on *nix, but must be implemented differently.

      Both Linux and Solaris can be set to use round-robin schedulers (e.g. Solaris's real-time class process), but this can degrade overall system performance.

      THREE: A thread can block on multiple objects simultaneously. I said "conditions" before, but I'd prefer to get more specific. A Windows thread can wait for the end of another thread or process, a mutex, and event (like a condition in *nix), an IO operation, a semaphore, a timer, and a couple of others. The thread can also block under any one, or all, of a number of objects are in the signalled state.

      Compare that to *nix where you can wait on one of anything except for IO, where you can use select (or poll or dev/poll or kqueue) to wait on multiple non-blocking file descriptors. kqueue is a little more functional, but to my knowledge still doesn't support synchronization objects. If you are using SysV semaphores you can wait for multiple semaphores to be signalled.

      This has huge implications for application design. On Windows you can have a consumer thread wait on multiple producer threads using one mutex per consumer to control synchronization. All threads can be awoken from any wait state by a global event to inform them of reconfiguration, shutdown, etc. This is quite trivial, and is a straightforward and easily understood design.

      Move the same design to a *nix platform and you have problems. First your consumer thread can't wait on multiple producers without some radical changes (use could pipes rather tha

      --
      i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net
    2. Re:Portability Isn't Hard by sowth · · Score: 2, Insightful

      This is a big problem, and I think it is because many toolkits don't have generic functions. They require a developer to specify pixel locations, font sizes, or similarly low level things.

      A toolkit should ask for generic information and format it in the proper way for a given OS. You should not be indicating toolbars, menus and widgets. You should only need to specify what functions are made available and the name, icon, etc associated with them, the toolkit should put these into menus, toolbars, or whatever a user would expect. For dialogs, you should only need to specify the names of fields / questions and what is expected as the answer (a number, string, file, yes/no, etc) and what fields relate to the others. The toolkit should decide how the dialog is rendered. In fact many of these things are very common and should be included inside the toolkit. Yes all of them have file dialog boxes, but why not go a step further and integrate it into the menu? Just have a function which specifies a callback for say "open file" or "save file" and when activated the toolkit places the options in the appropriate places--the menu, toolbar, Alt-S hotkey, Ctrl-X/Ctrl-S seqence, on a disk widget for a 3d environment, wherever.

      Generalizing things in this way would allow programs to be made which work on text screens, 2d GUIs, 3d GUIs, braille/text to speech systems, audio only voice recognition/text to speech, web interfaces, and many more. All without special consideration or modifying the program. Yes, programs which require graphics (such as photo editing) would not work on a text screen, but the toolkit could just raise an error in that case or display ascii art if that is the user's preference. End application programmers should not have control of those things anyway.

    3. Re:Portability Isn't Hard by ctzan · · Score: 2, Interesting

      yes, you said fork() and fork() NEVER EVER worked as you describe.

      I supposed you were just mixing up vague recollections about vfork()
      and its limitations (sharing address space until execve(), etc) with
      vague recollections about copy-on-write pages in the child & stuff,
      and you were just confused by the whole thing.

      But no, you're deliberately spreading misinformation and don't
      care about that --

      Is it so humiliating to admit you're wrong ?

  3. Ugliness? by Tadrith · · Score: 2, Interesting

    I personally agree that if you're going to release something command-line based, it shouldn't matter at all. I myself am a software developer, and while my applications are not cross-platform, I certainly appreciate those utilities that are. In my case, what I'm doing is not simple and highly specialized, so cross-platform doesn't do anything for me except make more work for no reason. My applications are not things that anybody else would find useful aside from the people I am making it for.

    Most people, when they run an application on Windows, expect it to react in the same old Windows way. Many of cross-platform libraries do a poor job of doing that. I personally don't use GAIM because I can't stand the way it looks. Even though complaining about the ugliness of the GUI might seem stupid to some, it is a genuine problem with people. Clearly, it makes some form of different, as evidenced by the ever increasing "beautification" of window managers like KDE and Gnome.

    It may be that this bugs me more than most precisely because I am a developer. It may be that it bugs ordinary people even more. I have no idea. But I think that increasingly the transparency of external libraries would probably help gain them acceptance. The problem is made even worse by libraries that clutter up your system by popping up and asking you to update, or add entries in your menus that you'll never need, as a user.

  4. Java propaganda by Anonymous Coward · · Score: 2, Insightful
    So the question I have to ask is: Why do the masses perceive portability as something that requires effort and a waste of time?"


    Because all they teach in schools now is java. They have all bought into Sun's propaganda. The students don't know any better and believe what they are told.

    You are absolutely correct in your approach, well written C/C++ code will compile and run on just about any modern OS and results in the most efficient and fastest applications.

    Another reply above also makes a good point that too many people depend on libraries and third party code that is specific to their development platform. Depending on third party code and libraries is absolutely foolish, however the majority of programmers expect a free lunch when it comes to writing applications and expect someone else to do all the work for them, then wonder why things go wrong.

    You pose an excellent, yet rhetorical question and it illustrates perfectly the absurd redundancy of java which claims to be cross platform but really is not, all it does is waste system resources and ecourage you to depend on inefficient and probably broken classes written by other people.

    Don't change a thing about how you work, it is the right way to go no matter what the java zealots tell you.
    1. Re:Java propaganda by jonabbey · · Score: 2, Insightful

      You pose an excellent, yet rhetorical question and it illustrates perfectly the absurd redundancy of java which claims to be cross platform but really is not, all it does is waste system resources and ecourage you to depend on inefficient and probably broken classes written by other people.

      Where did this rant come from? The o.p. didn't mention or allude to Java at all.. it was a question about why people think that cross-platform development effort is hard/useless.

      Are you saying that people only think cross-platform development is hard because.. Java has clouded mens' minds? You're not really saying that, are you?

    2. Re:Java propaganda by insane_coder · · Score: 2, Insightful

      I wouldn't blame it solely on Java. Some of it may be that some C++ programming classes today won't even teach the standard file manipulation libraries such as fopen() or std::fstream, but instead teach Win32 API method to open a file.

      Regarding 3rd party libaries, depending on some of them is actually a good idea. The zlib library for example is indispensible, hence why almost everything uses it.

      As for what Java zealots tell me, just yesterday someone mentioned to me I should switch all my C++ apps over to Java because Java has a string library and I won't have to mess around with char arrays anymore. The new guys aren't even learning what C++ has, demonstrated by C++ having a string library very similar to what Java has, yet they don't even know about it.
      And with C++, if one sticks to std::string and the rest of the STL for the most part, all the "it's easy to leak memory" arguments are just a load of FUD. I regularly give my programs a full workout with valgrind and I'm happy to see that they don't leak a single byte of memory. Which in itself is a great reason for portability, valgrind doesn't exist on Windows, yet my Windows users benefit from it because they get solid applications.

      I really wish though there would be some way to get the new and/or clueless programmers to realize all of this.

      --
      You can be an insane coder too, read: Insane Coding
  5. Re:Ignore naysaying insects by abigor · · Score: 3, Interesting

    Well, using Qt obviously makes a huge difference. Not only is it an excellent toolkit, but they do a tremendous amount of work to make things portable, so writing cross-platform code becomes a piece of cake. That's also why KDE 4 (which will hopefully end up as the first, "real" Linux gui) will run on Windows.

  6. It depends. by Shados · · Score: 5, Insightful

    From the sound of the article/question, with their setup, it really doesn't seem like it is that big a deal to support multiple platforms. Plus, the knowledge is there, and they seem to enjoy it, its simple tools, etc. Why the hell not.

    Other environments (usualy very customer centric ones, let say consulting firms, with strict deadlines, marketing getting in the way, etc) and more complex applications with very specific needs, it becomes trickier. These are the environments where your job is hard even if you're only supporting one platform, and even using every single last specialised API the platform offers still let you wish for more. In those cases it becomes a bit more annoying to have to go with the lowest common denominator.

    Then add to that that users of different platforms -expect- different things. It isn't the end of the world to make something that works on both OSX and Windows, for example. But users of both platforms expect certain different things. I don't know the status right now ,but I remember even in Java a few years back, one had to add some specific arguments when running java apps so that the menu bar would be at the right place in OSX, otherwise it would end up more like KDE/WIndows/Gnome/etc, with everything inside the window by default.

    And last, but the most important one, testing, QA, etc. Doing cross platform, no matter what you do (unless you only do HTML and target Firefox only or something) means testing on those platforms, if only to look. That means moving the files, booting up the virtual machine, or something, to check it out. If the app is remotly complex, that IS time consuming like hell.

    So in the end, it really depends. If you release your app to the general public, then the advantages of cross platform often outweight the "cost", and its only a matter of time before we are -expected- to do it. When your audience is more limited though, you often benifit more from targeting one particular platform and optimising your workflow like crazy for it, the time saving is significant.

  7. third party interfaces by gfim · · Score: 2, Insightful

    I agree with what you say up to a certain point. But for anything complicated, there are always things that require some non-portable extension. The most common one I find is interfacing with third party software. On Windows, these often require the use of COM (or ActiveX, or whatever the flavour of the month is).

    --
    Graham
  8. So stop supporting the minority users! by emag · · Score: 3, Insightful

    I, of course, mean the "some" users who seem to think that they should dictate what platforms your freeware runs on. Really, there might be a valid argument if these people were paying you gobs of money on each release, but they aren't. Since it won't exactly hurt you financially, I don't see the issue with telling them to take a long hike off a short pier, or probably the better approach of "I'll give your suggestions the consideration they deserve. Thank you."

    Alternately, here's a money-making opportunity... "Whichever platform raises the most money by $DATE will be the one that's supported" :-)

    --
    "The urge to save humanity is almost always a false front for the urge to rule." --H.L. Mencken
  9. Ignore most of the replies by abradsn · · Score: 3, Insightful

    Basically, some people will say things like "Portability issues only happpen on Windows because of the use of Windows specific API.... and Linux somehow magically escapes this problem." I'm sure you are already aware that it is not true, because your code is portable and uses readily available libraries that do not vary in version, or in any major way at all from OS to OS. A buch of other people will say "All, code should be portable, because there is no reason for it to not be portable." And, I'm sure that from your post, this is the reasoning behind your question. So, here is a list of reasons that might help formulate an understanding of why some code is not portable... (bear in mind that a lot of my code is portable too, as that is usually indicative of good software practice) * Less portable code makes heavy use of API that is already written and tested inside the OS. * Less portable code can therefore be less expensive and quicker to produce. Depending on the circumstance this can be a long term and/or short term benefit. * Less portable code can be made to execute faster than portable code * Less portable code can be made to take advantage of hardware features that are only exposed through a specific API * Typically the most popular OS in the world is easier to program for by most programmers, thereby allowing everyone that is hired to get up to speed on the project more quickly. (Not a concern for a team of one) * Typically large projects need to make every advantage in efficiency that is readily available. This might or might not be dependant on the OS * Anything that has to do a lot of work with filesystems will need operating system dependant code to be written. There are faster file operation system calls for each specific OS. * Less portable code can be made smaller in size, by depending on libraries that are only available on a target OS. (As long as they are actually there!!!) For example in Windows you can take advantage of a bunch of API to change system settings like IIS settings, and smtp settings. In Linux you have to write code to manually change text files. Of course API are better here because then there is less chance messing up the format of the text file. And your code will work in the next version of the OS too. Your code will not work in the next version if you change the config files manually. In your case, you don't care because you are just writing little free utilities. In bigger enterprise level applications you need to care about things like this. There are many examples of needing to use API where-ever possible. More experience with bigger applications is the best way to get to this knowledge. Also, one final note. C is getting to be an old language now, and it is sad that any code written in C is not portable. Things that have been around that long, have workaround after workaround to make them keep from breaking. It almost requires effort to write C code that is not portable nowadays. Bad C code is still prevelant though. This is mostly due to the #define conditional that was included to make C a lasting language. It worked. Now let's be done with it. Moving forward, I would suggest a language that makes use of garbage collection as your next choice. Also, one with clean syntax and no workarounds already in place would be a good plan. These criterea make for a langauge that is more difficult to write stupid code in. If you ever have to maintain code, then these are good considerations. Here are some examples (in no specific oreder) Java, C#, PHP Here is a bad example C++

    1. Re:Ignore most of the replies by Sloppy · · Score: 3, Funny

      I didn't realize how hard portability could be, until today, when I found out that some platforms don't even let users break text into paragraphs.

      --
      As copyright owner of this comment, I authorize everyone to defeat any technological measure which limits access to it.
  10. Re:Because a lot of the time it's true by CableModemSniper · · Score: 2

    That's not what the code does though. cout i is like printf("%d", i). The only "portability problems" with the GGP post's code sample might be character encoding issues.

    --
    Why not fork?
  11. Hah! I have yet to see a decent port to MacOS by Blakey+Rat · · Score: 3, Informative

    Caveat: If your app is command-line, then this isn't really an issue. (Well, it still sort-of is, in that DOS CLI apps have different mechanisms for help than Unix ones, but we'll ignore those details.)

    The reason cross-platform is hard is because GUIs behave very differently from each other. To be a "correct" Mac OS program, you must support:

    1) AppleScript, at least the bare minimum actions.

    2) The Services menu. Many ported apps don't have it.

    3) The integrated spell checker. Most ported apps don't have it. Including biggies like Microsoft Office. (Needless-to-say, Firefox also doesn't support the integrated spell checker.)

    4) Verb dialog boxes. That is, no "yes/no" questions in dialogs, they must all be "Save" "Don't Save" (or similar.) In addition, the location of Ok and Cancel are different in different OSes.

    5) Drag&Drop, another simple feature the majority of ported apps get wrong. (Note: this includes drag&drop text editing as well as dragging snippets to the desktop.)

    6) Mac-like edit boxes. Here's an example ported apps almost always get wrong: if your cursor is at the bottom line, but in the middle of the text, and you hit the down arrow the cursor should move to the end of the bottom line. On Windows, it should do nothing. On Linux... well I have no clue if Linux has any standards for arrow behavior in edit boxes. (Firefox gets this wrong also, as do many, many apps.)

    7) Standard Mac menu shortcuts. This is pretty easy since other OSes ripped-off most of Apple's shortcuts anyway.

    8) Being responsive to sleep, hibernate and shut down requests from the OS. Every time I see OS X telling me that shutdown was cancelled because of some mis-behaving app I want to scream.

    9) Not relying on any absolute paths other than those defined by the OS. Lot of apps get this wrong.

    10) Using Apple's color picker, font picker, "Special Characters" picker, etc instead of your own. Many apps get this wrong.

    I'm probably missing items on this list. In addition, Windows has items on its list different from the Macintosh list. (For instance, coping with Active Directory, having an installer.)

    I can guarantee that your cross-platform framework gets at most half of these things right. The Java VM gets basically none of them right. Firefox gets like 3 of them right. The reason you think cross-platform development is easy is one or more of the following:

    1) You don't bother to QA your product on Mac/Windows/whatever. (This is the most likely.)

    2) Your programs have trivial GUIs and/or you don't give a whit about the quality of the GUI.

    3) Your programs are CLIs and have no GUI at all. (Note that if this is the case, they're still probably wrong on DOS, which is quite different from Unix CLIs.)

    Tell you what, the instant I see a single ported app to Mac OS X that actually looks and behaves like an OS X app, I'll eat my words and agree with you. But I don't think that'll happen.

  12. Portability has advantages, too by Dr.+Manhattan · · Score: 2, Interesting
    Of course, by developing code on multiple platforms from the start you quickly find all kinds of subtle bugs that come back to bite you later if you don't find them. A bit of memory corruption that causes a failure 10,000 cycles later on one platform, can cause obvious instant death on another. Write on one big-endian, one little-endian, and one 64-bit platform simultaneously and you'll find at least 80% of your memory bugs early on, usually more. Bonus points if one of them is like a SPARC and has alignment requirements.

    Also, portability tends to ecourage modularity, which helps isolate bugs and make them less likely in the first place, since the modules are smaller and easier to reason about than large chunks of code.

    --
    PHEM - party like it's 1997-2003!
  13. Reposting, formatted properly by SanityInAnarchy · · Score: 2, Informative

    I think you sent that as "HTML formatted" -- which gave me one big line of unreadable-ness. I haven't actually read it yet, I'll respond in a minute. Here's how I think it's supposed to look:

    Basically, some people will say things like "Portability issues only happpen on Windows because of the use of Windows specific API.... and Linux somehow magically escapes this problem."

    I'm sure you are already aware that it is not true, because your code is portable and uses readily available libraries that do not vary in version, or in any major way at all from OS to OS.

    A buch of other people will say "All, code should be portable, because there is no reason for it to not be portable."

    And, I'm sure that from your post, this is the reasoning behind your question.

    So, here is a list of reasons that might help formulate an understanding of why some code is not portable... (bear in mind that a lot of my code is portable too, as that is usually indicative of good software practice)

    * Less portable code makes heavy use of API that is already written and tested inside the OS.
    * Less portable code can therefore be less expensive and quicker to produce. Depending on the circumstance this can be a long term and/or short term benefit.
    * Less portable code can be made to execute faster than portable code
    * Less portable code can be made to take advantage of hardware features that are only exposed through a specific API
    * Typically the most popular OS in the world is easier to program for by most programmers, thereby allowing everyone that is hired to get up to speed on the project more quickly. (Not a concern for a team of one)
    * Typically large projects need to make every advantage in efficiency that is readily available. This might or might not be dependant on the OS
    * Anything that has to do a lot of work with filesystems will need operating system dependant code to be written. There are faster file operation system calls for each specific OS.
    * Less portable code can be made smaller in size, by depending on libraries that are only available on a target OS. (As long as they are actually there!!!)

    For example in Windows you can take advantage of a bunch of API to change system settings like IIS settings, and smtp settings.

    In Linux you have to write code to manually change text files. Of course API are better here because then there is less chance messing up the format of the text file. And your code will work in the next version of the OS too. Your code will not work in the next version if you change the config files manually. In your case, you don't care because you are just writing little free utilities. In bigger enterprise level applications you need to care about things like this. There are many examples of needing to use API where-ever possible. More experience with bigger applications is the best way to get to this knowledge.

    Also, one final note. C is getting to be an old language now, and it is sad that any code written in C is not portable. Things that have been around that long, have workaround after workaround to make them keep from breaking. It almost requires effort to write C code that is not portable nowadays. Bad C code is still prevelant though. This is mostly due to the #define conditional that was included to make C a lasting language. It worked. Now let's be done with it.

    Moving forward, I would suggest a language that makes use of garbage collection as your next choice. Also, one with clean syntax and no workarounds already in place would be a good plan. These criterea make for a langauge that is more difficult to write stupid code in. If you ever have to maintain code, then these are good considerations.

    Here are some examples (in no specific oreder)
    Java, C#, PHP

    Here is a bad example
    C++

    --
    Don't thank God, thank a doctor!
  14. Ok, now the actual reply: by SanityInAnarchy · · Score: 2, Insightful

    Basically, some people will say things like "Portability issues only happpen on Windows because of the use of Windows specific API.... and Linux somehow magically escapes this problem."

    Linux does not magically escape the problem. However, Linux developers are much more likely to write portable apps, because they remember how much it sucks to have their OS be unsupported, so they will naturally want to support BSD and OS X also.

    POSIX does help, however. NT was originally going to claim POSIX compliance, but now seems to deliberately break it.

    A buch of other people will say "All, code should be portable, because there is no reason for it to not be portable."

    I wouldn't claim that. For instance, modprobe has no reason to work on anything but Linux. Similarly, regedit has no reason to work on anything but Windows. However, I would suggest that most user-level apps could be portable, and the only question is whether it costs you anything. I believe you discuss costs below:

    * Less portable code makes heavy use of API that is already written and tested inside the OS.

    * Less portable code can therefore be less expensive and quicker to produce. Depending on the circumstance this can be a long term and/or short term benefit.

    There's a lot of vagaries there. Let's get more specific:

    * Less portable code can be made to execute faster than portable code

    Are you talking about the performance benefit gained by writing code that isn't as modular? Proper refactoring can have its own benefits, certainly in terms of cache coherency.

    The only way you're right here is if we're talking about assembly-level optimizations. In this case, only a madman would use hand-coded assembly for more than the tightest of the tight loops, which means very little hand-coded assembly. Even here, I think it's still possible to be portable across OSes on the same arch, most of the time, and I have to wonder if this could be shunted off to a library, which could then be made platform-independent by doing similar optimizations on every platform.

    For instance, if we're talking about games, the simple solution would be to use an existing engine, like the Quake4 engine, so someone else has already done the hand-optimization (as well as handled most of the other concerns), and you're automagically portable.

    * Less portable code can be made to take advantage of hardware features that are only exposed through a specific API

    What kind of hardware features?

    Unless you're talking about what I just was, the only way this is a problem is if you're writing a driver. Driver code is generally considered part of the OS, and thus not portable. And yet, nVidia still manages to make theirs mostly portable.

    * Typically the most popular OS in the world is easier to program for by most programmers, thereby allowing everyone that is hired to get up to speed on the project more quickly. (Not a concern for a team of one)

    This depends on the size of a project, but most often, I find it's a much bigger job to get up to speed on the app than the environment. For instance, it's taking me far longer to learn Drupal than it took me to learn (ugh) PHP. And since it's cross-platform, the programmers can use whatever OS is easiest for them, so long as they don't screw it up for everyone else -- which is something they should already be trying to do, assuming you've already got a project.

    * Typically large projects need to make every advantage in efficiency that is readily available. This might or might not be dependant on the OS

    Either you mean running speed, which we discussed above, or development speed. Development speed shouldn't really matter, as you should be able to mostly use the tools everyone's familiar with, although I can see problems with people

    --
    Don't thank God, thank a doctor!
  15. Testing by ranulf · · Score: 2, Insightful
    When I release, I just compile each app for all the OSs I have access to and post them on my website. I barely expend any effort at all to achieve portability. So the question I have to ask is: Why do the masses perceive portability as something that requires effort and a waste of time?"
    So, what about testing? That usually figures for a large part in most release schedules.