"The Linux kernel (and the majority of Free software projects) are doing it all wrong?"
I find your claim that the majority of free software projects are written in C to be dubious. In the Graphics world for example, C++ projects vastly outnumber C projects, the latter relegated largely to low level libraries such as Mesa and Xlib.
Linux kernel is entirely written in C for exactly one reason: Linus wants it that way. It's Linus's ball and bat, I won't comment further. Oh, just one comment. C99 is also banned from Linus's kernel, nuff said.
Posted Jan 12, 2011 20:49 UTC (Wed) by bug1 (subscriber, #7097)
[Link]
I had read that C is more popular than C++, but double checking, on freshmeat.net there are 5367 projects tagged C++, 9594 tagged C.
However, the point i was trying to make in my original post is that complexity doesnt come from language, it comes from design.
If you have a really good design for a project, it should be just as easy for a C programmer to implement that design in C, as it would be for a C++ programmer to implement it in C++.
Design can be really hard, for simple tasks a lot of programmers do it themselves without thinking about it, its only when projects get larger that it gets recognized as a separate problem.
Sobotka: Why GIMP is inadequate
Posted Jan 12, 2011 21:53 UTC (Wed) by HelloWorld (guest, #56129)
[Link]
However, the point i was trying to make in my original post is that complexity doesnt come from language, it comes from design.
If you have a really good design for a project, it should be just as easy for a C programmer to implement that design in C, as it would be for a C++ programmer to implement it in C++.
This is just nonsense. The whole point of a programming language is to give you the means to express things more easily. The converse of your argument is essentially that we shouldn't have bothered with programming languages in the first place, since, given the right design, we might as well implement it in assembly language.
An object-oriented design with heavy use of inheritance, virtual function calls etc. will be much cleaner, terser and simpler in C++ than in C.
Sobotka: Why GIMP is inadequate
Posted Jan 13, 2011 16:11 UTC (Thu) by mgedmin (subscriber, #34497)
[Link]
Why not go all the way and recommend something like Python then? *Much* cleaner, terser and simpler than C++.
(Of course there's a cost -- larger memory usage, slower running speed. Just like C++ has costs that C doesn't have -- gotchas in the language design, longer compilation times, increased memory usage, slower application startup due to eager linking overhead for vtables, etc.)
Sobotka: Why GIMP is inadequate
Posted Jan 13, 2011 17:27 UTC (Thu) by HelloWorld (guest, #56129)
[Link]
It's all about tradeoffs. Python is slow and uses more memory. I also dislike dynamic typing, and it's easier to use a C library in a C++ program than in Python. If these aren't problems for you - great, use Python.
If instead you're looking for a programming language that offers both flexibility and suitability for systems programming (perhaps even in the embedded world), then C++ is in my opinion a reasonable option.
Sobotka: Why GIMP is inadequate
Posted Jan 13, 2011 20:31 UTC (Thu) by daniel (subscriber, #3181)
[Link]
"The point i was trying to make in my original post is that complexity doesnt come from language, it comes from design."
If you are saying that design complexity cannot possibly be caused by the language then I strongly disagree. The absence of essential organizational constructs in C is a breeding ground for complexity. Look at Xlib for example, you have to match up discriminated unions properly by hand, which involves keeping track of struct names, typedefs and union field names, all spelled differently and sometimes inconsistently. The resulting code is unnecessarily hard to write, harder to read (at least if "understanding" is a required part of reading) and full of accidents waiting to happen. I do not see how that can fail to translate into design complexity. You just can't cover up those flaws with a design, the underlying mechanism insists on showing through.
Sobotka: Why GIMP is inadequate
Posted Jan 13, 2011 22:31 UTC (Thu) by bug1 (subscriber, #7097)
[Link]
"If you are saying that design complexity cannot possibly be caused by the language then I strongly disagree."
Design _should_ be separate from its implementation, they are separate stages.
But if you are designing as you go then its likely to all turn to shit a few times anyway, the efficiency loss of the language probably isnt significant compared to lost time due to re-writing whole sections of code.
Sobotka: Why GIMP is inadequate
Posted Jan 18, 2011 17:54 UTC (Tue) by daniel (subscriber, #3181)
[Link]
"Design _should_ be separate from its implementation, they are separate stages."
That is the waterfall method. I do not find it as effective or efficient as the iteration method.
Sobotka: Why GIMP is inadequate
Posted Jan 18, 2011 17:52 UTC (Tue) by daniel (subscriber, #3181)
[Link]
It is hard to get reliable data on language popularity. That said, a search for "int main" lang:c vs lang:c++ on code.google.com shows C and C++ nearly tied. I think it is safe to say that a few years ago C++ would not have been anywhere close. (Caveat: it is naive to assume that a lot of care and attention goes into ensuring accurate search stats in a search engine.)
As far as freshmeat goes, it would be nice to know the relative popularity of C vs C++ for active and new projects versus inactive and old projects.
Sobotka: Why GIMP is inadequate
Posted Jan 13, 2011 12:16 UTC (Thu) by error27 (subscriber, #8346)
[Link]
C99 is also banned from Linus's kernel, nuff said.
Kernel style is one variable declaration per line. The declarations are separated from the code by a blank line. C99 allows people to mix code and variable declarations, but in the kernel it's considered horribly bad style.
The kernel style is to use kernel-doc comments and so C99 comments are considered non-standard and thus wrong.
On the other hand, the kernel has pretty much all been updated to use C99 style structure initialization and it uses __func__ instead of using the old GCC extensions. And the kernel often takes advantage of the latest features in GCC where possible. For example, v2.6.37 uses the new local label declarations.
When you say that we've banned C99 code that makes it sound like we're retarded. There are tons of things that we hate but only because they are ugly and not because they are new.
Sobotka: Why GIMP is inadequate
Posted Jan 13, 2011 20:34 UTC (Thu) by daniel (subscriber, #3181)
[Link]
"When you say that we've banned C99 code that makes it sound like we're retarded."
It does sound like that, doesn't it?
Sobotka: Why GIMP is inadequate
Posted Jan 14, 2011 7:36 UTC (Fri) by bronson (subscriber, #4806)
[Link]
Yep. So why don't you apologize? Your statement was clearly wrong.
Sobotka: Why GIMP is inadequate
Posted Jan 18, 2011 18:45 UTC (Tue) by daniel (subscriber, #3181)
[Link]
"So why don't you apologize?"
I will when the ban on inline declarations and // comments ends.
Sobotka: Why GIMP is inadequate
Posted Jan 19, 2011 16:56 UTC (Wed) by bronson (subscriber, #4806)
[Link]