Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!rutgers!nike!ucbcad!ucbvax!jade!eris!mwm From: mwm@eris.berkeley.edu (Mike Meyer) Newsgroups: net.lang.c,net.lang Subject: Portable Languages (was: Expression sequencing query) Message-ID: <1455@jade.BERKELEY.EDU> Date: Wed, 15-Oct-86 17:24:56 EDT Article-I.D.: jade.1455 Posted: Wed Oct 15 17:24:56 1986 Date-Received: Thu, 16-Oct-86 22:16:29 EDT References: <111@titan.UUCP> <139200039@uiucdcsb> <483@jc3b21.UUCP> Sender: usenet@jade.BERKELEY.EDU Reply-To: mwm@eris.UUCP (Mike Meyer) Followup-To: net.lang Organization: Missionaria Phonibalonica Lines: 42 Xref: mnetor net.lang.c:6125 net.lang:1219 In article <483@jc3b21.UUCP> fgd3@jc3b21.UUCP writes: > Your examples support my point: a _portable_ language is one which >runs identically on all implementations. A language which permits the code >generated by its statements to be implementation-dependent is not portable. Your definition is ambiguous. Given the context (expression sequencing in C), I assume you mean "... is one where all programs run identically on all implementations." If you don't mean "all" programs, then obviously the language permits code to be generated which is implemtation-dependent. Of course, this implies that the two implementations accept the same language. I've got bad news for you. By that definition, the ONLY portable languages are ones that are trivially portable, with only one implementation. Let's look at some examples: FORTRAN: Even WATFIV and IBM FORTRAN G are different, since they evaluate expressions in different order. C: We've already seen several counter-examples. FORTH/LISP/BASIC/Pascal: Multiple standards for these languages, so I won't even bother. ALGOL: No I/O defined, so every implementation has a different set. COBOL: Similar to ALGOL, except only for "terminal" I/O. PL/I: IBM's two compilers accept different languages! Euclid: Maybe portable, but is there more than one implementation? To make matters worse, if a language supports floating point numbers, I can give you code that will behave radically differently on a 360-oid machine than on a VAX, even with near-identical implementations (you see, (x * 2) / 2 is not always x on a 360-oid architechture!). From looking at the above, I'd say that C, with a small set of vague standards (K&R and H&S), and a "real" standard (ANSI) in the works, is in pretty good shape. Even better, C has a DEMONSTRATED portability nearly as good as FORTRAN. Of course, the constraints on portable code in C are worse than they are in FORTRAN, but you've got a sharper tool to work with.