473,609 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Platform Independence

Hi,
I have read that 'C' is platform-independent and portable. I can'tsee
much a difference between the two terms. Could anyone differentiate the
two? Also is the statement actually true?
Thanks
Andy

Aug 12 '06 #1
16 3908
Andy wrote:
Hi,
I have read that 'C' is platform-independent and portable. I can'tsee
much a difference between the two terms. Could anyone differentiate the
two? Also is the statement actually true?
I don't think you should differentiate between them, they are
complimentary. You can get a C compiler for just about any processor
and standard conforming code will compile and run on them.

--
Ian Collins.
Aug 12 '06 #2
Andy wrote:
Hi,
I have read that 'C' is platform-independent and portable. I can'tsee
much a difference between the two terms. Could anyone differentiate the
two? Also is the statement actually true?
Neither term has a precise definition, as far as I know.
By my own notions (others may disagree), I would say that C
is *not* platform-independent: Too many characteristics of the
environment a C programmer confronts are inherited from and
controlled by the underlying platform. The number of bits in
an `int', the way negative integers are represented, the range
and precision of `double', whether floating-point types support
infinities, the syntax and semantics of file name strings -- all
these and more are at the platform's discretion, within broad
limits set by the language Standard. Search the Standard for the
phrase "implementa tion-defined" and you will find that it appears
quite often; each appearance diminishes the language's degree of
platform independence.

On the other hand, the C language is portable in the sense
that it is available on many differing platforms; porting a C
program to a new platform will seldom require that you translate
the code into a different language. C programs can be portable
to varying degrees, depending on how much they rely on the specific
characteristics of a platform. (I find it odd that C programmers
as a class seem apt to resort to non-portable techniques even when
C offers portable techniques that are no trickier; the observation
that "C combines the power of assembly language with the portability
of assembly language" is really more about the way programmers use
C than about C itself.) The ability to write non-portable programs
is both a weakness and a strength of C: a weakness because you cannot
be sure that "an ANSI C program" will port smoothly to a new platform,
and a strength because when you simply *must* stuff a special value
into location 2fff:0800 there's probably a way to do it even if it's
heavily platform-dependent.

A final note: In my view, neither "platform independence" nor
"portabilit y" are Boolean attributes. Nor are they scalar; they
seem to me to be multi-dimensional. They are not even objective:
portability is always assessed in terms of the likely universe of
desirable target platforms, and different programmers anticipate
different audiences.

--
Eric Sosman
es*****@acm-dot-org.invalid
Aug 12 '06 #3
Andy wrote:
I have read that 'C' is platform-independent and portable.
Standard C /can/ be used in a platform-independent way, but it takes
care and effort to achieve this, since there are many
implementation-defined and unspecified aspects of C. Two's complement
arithmetic and integer bit length which is a power of two are examples
of features that are common to most platforms, but not guaranteed in the
Standard.

To achieve the most portability, use only the features that Standard C
supports. Unfortunately, there are often implementation-dependent
things that the programmer wants to do, so he must use platform-specific
extensions or libraries. Common examples are graphics, multi-threading,
and menu systems. There are some multiple-platform libraries that make
portability easier.

The best approach is usually to use Standard C as much as feasible and
collect non-standard usage to a few functions and modules. This makes
porting easier.
--
Thad
Aug 12 '06 #4
Andy wrote:
Hi,
I have read that 'C' is platform-independent and portable. I can'tsee
much a difference between the two terms. Could anyone differentiate the
two? Also is the statement actually true?
Hi:

You can try AMPC at http://www.axiomsol.com
It is a C compiler that generate Java class files for the purpose of
achieveing platform independence via the JVM.

Regards.

Napi

Aug 13 '06 #5
napi wrote:
Andy wrote:
>>Hi,
I have read that 'C' is platform-independent and portable. I can'tsee
much a difference between the two terms. Could anyone differentiate the
two? Also is the statement actually true?


Hi:

You can try AMPC at http://www.axiomsol.com
It is a C compiler that generate Java class files for the purpose of
achieveing platform independence via the JVM.
On an 8 bit micro?

--
Ian Collins.
Aug 13 '06 #6
Ian Collins wrote:
napi wrote:
>Andy wrote:
>>Hi,
I have read that 'C' is platform-independent and portable. I can'tsee
much a difference between the two terms. Could anyone differentiate the
two? Also is the statement actually true?

