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.
The kernel is in C.
The above is the text of my response, in its entirety.
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.
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.
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++
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.
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.
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.
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.
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.
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.
Quite a lot of Linux developers know C#, let alone C++! :)
One of the leading media players on Linux is in C#, for example.