views:

479

answers:

11

I got into a discussion a while back. The company I work at develop under Linux and does so in ANSI C. A lot of benefits could come from moving to C++ as far as design goes I think. Our existing code would just have to get rid of all implicit type casts since C++ is a bit stricter about that and it would compile and run as usual. But I was told that we would never start using C++. The reason was that "Linux developers know C", but it would be very hard to find Linux developers who know C++. Personally I find this kinda strange since I started out by learning C++ on Linux. But it made me curious and I wonder if there are any statistics anywhere or if you could help me get a general feel for the validity in this statement. Would be good for future reference since I have always thought that Linux developers with knowledge in C++ wouldn't be that hard to find, but I could be totally wrong.

A: 

The kernel is in C.

The above is the text of my response, in its entirety.

Borealid
The Windows and OS X kernels are also written in C, and nobody argues that just because of that all application programs should also be written in C.
Philipp
No, but you could argue that being a "linux developer" means you're a kernel hacker.
Dave Van den Eynde
@Philipp: That's because Windows and OSX developers aren't driven by hero worship and don't *care* what the main guy behind the kernel prefers.
jalf
+1  A: 

For that matter, I develop a lot in C++ on Linux. And there are lots of C++ projects that target Linux, for example the whole Qt/KDE stuff. Linux developers seem to be a bit biased towards C because Stallman pronounced that "thou shalt write in C." But this is not something you should care too much about.

Philipp
this may have changed, at least for gcc, http://gcc.gnu.org/ml/gcc/2010-05/msg00705.html
aaa
+8  A: 

Developing Linux precludes knowing C++? Weird. One of the most common UI's for Linux is KDE, and that uses C++ extensively.

In my company, I think we easily have a hundred developers that know C++ and Linux. While it was hard to find them, it wasn't particularly hard. Good engineers are hard to find independent of the precise skills you're looking for.

We don't seem to be the only who came up with that idea. Look at Mozilla; FireFox is a big C++ project. Same goes for WebKit, C++ too.

MSalters
Related: http://stackoverflow.com/questions/1551842/why-are-most-of-the-biggest-open-source-projects-in-c, and specifically http://stackoverflow.com/questions/1551842/why-are-most-of-the-biggest-open-source-projects-in-c/1551859#1551859
gnud
A: 

Linux developers knowing C++

Yes why not? System programms usually are written in C. But at the same time, there are many custom applications for *nix written in Qt/gtkmm and it's C++

shk
Well, this was just the reasoning I was told was behind the decision to never start using C++, even if our existing code would compile and run using the g++ compiler. I thought that it was kinda of a strange statement to make, but then again, I don't know all Linux devs in the world :)
inquam
+1  A: 

Depends on what project you are working on. C and C++ are there to be "exploited" on the linux platform with each having its own share of developers. I have never come across such a reasoning.

Praveen S
+2  A: 

Kernel is in C, and converting kernel to C++ probably won't be a smart idea.

The rest of software can be written in whatever you want - I saw serious linux programs (on my machine) written in C, C++, OCaml, Python, Perl, D, Fortran, Java, Lisp, etc.

There is quite a lot of Linux software in C++ - For example, entire KDE suite, and everything that uses Qt is C++.

But I was told that we would never start using C++. The reason was that "Linux developers know C"

IMO, it is nonsense unless you're working with kernel or might run into portability problems. I'd recommend for them to take a look at Qt 4 apps and KDE. C is nice, but some things are easier to do in other languages.

SigTerm
I should say the reason was, word-by-word, "It's easy to find Linux developers who know C, but almost impossible to find Linux developers who know C++. C++ developers tend to be Windows developers". Still doesn't fit on me as I started out with C++ and Linux though :P
inquam
Me too. Although I must admit, I'm a VMS man really.
Brian Hooper
A: 

inquam - Here's a suggestion for your own dev team. Consider evangelizing that your team can still continue to code in "pure ansi C", but with the code going compiled through the C++ compiler instead of the C compiler. That is, rename the extension on all your projects .c files as ".cc" (or ".cpp") and set the default build tool to g++ (or whatever your compiler is).

The C++ compiler will enforce better type safety, treat more ambiguous coding practices as errors, and block real bugs before being checked in.

There's a few nuances with converting legacy code from C to C++, so it might be that you evangelize all new source files as C++. Then gradually convert the legacy code. At the very least, do this for the code you write. Then switch the filename extension back to ".c" before checking in. Maybe this good habit will catch on.

selbie
-1 Bad suggestion. If you code C, you should use a C compiler.
Tomas
Agreed with @Tomas: That's the better way to get a poorly written and unmaintenable code in the end.
ereOn
+2  A: 

The reason was that "Linux developers know C"

That is a true statement if by "Linux developers" you mean "people who develop the Linux kernel". However, if you mean "people who develop applications that run on Linux" it's patently false. People develop on Linux in any number of languages.

Whether C++ is the right language for your application is another matter which obviously I can't answer given that I know nothing about your code base.