Hi:

You can try AMPC at http://we.are.spamming/
It is a C compiler that generate Java class files for the purpose of
achieveing platform independence via the JVM.
On an 8 bit micro?
Nope. I doubt it would run on my (or my customers) SCO boxes not a
number of others when I run standard C programs built with the standard
port of gcc to those platforms.

Since the OP was not asking for such tools but asking for definitions of
terms I would say that AMPC was very close to being spammed. It also
still does not support C89 (it doesn't support C99 either).
--
Flash Gordon
Still sigless on this computer.
Aug 13 '06 #7
On Sat, 12 Aug 2006 20:16:12 UTC, Eric Sosman
<es*****@acm-dot-org.invalidwrot e:
Andy wrote:
Hi,
I have read that 'C' is platform-independent and portable. I can'tsee
much a difference between the two terms. Could anyone differentiate the
two? Also is the statement actually true?

Neither term has a precise definition, as far as I know.
By my own notions (others may disagree), I would say that C
is *not* platform-independent:
You are wrong. C is defined by zhe standard. Write your program in C
as the standard it defines and you ends up in a program that is
absolutely platform independent. I've proven that multiple times.
Write once, compile on each environment and run.

Too many characteristics of the
environment a C programmer confronts are inherited from and
controlled by the underlying platform.
That is why C exists. It is the job of the C environment to hide
platform dependant things from you.

The number of bits in
an `int', the way negative integers are represented, the range
and precision of `double', whether floating-point types support
infinities, the syntax and semantics of file name strings -- all
these and more are at the platform's discretion, within broad
limits set by the language Standard. Search the Standard for the
phrase "implementa tion-defined" and you will find that it appears
quite often; each appearance diminishes the language's degree of
platform independence.
Don't use yourself platform dependant details in your own code. The
standard guaratees a lot of things. Live inside the guarantees and you
would not change a single bit in your code to get it compiled and
running on highly different platforms - even on such you've never
heard before.

On the other hand, the C language is portable in the sense
that it is available on many differing platforms; porting a C
program to a new platform will seldom require that you translate
the code into a different language. C programs can be portable
to varying degrees, depending on how much they rely on the specific
characteristics of a platform. (I find it odd that C programmers
as a class seem apt to resort to non-portable techniques even when
C offers portable techniques that are no trickier; the observation
that "C combines the power of assembly language with the portability
of assembly language" is really more about the way programmers use
C than about C itself.) The ability to write non-portable programs
is both a weakness and a strength of C: a weakness because you cannot
be sure that "an ANSI C program" will port smoothly to a new platform,
Not true. Write a conforming program any you can pot it by only
compile for the new platform.
and a strength because when you simply *must* stuff a special value
into location 2fff:0800 there's probably a way to do it even if it's
heavily platform-dependent.
Yes, you will write complete incompatible program when your program is
based on functionality only defined on a specific platform. But on the
other hand you can even then write lots of the fuctionality strictly
portable by encapsulationg incomplatible functions and write only the
nonportable sections separately.

I've done that in a team of about 50 peoples for 10 completely
incompatible systems by rewriting only 25% of the total amount of 30
million lines (comments stripped) of code, having the other 75%
strictly conforming.
A final note: In my view, neither "platform independence" nor
"portabilit y" are Boolean attributes. Nor are they scalar; they
seem to me to be multi-dimensional. They are not even objective:
portability is always assessed in terms of the likely universe of
desirable target platforms, and different programmers anticipate
different audiences.
No, you can only been portable or not. You can only been platform
independant or not.
Your progam in whole can be both in same time.

--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!
Aug 13 '06 #8

Andy wrote:
Hi,
I have read that 'C' is platform-independent and portable. I can'tsee
much a difference between the two terms. Could anyone differentiate the
two? Also is the statement actually true?
Thanks
Andy
Er, Um, let's put it this way:
"Portabilit y" isnt a yes/no issue. Let's try rating languanges on a
scale from zero to 100%, portability-wise.

Now this is a bit unfair-- many languages were developed before the
concept of "portabilit y" was considered an important language
attribute. But let's plow ahead.

If we define portability as "The average programmer, writing say 1000
lines of code, taking no special emphasis on writing portable code,
will end up with a program that will run on xx% of the machines out
there"

let's take a wild stab at this, you may have other opinions, but this
is my guess:

Perl, COBOL, SNOBOL, Lisp: 85 to 95%

Pascal, Fortran 95, php, Java, SQL, , APL(100 lines): 70 to 84%

C, C++: 30 to 69%

Javascript, csh, sh, BASIC: 1 to 29%

Your opinion may vary.

----
(Explanation)
Some languages were intended to be portable, others have been
rigorously standardized into a semblance of portability, others are
portable because there exist "portable" implementations , others are
soooo loosely designed, or so dependent on system features that the
average program isnt very portable, or it's hard to remember all the
restrictions for writing portable programs.

So to answer your question, IMHO, C falls into the next to the bottom
category for portability. Mildly modify that by the fact that with
macros and #ifdefs and ./configure scripts you can coerce a C program
into a reasonable exterior semblance of portability.

Aug 13 '06 #9
"Herbert Rosenau" <os****@pc-rosenau.dewrote in message
news:wm******** *************** ****@JUPITER1.P C-ROSENAU.DE...
On Sat, 12 Aug 2006 20:16:12 UTC, Eric Sosman
<es*****@acm-dot-org.invalidwrot e:
>and a strength because when you simply *must* stuff a special value
into location 2fff:0800 there's probably a way to do it even if it's
heavily platform-dependent.

Yes, you will write complete incompatible program when your program is
based on functionality only defined on a specific platform. But on the
other hand you can even then write lots of the fuctionality strictly
portable by encapsulationg incomplatible functions and write only the
nonportable sections separately.

I've done that in a team of about 50 peoples for 10 completely
incompatible systems by rewriting only 25% of the total amount of 30
million lines (comments stripped) of code, having the other 75%
strictly conforming.
That seems to be the typical model. The amount of non-portable code you
need in your abstraction layer will depend on your exact needs and whether
or not you're running on top of some sort of OS or having to write your own
drivers, scheduler, etc., but every "portable" program I've seen follows the
same general idea: there's an abstraction layer which has to be rewritten
for each new target, but the bulk of the program logic is portable.
No, you can only been portable or not. You can only been platform
independant or not.
Your progam in whole can be both in same time.
Not in whole, no, but the beauty of C is that you can have individual
modules that are one or the other _written in the same language_ within the
same program.

S

--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking

--
Posted via a free Usenet account from http://www.teranews.com

Aug 13 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1967
by: kj | last post by:
I'm just learning about SOAP, and one of the claims about SOAP that I'm having the hardest time understanding/believing is this business about language independence. Please tell me if I got this right: suppose that I have a SOAP server written Perl that returns Perl objects in response to some method calls. Would a SOAP client written in Python or Java or C++ be able to make any sense out of these Perl objects? Thanks!
4
3514
by: Simon Elliott | last post by:
I want to design a class which will encapsulate some system specific representation, in this case time structs: #if unix_implementation #include <time.h> class Cfoo { private:
14
2119
by: John Salerno | last post by:
Bear with me, but I've been reading a lot about how the .NET languages are platform independent, and I assume this means a program written in C# can be run on a Unix or Mac machine. If this assumption is wrong, then nevermind! :) But if it's true, what will be necessary to run these programs on a Mac, for example? I know they would need an equivalent to the .NET Framework, but does something like this exist yet, or is the "platform...
2
1271
by: ad | last post by:
I use VS2005 to develop Web Application. The WebApp refer another ClassLibrary project in the solution. But when I compile, it result in an error:Can't find the independence of project. and I can't trace into the ClassLibrary project. How can I do?
0
1218
by: NRI Events | last post by:
Hello Friend, Kindly spare 2 minutes to celebrate INDIA's Independence Day with us. Host INDIA'S tri-color flag at your desk-top to show your love & support to INDIA. Its specially designed for you. (Home page) Participate in the event & win a gift for your
8
2062
by: Joel | last post by:
If I'm not wrong, .NET generates MSIL which can be executed by the CLR on any machine because the code is managed, but what if a programmer decides to use a bit of unmanaged code, say a feature of the win32 api, how is platform independence going to be achieved then. Thanks Joel
0
8127
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8567
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8215
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5509
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.