C and C++ together?

Avatar

Anant Narayanan

over 2 years ago

Hi again,

I don't understand the rationale behind clubbing C and C++ together throughout the website? They are different languages and should be treated as such. The statistics are not so helpful when they say "C/C++ is(are) the most popular language(s) to be used by open source projects". For instance, it doesn't answer the question: "Is Java more popular than C++?"

How difficult would it be to parse the files with the aim of differentiating between C and C++? If you're going by file extensions, that would be easy; even otherwise I don't think it would be too tough.

I'm probably just nitpicking, but it would be cool to see updated stats treating C and C++ seperately :)

Keep up the great work! Anant


Avatar

braden

over 2 years ago

I'd just like to echo this sentiment. C and C++ have very different usage patterns and distinct user communities. C++ projects are not, in general, of interest to C users. And while C++ users may be interested in C projects, certainly C++ users can be expected to have a particular interest in C++ projects.


Avatar

Jason Allen

over 2 years ago

Greetings,

I agree that they are (mostly) different languages. However I was unable to come up with a good heuristic to disambiguate header files (.h). I tried some basic rules like looking for a matching .cpp file or looking in the contents of the file to look for specific C++ keywords ("class" for example). However it was still failing often enough. The typical failure meant that C++ projects would report having some C in it - which was usually wrong.

We plan on open sourcing our code detection/parsing technology soon enough - maybe someone could improve on my earlier attempts?


Avatar

braden

over 2 years ago

Header files are indeed tough. Keyword detection is problematic in that C++ keywords that are not C keywords can be used as identifiers in C. Matching keywords with proximate syntax might be workable. Emacs mode settings are a handy thing to look for; but certainly not something that can be relied upon generally.

I understand that getting this right is not exactly trivial. Thanks, though, for acknowledging the issue.


Avatar

James Bursa

over 2 years ago

Header files could be handled by allocating the lines of code proportionally to the lines of C vs C++ in the same directory.

I guess in most cases it would be 100% C or 100% C++ anyway.