[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Which programming Language



On Sun, Feb 08, 2009 at 05:00:54PM -0600, Boyd Stephen Smith Jr. wrote:
> On Sunday 08 February 2009 11:04:42 Martin wrote:
> > On Sat, Feb 07, 2009 at 10:24:58PM -0600, Boyd Stephen Smith Jr. wrote:
 
> > And C standard is one that leaves many features implementation
> > defined, unspecified or undefined!
> 
> That's on purpose, for two reasons: (1) to support multiple competing 
> implementations, (2) to document where implementations are allowed to differ 
> so programmers can avoid them if they so choose.
> 
> >   y += y+++--y;
> 
> This results in implementation-specific behavior since you are modifying a 
> single variable twice with no sequence point in between.
> 
> >   printf("x=%d y=%d z=%d\n", x, y, z);
> 
> More implementation-specific behavior as z has not be initialized.
> 
> > Two compiler that I installed on Debian (gcc, tcc) gives different result.
> 
> Different implementations are allowed to have different behavior in this case.  
> It's not a flaw with the standard to support multiple implementations; it's a 
> feature.  If the programmer wants consistent results across implementations, 
> they can avoid the constructs that the standard says have undefined or 
> implementation-specific behavior.


The problem with implementation-specific stuff in C is that it is
allowed to varry so much from one implementation to another that you get
such unportable behaviour where this isn't technically necessary.

This was addressed in the Ada standard.  It says of the main langauge,
basically that all implementation have to do such-and-such.  It then
says that there are optional things that every implementation doesn't
have to have, but if it chooses to have it, it has to be done in a
specific way.

I really suggest that the OP read Understanding Programming Languages by
M. Ben-Ari.  It is freely available on the internet (or I can email it,
its under 1 MB).  It talks about programming lanagues in the abstract
and contrasts and compares C, C++, Ada, Java, and the more historical
languages where appropriate, such as FORTRAN, COBOL, Pascal, Smalltalk,
PL/1, etc.

Doug.


Reply to: