C vs C++ for Open Source projects

C vs C++ for Open Source projects

Post by Matthew Cli » Fri, 03 Sep 1999 04:00:00



What are the disadvantages of using C++, instead of C, for an Open
Source project.  The only two disadvantages that I can think of are:

1) Not all potential users might have a C++ compiler.
2) There will always be more C programmers that C++ programmers, since

   anyone who can program C++ can also program C.  Thus, making a in C++
   will prevent some of the development community from working on it.

How much of a problem are these?  Are there any other problems?

Thanks in advance.

 
 
 

C vs C++ for Open Source projects

Post by Drazen Kac » Fri, 03 Sep 1999 04:00:00



> What are the disadvantages of using C++, instead of C, for an Open
> Source project.  The only two disadvantages that I can think of are:

> 1) Not all potential users might have a C++ compiler.
> 2) There will always be more C programmers that C++ programmers, since

  3) If you intend to produce code which could be compiled with
     most (all?) of the existing C++ compilers, you'll find it
     very hard. You'll end up not using many C++ features which
     made you choose C++ in the first place.

--
 .-.   .-.    Life is a *ly transmitted disease.
(_  \ /  _)



 
 
 

C vs C++ for Open Source projects

Post by M van Oosterhou » Fri, 03 Sep 1999 04:00:00



> What are the disadvantages of using C++, instead of C, for an Open
> Source project.  The only two disadvantages that I can think of are:

> 1) Not all potential users might have a C++ compiler.

This should get much better now, since EGCS has a much better C++
compiler. The older version of g++ was *way* out of date and
not being maintained much.

Quote:> 2) There will always be more C programmers that C++ programmers, since

>    anyone who can program C++ can also program C.  Thus, making a in C++
>    will prevent some of the development community from working on it.

Sort of. C++ is a superset of C but it is also an object oriented
language, and to be honest, to write good object oriented code
is hard.

Bad C++ can be even harder to read then bad C.

The other thing is that i think the kernel headers are not C++
compatable.

HTH,

Martijn van Oosterhout
Australia

 
 
 

C vs C++ for Open Source projects

Post by Johan Kullsta » Fri, 03 Sep 1999 04:00:00



> What are the disadvantages of using C++, instead of C, for an Open
> Source project.  The only two disadvantages that I can think of are:

> 1) Not all potential users might have a C++ compiler.
> 2) There will always be more C programmers that C++ programmers, since

>    anyone who can program C++ can also program C.  Thus, making a in C++
>    will prevent some of the development community from working on it.

> How much of a problem are these?  Are there any other problems?

the shared C++ standard library, libstdc++.so, seems to change in a
binary incompatible way with each minor revision of gcc/egcs.  as long
as you distribute source you should be fine.  you may want to encourage
users to compile your app themselves as opposed to downloading a
binary.

--
J o h a n  K u l l s t a m

Don't Fear the Penguin!

 
 
 

C vs C++ for Open Source projects

Post by Gergo Bara » Fri, 03 Sep 1999 04:00:00




>> 2) There will always be more C programmers that C++ programmers, since

>>    anyone who can program C++ can also program C.  Thus, making a in C++
>>    will prevent some of the development community from working on it.

>Sort of. C++ is a superset of C

Wrong. Compile this absolutely correct C program as C++:

int main(void)
{
        int new;
        return 0;

Quote:}

To the OP: choose the tools that help you get your work done.

Gergo

--
Olmstead's Law:
        After all is said and done, a hell of a lot more is said than done.

GU d- s:+ a--- C++>$ UL+++ P>++ L+++ E>++ W+ N++ o? K- w--- !O !M !V
PS+ PE+ Y+ PGP+ t* 5+ X- R>+ tv++ b+>+++ DI+ D+ G>++ e* h! !r !y+

 
 
 

C vs C++ for Open Source projects

Post by T.E.Dicke » Fri, 03 Sep 1999 04:00:00



Quote:> 1) Not all potential users might have a C++ compiler.
> 2) There will always be more C programmers that C++ programmers, since
>    anyone who can program C++ can also program C.  Thus, making a in C++

that's not true (unfortunately).

