Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > C, really portable?

Reply
Thread Tools

C, really portable?

 
 
P.J. Plauger
Guest
Posts: n/a
 
      12-10-2005
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...

> pemo wrote:
>> Is C really portable?

>
> No. The standard embodies a portable syntax which exists as subset of
> any compliant compiler, but that's exactly as meaningless as you might
> suspect it is. For example, I don't believe there exists any pair of C
> compilers from different vendors that have exact source space
> compatibility.


Probably true, but not terribly important. Having been in and
around the validation business for several decades, I can testify
that Standard C has way more implementations than any other
language; and many of them score nearly perfect on two or more
nontrivial validation suites. Put another way, I've sold C code
intended to be portable also for several decades and I've *never*
had to worry about whether that code will compile, and execute
correctly, on a multitude of platforms. (With C++, I *always*
worry.)

Before C came along, I was doing similar things with Fortran,
and with reasonable success. And I've used about half a dozen
other popular languages with lesser success. So, IM(extensive)E
C portability is far from meaningless to me. YM(obviously)V.

>> In c.l.c we often see 'not portable' comments, but I wonder just how
>> portable C apps really are.

>
> They're not. Amongst languages in common use today, C is just like
> Visual Basic in that there just really isn't any real expectation of
> portability on any real world application code. Nearly every other
> language in common use today is far more portable than C.


Does your planet have an oxygen atomsphere? Just curious.

>> [...] And
>> that's why we also often see 'go and ask elsewhere' comments appearing
>> here
>> [totally reasonable they are too of course].

>
> Of course. This group is incorrectly named (or equivalently has been
> taken over by people who have ideas for this group that don't
> correspond to the name of it). It should be called comp.lang.c.ansi.
> This group does not discuss the practice of C programming.
>
> The exception, of course, is the tremendous leniancy given to people
> asking questions about gcc, and giving answers that are specific to
> gcc.


If you weren't in such a sour mood, and if I weren't trying to
hold onto my recent good mood, I'd be tempted to agree with you,
at least to some extent.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com


 
Reply With Quote
 
 
 
 
slebetman@yahoo.com
Guest
Posts: n/a
 
      12-10-2005
