J
jacob navia
In this group there is a bunch of people that call themselves 'regulars'
that insist in something called "portability".
Portability for them means the least common denominator.
Write your code so that it will compile in all old and broken
compilers, preferably in such a fashion that it can be moved with no
effort from the embedded system in the coffe machine to the 64 bit
processor in your desktop.
Sure, you can do that. But as you know, there is no free lunch.
You pay for that "portability" by missing all the progress done
since 1989 in C.
Note that there is objectively speaking not a single useful
program in C that can be ported to all machines that run the
language.
Not even the classic
int main(void) { printf("hello\n");}
Why?
For instance, if we take that program above and we want to
know if our printf did write something to stdout, we have to write
int main(void) {
int r=printf("hello\n");
if (r < 0) {
// what do we do here ???
}
}
The error code returned by printf is nowhere specified. There is no
portable way for this program to know what happened.
Since printf returns a negative value for an i/o error OR for a
format error in the format string there is no portable way to
discriminate between those two possibilitiess either.
Obviously, network i/o, GUIs, threads, and many other stuff essential
for modern programming is completely beyond the scope of "standard C"
and any usage makes instantly your program non portable.
This means that effectively 100% of real C software is not portable to
all machines and that "portability" is at best a goal to keep in
mind by trying to build abstraction layers, but no more.
This is taken to ridiculous heights with the polemic against C99, by
some of those same 'regulars'.
They first start yelling about "Standard C", and then... they do not
mean standard C but some other obsolete standard. All that, in the name
of "portability".
Who cares about portability if the cost is higher than "usability"
and easy of programming?
jacob
that insist in something called "portability".
Portability for them means the least common denominator.
Write your code so that it will compile in all old and broken
compilers, preferably in such a fashion that it can be moved with no
effort from the embedded system in the coffe machine to the 64 bit
processor in your desktop.
Sure, you can do that. But as you know, there is no free lunch.
You pay for that "portability" by missing all the progress done
since 1989 in C.
Note that there is objectively speaking not a single useful
program in C that can be ported to all machines that run the
language.
Not even the classic
int main(void) { printf("hello\n");}
Why?
For instance, if we take that program above and we want to
know if our printf did write something to stdout, we have to write
int main(void) {
int r=printf("hello\n");
if (r < 0) {
// what do we do here ???
}
}
The error code returned by printf is nowhere specified. There is no
portable way for this program to know what happened.
Since printf returns a negative value for an i/o error OR for a
format error in the format string there is no portable way to
discriminate between those two possibilitiess either.
Obviously, network i/o, GUIs, threads, and many other stuff essential
for modern programming is completely beyond the scope of "standard C"
and any usage makes instantly your program non portable.
This means that effectively 100% of real C software is not portable to
all machines and that "portability" is at best a goal to keep in
mind by trying to build abstraction layers, but no more.
This is taken to ridiculous heights with the polemic against C99, by
some of those same 'regulars'.
They first start yelling about "Standard C", and then... they do not
mean standard C but some other obsolete standard. All that, in the name
of "portability".
Who cares about portability if the cost is higher than "usability"
and easy of programming?
jacob