Quote:>    will prevent some of the development community from working on it.
> How much of a problem are these?  Are there any other problems?

The main one I've seen is a tendency to use the newest features, which
are not supported in other compilers.  Not much code written in C++ is
portable.  (Using the newest features can be amusing, but if you want
people to port the code, it's not so amusing).

--
Thomas E.*ey

http://www.veryComputer.com/

 
 
 

C vs C++ for Open Source projects

Post by Peter Seeba » Fri, 03 Sep 1999 04:00:00




>What are the disadvantages of using C++, instead of C, for an Open
>Source project.  The only two disadvantages that I can think of are:
>1) Not all potential users might have a C++ compiler.
>2) There will always be more C programmers that C++ programmers, since
>   anyone who can program C++ can also program C.  Thus, making a in C++
>   will prevent some of the development community from working on it.

Actually, the latter is patently false; C++ is *not* a superset of C, it's
a different language.  A good C++ programmer may well be a *sucky* C
programmer.  (And, of course, vice versa.)

There are plenty of people who can generate things that some compilers will
eventually accept as C, but which are fundementally awful code.  We do not
want these people maintaining "C".

Quote:>How much of a problem are these?  Are there any other problems?

C++ is a bloated, inefficient, badly designed hog.  If you want to use a
more "powerful" language than C, look at perl, python, or even Objective C.

-s
"Isn't bias a setting on tape decks?"
--

C/Unix wizard, Pro-commerce radical, Spam fighter.  Boycott Spamazon!
Will work for interesting hardware.  http://www.plethora.net/~seebs/
Visit my new ISP <URL:http://www.plethora.net/> --- More Net, Less Spam!

 
 
 

C vs C++ for Open Source projects

Post by Peter Seeba » Fri, 03 Sep 1999 04:00:00






>>> 2) There will always be more C programmers that C++ programmers, since

>>>    anyone who can program C++ can also program C.  Thus, making a in C++
>>>    will prevent some of the development community from working on it.
>>Sort of. C++ is a superset of C
>Wrong. Compile this absolutely correct C program as C++:
>int main(void)
>{
>    int new;
>    return 0;
>}

This is a nice cheap shot.  For a better understanding, consider that a C++
programmer will know that you should always write (if, for some insane reason,
you must use malloc() in C++)
        int *p = (int *) malloc(sizeof(int));
while any C programmer who re-read things since '90 or so will know it's
        int *p = malloc(sizeof(int));

There are a lot of subtle differences in the idiomatic and clear usage of the
languages.  People who use C++ are unlikely to appreciate the scope of utility
of function pointers in C, because they've got "better ways to do that", and
won't have bothered to pick up such an obscure and useless feature.

-s
--

C/Unix wizard, Pro-commerce radical, Spam fighter.  Boycott Spamazon!
Will work for interesting hardware.  http://www.plethora.net/~seebs/
Visit my new ISP <URL:http://www.plethora.net/> --- More Net, Less Spam!

 
 
 

C vs C++ for Open Source projects

Post by Johan Kullsta » Fri, 03 Sep 1999 04:00:00





> >What are the disadvantages of using C++, instead of C, for an Open
> >Source project.  The only two disadvantages that I can think of are:

> >1) Not all potential users might have a C++ compiler.
> >2) There will always be more C programmers that C++ programmers, since
> >   anyone who can program C++ can also program C.  Thus, making a in C++
> >   will prevent some of the development community from working on it.

> Actually, the latter is patently false; C++ is *not* a superset of C, it's
> a different language.  A good C++ programmer may well be a *sucky* C
> programmer.  (And, of course, vice versa.)

take away some C++ reserverd keywords and use ansi prototypes and yes
C++ is essentially a superset of C.  this is why C++ is popular.  if
it weren't, it
a) wouldn't be C++ (it'd be smalltalk haskell, common-lisp, ML &c)
b) wouldn't be as popular (just like smalltalk, haskell, common-lisp, ML &c)
yes it's practically a tautology, but your denial that C and C++ are
closely related makes me bring up the obvious.

