PDA

View Full Version : general programming compatability question



Metarectilinear
10-24-2002, 07:13 PM
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.

Hillbillie
10-24-2002, 07:31 PM
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.

Prelude
10-24-2002, 07:48 PM
>-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

adrianxw
10-25-2002, 06:01 AM
>>>
>-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.

Prelude
10-25-2002, 09:41 AM
>Not often I say this, but yes Prelude, you are wrong!
Serves me right for making a guess. :) Thank you for the correction.

-Prelude

Metarectalinear
10-25-2002, 01:28 PM
You would have to re-run the compiler for Fortran and C, but you would not have to re-write anything per se?

adrianxw
10-25-2002, 11:51 PM
>>> 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.