Reverting to C in C++ Code

  • Thread starter Scott Brady Drummonds
  • Start date
S

Scott Brady Drummonds

Hi, all,

I'm finding that in my new project I have developers that have been
developing in C++ for many years but they default to C code in most places.
As such, our code is C++ by compiler, but tends to be C by design and
appearance. As examples, they're used to using character prefixes for
library function and variable names instead of namespaces, favoring *printf
to streams and stringstreams, avoiding exceptions in favor of overloading
return values, and avoid the STL in favor arrays, character buffers, and
hand-rolled containers.

Most of the reasons for which I have chosen the C++ path in these decisions
lie in my own comfort level with the language. There are some clear
benefits of choosing C++ over C for some of these decisions (STL reliability
and robustness over char * comes to mind) but some of my choices seem to be
more about personal preference than correctness (using namespaces instead of
prefixes for library functions/variables).

I'd like to educate myself on the pros and cons of each of these and other
C/C++ decisions. I do have several books on C++ but none really attempt an
objective analysis of each of these features. Many rely on the notion of
"this is how you do it in C++". Unfortunately, that argument doesn't carry
weight with my coworkers.

Can anyone recommend a good source for this information? Books are better
than web pages, but at this point I'll take anything I can get.

Thanks!
Scott
 
M

Mike Wahler

Scott Brady Drummonds said:
Hi, all,

I'm finding that in my new project I have developers that have been
developing in C++ for many years but they default to C code in most places.
As such, our code is C++ by compiler, but tends to be C by design and
appearance. As examples, they're used to using character prefixes for
library function and variable names instead of namespaces, favoring *printf
to streams and stringstreams, avoiding exceptions in favor of overloading
return values, and avoid the STL in favor arrays, character buffers, and
hand-rolled containers.

Most of the reasons for which I have chosen the C++ path in these decisions
lie in my own comfort level with the language. There are some clear
benefits of choosing C++ over C for some of these decisions (STL reliability
and robustness over char * comes to mind) but some of my choices seem to be
more about personal preference than correctness (using namespaces instead of
prefixes for library functions/variables).

I'd like to educate myself on the pros and cons of each of these and other
C/C++ decisions. I do have several books on C++ but none really attempt an
objective analysis of each of these features. Many rely on the notion of
"this is how you do it in C++". Unfortunately, that argument doesn't carry
weight with my coworkers.

Can anyone recommend a good source for this information? Books are better
than web pages, but at this point I'll take anything I can get.

Have you read Stroustrup's "Design and Evolution of C++"?
Also you might find interesting Lippman's "Inside the C++ Object Model".

-Mike
 
E

EventHelix.com

E

E. Robert Tisdale

EventHelix.com said:
I guess some of the issues you are mentioning are issues with
using C++. The more important thing is to make sure you have an
object oriented design.

When transition from C to C++, the difficult part is the transition
from procedural design to object oriented design.

Who says that C programmers (programs) aren't object oriented?
Who says that a C++ programmer (program) must be object oriented?

Object Oriented Programming in C is just as good an idea as
Object Oriented Programming in C++.
 
M

msalters

E. Robert Tisdale said:
Who says that C programmers (programs) aren't object oriented?
Who says that a C++ programmer (program) must be object oriented?

Object Oriented Programming in C is just as good an idea as
Object Oriented Programming in C++.

Having written OO programs in both C and C++, let me tell you
that writing them in C leads to poorly readable C code.

E.g. your average C coder will not recognize

*(obj->vtable[obj_foo])(1)
or
SendMessage(obj, obj_foo, (void*)1 );
or
OOCALL( obj, foo, 1 ); /* nasty macro alert */

whereas your average C++ coder will understand
obj->foo(1);

Regards,
Michiel Salters
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,201
Messages
2,571,048
Members
47,647
Latest member
NelleMacy9

Latest Threads

Top