Quote:> There are plenty of people who can generate things that some compilers will
> eventually accept as C, but which are fundementally awful code.  We do not
> want these people maintaining "C".

are you saying that

#include <stdio.h>

int main(
    int argc,
    char *argv[])
{
    printf("hello world\n");

    return 0;

Quote:}

is fundamentally awful?  note that this classic is valid in both C and C++.

Quote:> C++ is a bloated, inefficient, badly designed hog.  If you want to
> use a more "powerful" language than C, look at perl, python, or even
> Objective C.

and for something completely different, there's also lisp.

--
J o h a n  K u l l s t a m

Don't Fear the Penguin!

 
 
 

C vs C++ for Open Source projects

Post by Gergo Bara » Sat, 04 Sep 1999 04:00:00




>> There are plenty of people who can generate things that some compilers will
>> eventually accept as C, but which are fundementally awful code.  We do not
>> want these people maintaining "C".

>are you saying that

>#include <stdio.h>

>int main(
>    int argc,
>    char *argv[])
>{
>    printf("hello world\n");

>    return 0;
>}

>is fundamentally awful?  note that this classic is valid in both C and C++.

I would say that it's a less than perfect implementation in C (I can't
speak for C++). The parameters to main() are not used, and printf() is
overkill for printing a simple string + newline sequence.
Unless your compiler optimises those mistakes away, your program is a
bloated memory hog (well, sort of).

Gergo

--
"Where shall I begin, please your Majesty?" he asked.  "Begin at the beginning,"
the King said, gravely, "and go on till you come to the end: then stop."
Alice's Adventures in Wonderland, Lewis Carroll

GU d- s:+ a--- C++>$ UL+++ P>++ L+++ E>++ W+ N++ o? K- w--- !O !M !V
PS+ PE+ Y+ PGP+ t* 5+ X- R>+ tv++ b+>+++ DI+ D+ G>++ e* h! !r !y+

 
 
 

C vs C++ for Open Source projects

Post by Barry Margoli » Sat, 04 Sep 1999 04:00:00





>> 1) Not all potential users might have a C++ compiler.
>> 2) There will always be more C programmers that C++ programmers, since

>>    anyone who can program C++ can also program C.  Thus, making a in C++

>that's not true (unfortunately).

Are the unfortunate folks who are the exceptions to this rule really worth
worrying about?

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

C vs C++ for Open Source projects

Post by Jonathan Thornbu » Sat, 04 Sep 1999 04:00:00




>a C++
>programmer will know that you should always write (if, for some insane reason,
>you must use malloc() in C++)
>    int *p = (int *) malloc(sizeof(int));
>while any C programmer who re-read things since '90 or so will know it's
>    int *p = malloc(sizeof(int));

Well, the former is legal in _both_ langauges, no less efficient,
still works reliably on systems whose header files don't have full
ISO C prototypes, and is recommended by at least some contemporary C
experts.  See, for example, section 16.1 of Harbison & Steele's latest
(4th) edition, dated 1995.

Quote:>There are a lot of subtle differences in the idiomatic and clear usage of the
>languages.  People who use C++ are unlikely to appreciate the scope of utility

             ==================

Quote:>of function pointers in C, because they've got "better ways to do that", and
>won't have bothered to pick up such an obscure and useless feature.

More precisely, people who use C++ and who are not competent in C
and who have never bothered to read a decent C book and who have
never read an article discussing the many and varied uses of function
pointers.

I'm sure there are many such programmers, probably even working at
<your favorite vendor of bloatware>, but _I_ wouldn't want to work on
their code.

All this said, Peter is right, the idioms of C and C++ differ somewhat.
_Good_ C++ programmers should know both.  (In fact, in my experience
good C++ programmers were usually already good C programmers before
they learned C++.)

--

   http://www.thp.univie.ac.at/~jthorn/home.html
   Universitaet Wien (Vienna, Austria) / Institut fuer Theoretische Physik
   "There are no significant bugs in our released software that any
    significant number of users want fixed." - Bill Gates, 23 Oct 1995

 
 
 

C vs C++ for Open Source projects

Post by Mark Woodi » Sat, 04 Sep 1999 04:00:00


[Reformatting perpetrated.]