JeremyP
+1. In system programming, dumber the language - better. In application programming one has much much more freedom.
Dummy00001
"people who develop Linux" I think it will be more correct to say "people who develop linux *kernel*".
SigTerm
@SigTerm: According to Richard Stallman, Linux *is* the Linux kernel, the full operating system including the user space tools should be called GNU/Linux, or GNU/Gnome/KDE/Apache/etc/Linux.
JeremyP
@JeremyP: I *know* that. But many other people (more > than just one stallman) use word "linux" describing entire operating system. Check wikipedia article about linux and corresponding article about linux naming controversy. http://en.wikipedia.org/wiki/GNU/Linux_naming_controversy
SigTerm
@SigTerm: OK I give in.
JeremyP
+12  A: 

A lot of benefits could come from moving to C++ as far as design goes I think.

Probably (depends on who would decide on the design in C++).

Our existing code would just have to get rid of all implicit type casts since C++ is a bit stricter about that and it would compile and run as usual.

It's not that simple. If you changed compiler options (or file extensions) to switch to C++ your code will not compile just like that (you will need to go over it and make changes).

Furthermore, your existing C codebase will make for a poorly-written C++ codebase.

It may also introduce all kinds of subtle bugs that to a seasoned C-thinking developer will be almost impossible to find (sizeof operator behaves differently for arrays in C and C++ for example but a seasoned C/beginner C++ developer would not even consider that the familiar sizeof in his code does something unexpected).

The reason was that "Linux developers know C", but it would be very hard to find Linux developers who know C++.

That's not a valid reason (if you make a job-posting online with "looking for C++ Linux developers you should get some good CVs - depending on your offer).

It may be the belief of whoever can make that decision in your company or it may be just an excuse they gave to get rid of you :-\

Here are some of the reasons (against switching) that may actually apply in your case - and that your manager probably considered:

  • the people who wrote your codebase may be good C developers but not know C++ - or be beginner C++ developers and/or poor C++ developers.

Good C developers often make poor C++ developers (best practices in C++ are completely different and many times opposed to best practices in C. This is a problem because the C++ code looks familiar enough to a C developer that he will think his experience applies to it (and good design decisions in C often make for poor design decisions in C++).

They may even be good C++ developers, but if that is the case, that should be unknown to your manager (if they were hired as C developers, their C++ skills probably never came up in the job interview).

  • your senior team members may have a good understanding of your application logic. If your application switches to C++ they may have to go (and be replaced by C++ developers). Such a change would lose you team members who are very familiar with your problem domain. Depending on your specific problem domain such a loss could be enormous.

Depending on the size and structure of your codebase, moving to C++ may be a very good decision. You don't give enough detail for us to know if that is the case.

For example, I've seen a large C codebase that over the years ended up reinventing C++ poorly (pseudo-classes supporting virtual function tables and inheritance - with a structure holding a void* to a base structure, or a base structure having void* to specialized data created dynamically - and other monsters).

Would be good for future reference since I have always thought that Linux developers with knowledge in C++ wouldn't be that hard to find, but I could be totally wrong.

They shouldn't be hard to find, but that's only a valid point if you're at the beginning of your project. No good manager will consider lightly changing seasoned developers who know the problem domain with new hires just for a few design decisions.

If you can provide better reasons for switching they may consider it. Good reasons for switching (for a manager) involve lower maintenance costs, lower development costs, lower risks, less effort, better progress reporting and so on.

If you want to keep pushing for this change, you will have to find some good arguments in those areas on top of some good counter-arguments to his "Linux developers know C".

Your arguments should be good enough that they overcome the arguments I've given above.

utnapistim
I took over after the last senior dev and I'm the ONLY dev working on this system today. Even the old ones leaving thought I might wanna change to C++ :). I managed to, as a test, take one of our systems parts and make it g++ compatible in about 30 min. Running and passing all tests. The way our code is written today almost exclusively includes getting rid of implicit type casts to make it comply to g++. Also, in a lot of places we have void* to data structures to support linked lists on arbitrary data etc. Having STL and using list<mydata*> would probably be a lot nicer.
inquam
What's the difference in `sizeof` on arrays in C and C++?
Kleist
@inquam: I made some suppositions about your situation that I thought were simply not addressed by you (thanks for mentioning them).Consider also making that as a proposal to your boss (in fact you could make a formal proposal with pluses and minuses and see where it gets you (you should also mention these points).It would be more difficult to ignore.Regarding your initial question (on linux devs knowing C++) you could point out to him that it is probably a case of sample bias (if he had to work with linux C devs, that would tell him nothing about the existence of C++ devs).
utnapistim
@inquam: Also, mentioning that all your tests pass after switching is critical. If your test coverage is significant (or exhaustive) that means the cost of switching is greatly reduced.
utnapistim
+1  A: 

I've been working as a C++ maintenance coder for roundabout 10 years now. Platforms included Solaris, AIX, HP-UX and Linux. Not for a second did I (or any other developer working on the same team) pause to ponder the possibility that we shouldn't because "Linux developers know C".

Someone has been sucking up too much of the Linux Kernel Mailing List anti-C++ propaganda.

DevSolar
A: 

Quite a lot of Linux developers know C#, let alone C++! :)

One of the leading media players on Linux is in C#, for example.

Daniel Earwicker