pemo wrote:
> Premise: any decently complex modern application cannot be entirely written
> in standard C [meaning, the language without compiler added 'extensions',
> and only using the standard libraries]. Or, if it is written in standard C,
> then it is 'sub optimal' [and certainly doesn't have a nice UI!].
>
> Conclusion: Whilst the language is portable, applications are not. And
> that's why we also often see 'go and ask elsewhere' comments appearing here
> [totally reasonable they are too of course].
>
> Anyway, just a thought, and I wonder if anyone can come up with a counter to
> it?


Well, even if the application can't be completely written in standard
C, it pays to be as close to portable as possible. Here's a list of
mostly portable, very non-trivial code in the real world where
portability is a major reason for their success:

1. Linux Kernel - now usually the first OS to be ported to a new CPU
2. BSD Kernel
3. Tcl interpreter - almost always the first scripting language to be
ported to a new OS or CPU
4. Tk GUI toolkit/library
5. gcc
6. Apache web server.
7. Adobe's postscript engine.

There are many others. Some assumes POSIX for portability. A few, like
the Tcl interpreter, don't even assume this. Tcl runs perfectly on a
386 in DOS.

 
Reply With Quote
 
 
 
 
websnarf@gmail.com
Guest
Posts: n/a
 
      12-10-2005
P.J. Plauger wrote:
> <(E-Mail Removed)> wrote in message
> > pemo wrote:
> >> Is C really portable?

> >
> > No. The standard embodies a portable syntax which exists as subset of
> > any compliant compiler, but that's exactly as meaningless as you might
> > suspect it is. For example, I don't believe there exists any pair of C
> > compilers from different vendors that have exact source space
> > compatibility.

>
> Probably true, but not terribly important. Having been in and
> around the validation business for several decades, I can testify
> that Standard C has way more implementations than any other
> language;


Thats nice, but not the question OP was asking. Please crack open a
dictionary: Availability != Portability.

> [...] and many of them score nearly perfect on two or more
> nontrivial validation suites. Put another way, I've sold C code
> intended to be portable also for several decades and I've *never*
> had to worry about whether that code will compile, and execute
> correctly, on a multitude of platforms. (With C++, I *always*
> worry.)
>
> Before C came along, I was doing similar things with Fortran,
> and with reasonable success.


Well yeah, and you could do the same thing with Visual Basic, and the
various Basic interpretors available for UNIXs, and so on. If you push
the entire job of portability up to the actual developer of the code,
well then in fact *MOST* languages are portable. If fact, did you know
its fact possible to be portable *BETWEEN* many languages? When you
put the onus onto the programmer, you can claim all sorts of
capabilities for your language.

There is a subtle difference between a language begin portable, and
software which has been painstakingly ported.

> [...] And I've used about half a dozen
> other popular languages with lesser success. So, IM(extensive)E
> C portability is far from meaningless to me. YM(obviously)V.
>
> >> In c.l.c we often see 'not portable' comments, but I wonder just how
> >> portable C apps really are.

> >
> > They're not. Amongst languages in common use today, C is just like
> > Visual Basic in that there just really isn't any real expectation of
> > portability on any real world application code. Nearly every other
> > language in common use today is far more portable than C.

>
> Does your planet have an oxygen atomsphere? Just curious.


Well my planet has Lua, Java, Python, Perl, TCL, and bizarre new
languages like Haskel, Scheme, etc. They are all portable.

Oh and BTW, my planet actually has mostly a Nitrogen atmosphere, though
it does includes a smaller proportion of oxygen, CO_2 and other
elements.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/

 
Reply With Quote
 
Walter Roberson
Guest
Posts: n/a
 
      12-10-2005
In article <(E-Mail Removed). com>,
<(E-Mail Removed)> wrote:
>Well my planet has Lua, Java, Python, Perl, TCL, and bizarre new
>languages like Haskel, Scheme, etc. They are all portable.


perl has horrible portability. Every time I want to do a non-trivial
perl update, whether it be a rev update or just bringing in a bunch
of new modules, it takes me pretty much a working day.

Indeed, I've been doing a module update today, and 22 of the modules
won't compile or won't test properly.

Last I checked, if you compile perl without threading then multiple
signals are not handled properly... and if you do compile with
threading then various other things break.
--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      12-10-2005
On 9 Dec 2005 17:27:08 -0800, in comp.lang.c , http://www.velocityreviews.com/forums/(E-Mail Removed)
wrote:

>pemo wrote:
>> In c.l.c we often see 'not portable' comments, but I wonder just how
>> portable C apps really are.

>
>They're not. Amongst languages in common use today, C is just like
>Visual Basic in that there just really isn't any real expectation of
>portability on any real world application code.


This is complete nonsense. Find me a Visual Basic compiler for Atari
ST, or Palm pilot, or IBM mainframe.

>Nearly every other
>language in common use today is far more portable than C.


You're fuller of sh*t than a midden.

>Even avoiding system calls, user interfaces and threading, its still
>very hard to write portable code in C.


and clueless.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      12-10-2005
On 9 Dec 2005 19:43:44 -0800, in comp.lang.c , (E-Mail Removed)
wrote:

>P.J. Plauger wrote:
>> <(E-Mail Removed)> wrote in message


(of writing portable code)
>>
>> Before C came along, I was doing similar things with Fortran,
>> and with reasonable success.

>
>Well yeah, and you could do the same thing with Visual Basic,


go on then, port some VB to Apple Mac, IBM Mainframe, Solaris, and Vax
11/780. And Blackberry.

>> Does your planet have an oxygen atomsphere? Just curious.

>
>Well my planet has Lua, Java, Python, Perl, TCL, and bizarre new
>languages like Haskel, Scheme, etc. They are all portable.


Fascinating but not relevant to the question.

>Oh and BTW, my planet actually has mostly a Nitrogen atmosphere, though
>it does includes a smaller proportion of oxygen, CO_2 and other
>elements.


Sounds habitable. One sun or two? I'm guessing one, but its possible
its two, apparently habitable planets can form round binary systems.

Can you send me the plans for your FTL transmitter by the way, its
very effective.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
Malcolm
Guest
Posts: n/a
 
      12-10-2005

"Eric Sosman" <(E-Mail Removed)> wrote
> "Portability" cannot even be assessed entirely from a
> study of the code. For example, a program written to the
> strictest coding standards and impeccably implemented might
> still be "non-portable" to a system with less than 256MB of
> memory. (The well-behaved program will, of course, fail
> cleanly with a polite message -- but if the program cannot
> carry out its intended function, it hasn't been "ported,"
> has it?)
>

Particularly when it could have produced the output, but slower, or less
accurately, or (here's the crucher) with less readable source code, on the
256MB machine.
>
> "Non-portable" is similarly inexact. In c.l.c. usage, all of
> these have been tagged as "non-portable;" I've tried to arrange
> them in an approximate order from venial sins to deadly:
>
> - Code that assumes two's complement integers
>
> - Code that assumes a particular character encoding
>
> - Code that assumes a particular endianness
>
> - Code that assumes `int i; int j;' allocates the two
> variables in adjacent memory locations
>
> ... and, of course, many more. Clearly there are "portability
> threats" of different kinds and magnitudes in such examples;
> because c.l.c. is sort of rabid we tend to lose the differences
> and tar them all with the same "non-portable" brush.
>

"Good enough" portability is a huge problem.

For instance, if you are pasing an IFF file, most of the file is binary and
the clc regular will of course load in all the big-endian integers using a
big-endian read and the little-endian ones using a little-endian read.
Unfortunately the segment tags are ASCII, and it is very tempting to
hardcode 'A' 'I' 'F' 'F' (the tag for a sound file). This will work fine on
any ASCII system, and suddenly go wrong when the portable code is ported to
non-ASCII.


 
Reply With Quote
 
Malcolm
Guest
Posts: n/a
 
      12-10-2005

<(E-Mail Removed)> wrote
> They're not. Amongst languages in common use today, C is just like
> Visual Basic in that there just really isn't any real expectation of
> portability on any real world application code. Nearly every other
> language in common use today is far more portable than C.
>

C is probably the most portable for command-line type apps.
Nothing is very portable for GUIs. Java tries to be, but the original
library had to be abandoned because it didn't work. Also, lots of PCs don't
have Java Virtual Machines installed.


> The exception, of course, is the tremendous leniancy given to people
> asking questions about gcc, and giving answers that are specific to
> gcc.
>

Unix people are morally superior to those who use and program Windows.
Didn't you realsie this?


 
Reply With Quote
 
websnarf@gmail.com
Guest
Posts: n/a
 
      12-10-2005
Walter Roberson wrote:
> In article <(E-Mail Removed). com>,
> <(E-Mail Removed)> wrote:
> >Well my planet has Lua, Java, Python, Perl, TCL, and bizarre new
> >languages like Haskel, Scheme, etc. They are all portable.

>
> perl has horrible portability. Every time I want to do a non-trivial
> perl update, whether it be a rev update or just bringing in a bunch
> of new modules, it takes me pretty much a working day.
>
> Indeed, I've been doing a module update today, and 22 of the modules
> won't compile or won't test properly.
>
> Last I checked, if you compile perl without threading then multiple
> signals are not handled properly... and if you do compile with
> threading then various other things break.


So you mean, its not easy to *INSTALL* right?

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/

 
Reply With Quote
 
websnarf@gmail.com
Guest
Posts: n/a
 
      12-10-2005
Mark McIntyre wrote:
> On 9 Dec 2005 17:27:08 -0800, in comp.lang.c , (E-Mail Removed)
> wrote:
> >pemo wrote:
> >> In c.l.c we often see 'not portable' comments, but I wonder just how
> >> portable C apps really are.

> >
> >They're not. Amongst languages in common use today, C is just like
> >Visual Basic in that there just really isn't any real expectation of
> >portability on any real world application code.

>
> This is complete nonsense. Find me a Visual Basic compiler for Atari
> ST, or Palm pilot, or IBM mainframe.


Uhh ... no, they have *other* basic interpretors and compilers. I'm
sure they all can run the following:

10 PRINT "HELLO"
20 END

Which is the same situation as C.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
really interesting... or really dull. (depends on your attitude) TrevorBoydSmith@gmail.com Java 2 09-01-2006 04:38 PM
OT : But help really really needed re: Domain Name selling, hosting etc. problem nc HTML 1 02-03-2005 07:24 PM
REALLY REALLY WERID PROBLEM!!!!pls take a look Amir ASP .Net 3 01-23-2004 06:01 PM
really really mysterious IE6 problem--secure site ultraviolet353 Computer Support 7 11-22-2003 07:56 PM
MR. ED REALLY, REALLY LOVES THE D60 !!! Annika1980 Digital Photography 9 10-28-2003 04:53 PM



Advertisments