> > a C++ programmer will know that you should always write (if, for
> > some insane reason, you must use malloc() in C++)

> >       int *p = (int *) malloc(sizeof(int));

> > while any C programmer who re-read things since '90 or so will know
> > it's

> >       int *p = malloc(sizeof(int));

> Well, the former is legal in _both_ langauges, no less efficient,
> still works reliably on systems whose header files don't have full
> ISO C prototypes, and is recommended by at least some contemporary C
> experts.  See, for example, section 16.1 of Harbison & Steele's latest
> (4th) edition, dated 1995.

It also hides a diagnostic if you forgot to include <stdlib.h>.  This I
consider to be a major disadvantage.

I never make this mistake in my own code: my fingers automatically type

  #include <errno.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>

at the top of source files before thinking about what I actually need;
however, omitting the cast has quite often saved me some embarassment
when editing other people's code.

Quote:> > There are a lot of subtle differences in the idiomatic and clear
> > usage of the languages.  People who use C++ are unlikely to
> > appreciate the scope of utility of function pointers in C, because
> > they've got "better ways to do that", and won't have bothered to
> > pick up such an obscure and useless feature.

> More precisely, people who use C++ and who are not competent in C
> and who have never bothered to read a decent C book and who have
> never read an article discussing the many and varied uses of function
> pointers.

I suspect that Mr Seebach is referring to those unfortunates who try to
program in `C/C++'.  These induhviduals are, I suspect, unworthy of
considerarion in a discussion about good style.

-- [mdw]

 
 
 

C vs C++ for Open Source projects

Post by Mark Woodi » Sat, 04 Sep 1999 04:00:00





> >> There are plenty of people who can generate things that some
> >> compilers will eventually accept as C, but which are fundementally
> >> awful code.  We do not want these people maintaining "C".

> >are you saying that

> >#include <stdio.h>

> >int main(
> >    int argc,
> >    char *argv[])
> >{
> >    printf("hello world\n");

> >    return 0;
> >}

> >is fundamentally awful?  note that this classic is valid in both C
> >and C++.

> I would say that it's a less than perfect implementation in C (I can't
> speak for C++). The parameters to main() are not used, and printf() is
> overkill for printing a simple string + newline sequence.  Unless your
> compiler optimises those mistakes away, your program is a bloated
> memory hog (well, sort of).

The arguments to `main' are, in most implementations, passed regardless
of whether they're declared or used.  This will make no difference to
the program's performance: a sensible compiler will notice that the
arguments aren't used and use the registers for something else.

As to the use of `printf', well, it's traditional. ;-)

The program is, at least, correct and portable.  This is a major
advantage over an awful lot of rubbish I've seen produced by `C/C++'
programmers.

If you want a bloated memory hog which prints the classic greeting shown
above, I can direct you towards GNU Hello.

-- [mdw]

 
 
 

C vs C++ for Open Source projects

Post by Richard Kettlewel » Sat, 04 Sep 1999 04:00:00



> take away some C++ reserverd keywords and use ansi prototypes and yes
> C++ is essentially a superset of C.  this is why C++ is popular.  if
> it weren't, it
> a) wouldn't be C++ (it'd be smalltalk haskell, common-lisp, ML &c)
> b) wouldn't be as popular (just like smalltalk, haskell, common-lisp, ML &c)
> yes it's practically a tautology, but your denial that C and C++ are
> closely related makes me bring up the obvious.

`is not a superset' != `are not closely related'

Quote:> are you saying that
[...]
>     printf("hello world\n");
>     return 0;
[...]

> is fundamentally awful?  note that this classic is valid in both C and C++.

How about some error checking...?

Talking of error checking in C++ - in C I can write:

    if(fclose(stdout) < 0) { perror("stdout"); exit(EXIT_FAILURE); }

to report any I/O errors to the calling program.  Of course I am
relying on implementation-specifics for the error message to make
sense, and also for the exit status to be interpreted in a sensible
way, but still.

How can I do this with `cout' in C++?  Can it be done at all?  My
local documentation would seem to imply that it can't, BICBW.

--
http://www.greenend.org.uk/rjk/