Original Post
Hi, I've got some code on the internet, which are C++ libraries, and sometimes it happens that I get an email from someone who asks if it's possible to have a C version. I've tried to convert one of my libraries to C once, but I gave up when I realized how bad the code started looking: not that C is bad, but it feels really bad to have nice C++ code that is very readable and uses classes and the STL, and then convert it to C where everything is much more limited, and you're basically converting all your classes to structs and convert member functions into functions that take the struct as first parameter, and don't have std::strings at all and have written some sort of replacement for std::vector that is also a struct with std::vector-like functions that uses malloc and realloc and such everywhere, but has to use void*'s to avoid code duplication since there are no templates in C. And did I mention how ugly the comments start looking if you can't even use "//" style comments? Or the thing where you have to declare all variables first, only then write the code? This all helps making code that was nice, into something less nice, which caused me to give up the conversion to C effort and keep my libraries C++. Anyway, I wonder, why are there people who need C? Maybe it is because Linus Torvalds has something against C++? I looked that up in Google, and found this: http://emonk.debianuruguay.org/?p=42 It's from september 2007, so very recent! In it is a lot of C++-bashing, including things like this:
Quote:As well as this:
C++ is a horrible language. It’s made more horrible by the fact that a lot of substandard programmers use it, to the point where it’s much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C.
Quote:I use STL everywhere, how's it not portable? My code compiles on all major OS platforms. C++ makes everything much nicer IMHO while C has a lot of annoying limits. Why is C++ so hated in a lot of the open source world?
- infinite amounts of pain when they don’t work (and anybody who tells me that STL and especially Boost are stable and portable is just so full of BS that it’s not even funny)