473,899 Members | 4,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ANSI C compliance

Just to make a tangential point here, in case anyone new to C doesn't
understand what all these flame wars are about.

Shorthand title: "My boss would fire me if I wrote 100% ANSI C code"

We are discussing whether this newsgroup should focus on 100% ANSI C or
simply topics related to the C language in the real world. There is a C
standard which is defined by an international committee. People who write
compilers refer to this in order to make sure their compilers follow the
standard -- that they actually compile C. However, they also add extensions
to the C language to make your life easier, and of course there are bugs in
the compilers and such.

So for various reasons, C you write which runs and works as expected on one
platform might not work on another platform. The C standard is there to
alleviate this -- to decide which compiler is wrong if they differ in
behavior.

What percent of non-trivial programs are completely ANSI C (i.e. they work
as intended on all platforms for which you have an ANSI C compiler, modulo
compiler bugs)? I would suspect somewhere near 0%, just like about 0% of
non-trivial programs are completely bug free. Even taking this into
account, I would suspect less than 5% of non-trivial C programs written are
intended to be, or actually are, standard C. It simply isn't necessary
engineering practice, although there are certainly exceptions. For example,
one job I once interviewed for was writing standard ANSI C implementions of
licensed technology, that were meant to be ported (by hand) to assembly on
DSPs by the licensees. That is, the idea was to write something for other
people to read and compile, not something to actually go in a real product.

Now, on to my point. Writing truly standard C as valued by the "regulars"
in this newsgroup is time-consuming if you're not experienced. And it takes
time to accumulate the knowledge necessary to do so. Thus, in the business
world, it is not considered good practice, since time = money.

There is a field of study you might call "software development", which is
the study of how real teams build real software products. There is a notion
called "speculativ e generality" (from one of Steve McConnell's books I
think, don't
remember which one, see also Martin Fowler). This is basically when you
write code that speculates on what you may need to write need in the future.
Instead of writing code that does exactly what you need to do, you write
something that does more than that, potentially. This is shorthand for
overengineering -- architecting a general system when a specific one will
do.

Writing 100% ANSI C when you are not in a special circumstance (like the one
I listed above) is considered speculative generality. Portability is a
feature of code. Thinking about portability to machine with 9 bit bytes or
2 stacks or no stack or 6 stacks is a waste of time (at least business time,
your personal time is free to be spent however you like), when you have no
forseeable need for it. Because this time could be spent working on
features that actually are required, ones that actually generate money.
Even if you DO have a forseeable need for it, it is considered good practice
to solve _only the problem at hand_. Business requirements are extremely
volatile. Executives are fickle.

An example. Our game started out on PS2. A couple years ago we ported it
to the GameCube and XBox. Did we have completely portable code at first?
No, we wrote a game for PS2. Would it have been easier to port if we had?
Sure, a little. But it wasn't a big deal to fix all the problems as they
came up, as compiled with *real* compilers. And so we did so, in a
straightforward manner.

Do we have standard C code now that we ported it? No. Do we need to? Not
really, the products sold more than 1.5 million copies and generated
millions of dollars in profits.

Now we are investigating porting it to PSP (Playstation portable). Would
it be easier if we have standard C code? Sure, a little. But what if we
never had to port to PSP? Then our effort writing standard C would have
been wasted. What if the PSP compiler has a bad bug that makes it
incompatible with ANSI C? (Not unlikely, since there is only one compiler
for these machines at first, generally).

In software development, *incur the development cost* of a feature *when you
need it*. Not any sooner.

So, the bottom line is, if I was working on making some old nasty code that
works ANSI C compliant, instead of implementing a feature on my schedule
(ANSI C compliance would be laughed off the schedule), my boss would be
PISSED. You don't do that. There is a very real risk of creating bugs in
already working code, which of course is much worse than that code not being
ANSI C.

That said, you should learn the basic rules of the language (to a reasonable
point, there is definitely a point of diminishing returns). Far too many
programmers hack blindly, just trying to shut the compiler warnings up.
(Believe it or not, I am actually the one on the team that adheres most
strictly to standards, e.g. I am the one who hates it when people use enum
as integers, even though that is standard, etc.. My co-workers would have a
good laugh at this, and wonder if this newsgroup is from another planet.)

So, the second bottom line is, that this is C programming in the real world,
which the overwhelming majority of people are interested in doing. As
opposed to whacking off in a newsgroup about their ANSI C knowledge as an
end in itself. That is why CLC is a terrible place to discuss ONLY ANSI C,
as there is already perfectly good place (CLC.moderated) . This is where
people new to C tend to come (as mentioned, alt.comp.lang.l earn-c-c++ is a
joke by its very title), and CLC.moderated would reject many of their posts
as off topic. Since they don't KNOW what standard C is yet, they don't know
what's on-topic.

Good day. If you have a reasoned response to this, I'd be interested in
your opinions.

(But alas, let the flames from the "regulars" begin...)

