Portability

R

Roger Leigh

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Malcolm said:
No. Simply use a language that enforces portability, like Java, or use C
carefully. Admittedly C has the problem of "good enough" portability - eg
all bits zero representing a null pointer, or the execution character set
being ASCII.

I don't remember either of those being true. On GNU/Linux, GCC uses
UTF-8 and UTF-32 as the respective narrow and wide execution character
sets.


Regards,
Roger

- --
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iD8DBQFCucfbVcFcaSW/uEgRAiG8AKCc+9Fo/g0HuTYrw/ZjLdke/bAdxgCgh/MN
TDdDGZNajVtGDBsrXfXV7us=
=N+p4
-----END PGP SIGNATURE-----
 
R

Richard Harter

This a common misunderstanding. The primary reason for making code portable
is not to move it to another system, as the layman would naturally suppose,
but to improve the sturcture of the code by separating algorithms from input
and output.
No. Simply use a language that enforces portability, like Java, or use C
carefully. Admittedly C has the problem of "good enough" portability - eg
all bits zero representing a null pointer, or the execution character set
being ASCII. This can be overcome with only a small amount of training.

One admires your hutzpah.



Richard Harter, (e-mail address removed)
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
 
P

pete

Richard said:
One admires your hutzpah.

I routinely make nonportable assumptions in code.
The standard doesn't guarantee that
sizeof(int) is less than SIZE_MAX,
but sometimes I'll just allocate an array of two int anyway.

int array[2];
 
W

websnarf

That really depends on what the scope of the standard is, and what you
are comparing against. For example, the language Python is *FAR* more
portable than C, in the sense the you can expect an generic application
written in it to work regardless of what platform you are running on.
In the case of Python, the core implementation *is* the standard.

The value of a standard such as the C standard with respect to
portability is that it allow different vendors to implement compilers
for it that have certain limits on it from a behavior and semantic
point of view. If you can write programs in the very narrow
intersection of all defined behaviors, then you can end up with
universally portable code.

Me personally? In the last 5 years I would say I basically don't write
code which isn't at least partially portable. However, I have never in
my life, qualified code that might run in a 1s complement machine -- I
have no idea what percentage of my code would ever successfully run on
such platforms, and I never will.
We do it all the time, so we can offer our products on all popular
platforms. Please note, however:

-- Portability is not a Boolean attribute, but a measure of the relative
cost of moving existing code vs. rewriting it. (If it's cheaper to move
than rewrite, we say it's "portable.")

Yes, but in most languages, the grey area is mostly about native
platform libraries and/or the size of the program. Portability in C to
a similar degree can on be achieved with significant effort.
-- It costs more time and effort up front to write code that's likely
to be portable. You may not get your investment back if you later
determine it's not worth porting.

True. But this is an issue mostly concerning C and C++.
-- The only way to make code truly portable, and keep it that way, is
to exercise it regularly on multiple platforms.

First of all, this is insufficient for the C (or C++) language.
Secondly, an alternative is to write your program in another language
which more naturally portable.
 
K

Kevin Handy

P.J. Plauger said:
We do it all the time, so we can offer our products on all popular
platforms. Please note, however:

-- Portability is not a Boolean attribute, but a measure of the relative
cost of moving existing code vs. rewriting it. (If it's cheaper to move
than rewrite, we say it's "portable.")

-- It costs more time and effort up front to write code that's likely
to be portable. You may not get your investment back if you later
determine it's not worth porting.

Sometimes it's better to be concerned with portability early,
because the next version of your favirite OS can change underneath
you, like MacOS->MacOSX or Linux aout->Linux elf; the hardware
can change: like Mac 68000->PowerPC->Intel or VAX->Alpha; or the
GUI libraries: like Gtk1.x->Gtk2.x, or AWT->Swing. If you have
tied yourself too rigidly to a specific version, you can cause
yourself a lot of grief.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top