Thread: general programming compatability question

  1. #1
    Metarectilinear
    Guest

    Question general programming compatability question

    Hey. Me and a few of my programming-ignorant friends were having a discussion the other day and we sort of have a bet going. We were talking about language compatability across different platforms. The argument was over this: take a simple program and write it for a PC. If you want it to work on a Mac, will you have to re-write it if it's in:
    -Assembly (no idea. beyond any experience of mine)
    -C (I say you'd have to re-write it.)
    -Fortran (I say you'd have to re-write it. This is used for some of our business software, I think)
    -JavaScript (you can use it in a browser, so the same program would run the same on both platforms?)
    -Java (OK, I don't really know the difference between this and JS)

    Any help would be appreciated. It was a friendly bet, but I'd like to know if I got at least a few right.
    -John M. L.

  2. #2
    Disagreeably Disagreeable
    Join Date
    Aug 2001
    Posts
    711
    Assembly - you'd have to rewrite it, yes.
    C - you'd have to rewrite it if it weren't ANSI unless the compiler on the Apple had the same library functions as the compiler you were porting the program FROM.
    Java - you shouldn't have to rewrite it, considering it's an interpreted language.

    As for the others, I dunno. Common sense tells me that you wouldn't have to in JavaScript assuming it doesn't call any system-specific features (if that's even possible). And I'm thinking Fortran would hold the same for C, but I don't know a line of Fortran so that's just speculation.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >-Assembly
    Most definitely.

    >-C
    It depends on the program, for non-trivial applications you would have to replace any platform-dependent code, but ISO conforming code would remain unchanged.

    >-Fortran
    I'm not familiar with Fortran, but I would imagine it would need a rewrite since I believe standard C is far more portable than Fortran (I could be wrong though).

    >-JavaScript
    Nope, if the platform supports Javascript then it should run anywhere. Scripting languages are nice like that, if there's an interpreter there's no problem.

    >-Java
    The JVM provides a layer between the code and the system, this makes Java highly portable and nothing would need changing in any reasonable situation.

    -Prelude
    My best code is written with the delete key.

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>>
    >-Fortran
    I'm not familiar with Fortran, but I would imagine it would need a rewrite since I believe standard C is far more portable than Fortran (I could be wrong though).
    <<<

    Not often I say this, but yes Prelude, you are wrong! Any Fortran source written to comply with FORTRAN-IV, FORTRAN-66, FORTRAN-77 or FORTRAN-9x, should compile on any platform given a conforming compiler.

    The ISO Fortran standards are just as tight as the ISO C standards.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Not often I say this, but yes Prelude, you are wrong!
    Serves me right for making a guess. Thank you for the correction.

    -Prelude
    My best code is written with the delete key.

  6. #6
    Metarectalinear
    Guest

    so basically...

    You would have to re-run the compiler for Fortran and C, but you would not have to re-write anything per se?

  7. #7
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> I don't know about the Fortran though

    The same is true of Fortran. As with C, the language is standard, however, the operating system API would not be.

    >>> but you would not have to re-write anything per se?

    The only real answer is to try exactly that and see what happens - you may be okay first time, (one can dream), if not, at least you'll have a handle on the scale of the work.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. general question
    By a.mlw.walker in forum C Programming
    Replies: 25
    Last Post: 04-04-2009, 09:32 AM
  2. A general question aout programming?
    By bradt93 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 03-26-2008, 11:00 AM
  3. winsock - general question
    By keira in forum Windows Programming
    Replies: 1
    Last Post: 09-28-2007, 01:56 PM
  4. General Question
    By obaid in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 08-22-2007, 05:39 AM
  5. general question regarding a function parameter
    By mlupo in forum C Programming
    Replies: 7
    Last Post: 10-13-2002, 07:32 PM