Roose
Nov 13 '05
100 7053
A couple of years ago, I posted a big long article defending this
newsgroup's focus on the importance of portability and ANSI C
compliance. In response, Richard Heathfield wrote:
An [adjective deleted] article. With a little editing (to generalise
it into essay format rather than "reply" format), it would make an
excellent Web reference page to which denizens of clc could justly
point when the subject comes up again.


For no particular reason, today was the day to do that editing
and generalizing. The revised essay is at

http://www.eskimo.com/~scs/readings/....20031117.html

Point away.

Just for fun, I poured the same text into the new "clc wiki", at

http://clc-wiki.net/wiki/Portability...I_C_Compliance

So anyone is free to edit it to more perfectly reflect the
newsgroup's consensus, refine the wording, eliminate first-person
perspective, etc.
--
Steve Summit
sc*@eskimo.com
Feb 4 '06 #91
sc*@eskimo.com (Steve Summit) writes:
A couple of years ago, I posted a big long article defending this
newsgroup's focus on the importance of portability and ANSI C
compliance. In response, Richard Heathfield wrote:
An [adjective deleted] article. With a little editing (to generalise
it into essay format rather than "reply" format), it would make an
excellent Web reference page to which denizens of clc could justly
point when the subject comes up again.


For no particular reason, today was the day to do that editing
and generalizing. The revised essay is at

http://www.eskimo.com/~scs/readings/....20031117.html

Point away.

Just for fun, I poured the same text into the new "clc wiki", at

http://clc-wiki.net/wiki/Portability...I_C_Compliance

So anyone is free to edit it to more perfectly reflect the
newsgroup's consensus, refine the wording, eliminate first-person
perspective, etc.


Excellent, and highly recommended. (BTW, "excellent" was the deleted
adjective.)

Just a couple of minor comments.

I just read the Wiki article. I have no problem with the first-person
perspective, but you might consider signing it, or at least mentioning
who wrote the original.

Also, I think "ISO C" would be a clearer and more accurate term than
"ANSI C".

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 4 '06 #92
Steve Summit wrote:
In response, Richard Heathfield wrote:
An [adjective deleted] article.


Ha. I first read this as, "An [expletive deleted] article."

I was trying to imagine what Richard had originally said.


Brian
Feb 5 '06 #93

"Default User" <de***********@ yahoo.com> wrote in message
news:44******** ****@individual .net...
Steve Summit wrote:
In response, Richard Heathfield wrote:
An [adjective deleted] article.


Ha. I first read this as, "An [expletive deleted] article."

I was trying to imagine what Richard had originally said.


Adjective deleted? Why bother, unless it was very derogatory and close to
an expletive...
It's simple to put three dots there so noone questions whether the original
article was crappy or not.

RP
Feb 5 '06 #94
"Rod Pemberton" <do*******@bitb ucket.cmm> writes:
"Default User" <de***********@ yahoo.com> wrote in message
news:44******** ****@individual .net...
Steve Summit wrote:
> In response, Richard Heathfield wrote:
>
> > An [adjective deleted] article.


Ha. I first read this as, "An [expletive deleted] article."

I was trying to imagine what Richard had originally said.


Adjective deleted? Why bother, unless it was very derogatory and close to
an expletive...
It's simple to put three dots there so noone questions whether the original
article was crappy or not.


I suspect Steve was being modest. (The adjective was "excellent" .)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 5 '06 #95
Keith Thompson wrote:
"Rod Pemberton" <do*******@bitb ucket.cmm> writes:

.... snip ...

Adjective deleted? Why bother, unless it was very derogatory and
close to an expletive... It's simple to put three dots there so
noone questions whether the original article was crappy or not.


I suspect Steve was being modest. (The adjective was "excellent" .)


Modest? A Programmer? A C Programmer? Extinct. :-)

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Also see <http://www.safalra.com/special/googlegroupsrep ly/>
Feb 5 '06 #96
On 4 Feb 2006 21:23:59 GMT, sc*@eskimo.com (Steve Summit) wrote in
comp.lang.c:
A couple of years ago, I posted a big long article defending this
newsgroup's focus on the importance of portability and ANSI C
compliance. In response, Richard Heathfield wrote:
An [adjective deleted] article. With a little editing (to generalise
it into essay format rather than "reply" format), it would make an
excellent Web reference page to which denizens of clc could justly
point when the subject comes up again.


For no particular reason, today was the day to do that editing
and generalizing. The revised essay is at

http://www.eskimo.com/~scs/readings/....20031117.html

Point away.

Just for fun, I poured the same text into the new "clc wiki", at

http://clc-wiki.net/wiki/Portability...I_C_Compliance

So anyone is free to edit it to more perfectly reflect the
newsgroup's consensus, refine the wording, eliminate first-person
perspective, etc.


I agree with Richard, the "excellent" adjective was well deserved.

I have tried to make the same point in replies of varying length here
over the years.

I enjoyed your description of building a desktop simulation of the
user interface for an embedded system. I've been doing that for more
than a decade and a half. It is extremely useful when the
customer/end user/etc., wants to see and approve the appearance and
operation of the interface early in the cycle.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Feb 5 '06 #97

"Jack Klein" <ja*******@spam cop.net> wrote in message
news:jq******** *************** *********@4ax.c om...
On 4 Feb 2006 21:23:59 GMT, sc*@eskimo.com (Steve Summit) wrote in
comp.lang.c:
A couple of years ago, I posted a big long article defending this
newsgroup's focus on the importance of portability and ANSI C
compliance. In response, Richard Heathfield wrote:
An [adjective deleted] article. With a little editing (to generalise
it into essay format rather than "reply" format), it would make an
excellent Web reference page to which denizens of clc could justly
point when the subject comes up again.


For no particular reason, today was the day to do that editing
and generalizing. The revised essay is at

http://www.eskimo.com/~scs/readings/....20031117.html

Point away.

Just for fun, I poured the same text into the new "clc wiki", at

http://clc-wiki.net/wiki/Portability...I_C_Compliance

So anyone is free to edit it to more perfectly reflect the
newsgroup's consensus, refine the wording, eliminate first-person
perspective, etc.


I agree with Richard, the "excellent" adjective was well deserved.


Eh, I'd say mostly good. There are a number of inflammatory things near the
middle. And, the last paragraph will be found highly offensive by many.
And, I'm sure that last paragraph probably translates poorly into other
languages with Altavista, something like "You will be Crucified like Jesus
by the Romans." ;)
Rod Pemberton
Feb 6 '06 #98
Rod Pemberton wrote:
"Jack Klein" <ja*******@spam cop.net> wrote in message
news:jq******** *************** *********@4ax.c om...
On 4 Feb 2006 21:23:59 GMT, sc*@eskimo.com (Steve Summit) wrote in
comp.lang.c :
Just for fun, I poured the same text into the new "clc wiki", at

http://clc-wiki.net/wiki/Portability...I_C_Compliance

So anyone is free to edit it to more perfectly reflect the
newsgroup' s consensus, refine the wording, eliminate first-person
perspectiv e, etc.


I agree with Richard, the "excellent" adjective was well deserved.

Eh, I'd say mostly good. There are a number of inflammatory things near the
middle. And, the last paragraph will be found highly offensive by many.
And, I'm sure that last paragraph probably translates poorly into other
languages with Altavista, something like "You will be Crucified like Jesus
by the Romans." ;)

Offensive to whom?

This is a well written piece and makes a very strong case for compliant
code, while avoiding flamebait.

--
Ian Collins.
Feb 6 '06 #99
Ian Collins wrote:
Rod Pemberton wrote:
"Jack Klein" <ja*******@spam cop.net> wrote in message
news:jq******** *************** *********@4ax.c om...
On 4 Feb 2006 21:23:59 GMT, sc*@eskimo.com (Steve Summit) wrote in
comp.lang.c: Just for fun, I poured the same text into the new "clc wiki", at

http://clc-wiki.net/wiki/Portability...I_C_Compliance

So anyone is free to edit it to more perfectly reflect the
newsgroup's consensus, refine the wording, eliminate first-person
perspective, etc.

I agree with Richard, the "excellent" adjective was well deserved.

Eh, I'd say mostly good. There are a number of inflammatory things
near the
middle. And, the last paragraph will be found highly offensive by many.
And, I'm sure that last paragraph probably translates poorly into other
languages with Altavista, something like "You will be Crucified like
Jesus
by the Romans." ;)

Offensive to whom?

This is a well written piece and makes a very strong case for compliant
code, while avoiding flamebait.


Presumably offensive to those like Rod Pemberton who like to insist that
this group should be wide open to anything vaguely C related even though
experience in comp.lang.c++ apparently shows that this would make the
group useless.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Feb 6 '06 #100

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

Similar topics

5
2838
by: Acacia | last post by:
a) Does the C++ language never change? I was recommended to upgrade my MSVC v1.5 to a newer compiler - yet I thought that ANSI C++ was a standardised language and never changed - so why would i need to upgrade my compiler? More features? b) How good is C++? Would it be worth learning for a computer, and possibly programming, enthusiast? Has it got a long life ahead of it or is it likely to die out soon replaced by newer languages?
3
5940
by: Jack | last post by:
Hi I am just trying to get a feel for what oracle SQL syntax there is that would not be covered at all in anyway from a functionality perspective in the standard ANSI SQL.. Any input is appreciated.. Thank you, Jack
83
11670
by: sunny | last post by:
Hi All What is C99 Standard is all about. is it portable, i mean i saw -std=C99 option in GCC but there is no such thing in VC++.? which one is better ANSI C / C99? can i know the major difference between C99 & ANSI C standards?
0
9845
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
11276
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...
0
10866
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10976
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,...
0
9671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8043
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
5891
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6082
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3320
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.