Linked by MOS6510 on Thu 10th Jan 2013 23:25 UTC
General Development "For years I've tried my damnedest to get away from C. Too simple, too many details to manage, too old and crufty, too low level. I've had intense and torrid love affairs with Java, C++, and Erlang. I've built things I'm proud of with all of them, and yet each has broken my heart. They've made promises they couldn't keep, created cultures that focus on the wrong things, and made devastating tradeoffs that eventually make you suffer painfully. And I keep crawling back to C."
Thread beginning with comment 548333
To read all comments associated with this story, please click here.
Point by point
by ingraham on Fri 11th Jan 2013 08:53 UTC
ingraham
Member since:
2006-05-20

"Simple and Expressive"

In what way is C simple? Take someone who's got a good background and mind for programming and show them C. See how long it takes them to actually understand how to define a function to pass to qsort() and bsearch() and then get the syntax right for function pointers. Versus .sort() and .find() in any object language, or the array-style dictionaries in Smalltalk or Lua. No way is C more expressive, much less 'simple.'

"Simpler Code, Simpler Types"

Okay, that I sort of agree with. I was bouncing through the JavaFX API docs yesterday, and there sure were a lot of bizarro return types that don't make sense off hand. However, there are entire books written about how to figure out what a damn variable definition means in C. const * char is a pointer to const... I think. Right? Very simple.

"Speed King"

Okay.

"Faster Build-Run-Debug Cycles"

In what universe? I grant you, C++ takes longer to compile than straight C, normally because it has to compile anything having to do with templates all the way back up the line. But my Java compiles are every bit as fast as C compiles. Maybe faster, since Java often does a better job of figuring out what needs to recompile, vs. 'hmm, maybe I should 'make clean' just to be sure.' And the Build-Run-Debug cycle of ANY scripting language is about a hundred times faster than C. gcc --help takes longer than no compile step at all.

"Ubiquitous Debuggers and Useful Crash Dumps"

Again, I can't argue with that one. Well, C crash dumps aren't always useful, but they're there when you really need them.

"Callable from Anywhere"

Okay. Although I'm not sure there's any real advantage over C++ in this regard.

"Yes. It has Flaws"

Indeed. Of course, every language does. But some of the crap you put up with in C is really just awful. Strings may be a simple, dumb example, but damn it just about every program has to deal with strings constantly. It may be a small grain of sand, but it chafes after a while. And sure, I can get an internationalization library for C. (Or ten of them, and who knows which one is actually the good one.) But in Java it's just there.

A final thought. Would Couchbase have been written at all if it hadn't started in Erlang? Sure, when it got big and successful and they needed speed improvements they re-coded in C. But could they have gotten that far without a higher level language to start with? The whole idea of "rapid prototyping" isn't just good because it makes programmers' lives easier, but also because get up and running with something functional quickly. You have to prove a business case or convince people to join your team, and that point is a lot harder to get to in C.

Reply Score: 9

RE: Point by point
by moltonel on Fri 11th Jan 2013 10:06 in reply to "Point by point"
moltonel Member since:
2006-02-24

In what way is C simple? Take someone who's got a good background and mind for programming and show them C. See how long it takes them to actually understand how to (...)


C is much simpler to understand fully than most other languages, in the sense that you understand exactly what a given line of code does. You pretty much know what (unoptimized) assembly will be generated by reading C. Try that with python, java, or even C++.

Of course C is harder to understand when you start with the language, but that's not what the author is talking about. He's talking about very experienced programmers (which he is).

"Faster Build-Run-Debug Cycles"

In what universe?


In the universe where java is not a "comparable language" I suppose, but I admit I wonder about this one too.

Reply Parent Score: 6

RE[2]: Point by point
by moondevil on Fri 11th Jan 2013 10:24 in reply to "RE: Point by point"
moondevil Member since:
2005-07-08

He's talking about very experienced programmers (which he is).


On my world such type of developers should have no problems understanding languages more complex than C.

Reply Parent Score: 2

RE: Point by point
by saso on Fri 11th Jan 2013 12:30 in reply to "Point by point"
saso Member since:
2007-04-18

In what way is C simple? Take someone who's got a good background and mind for programming and show them C.

This is a flawed premise. You are positing a hypothetical question and drawing conclusions without any data to show for it. In other words, what you're doing here is blind speculation.

const * char is a pointer to const... I think. Right? Very simple.

"const *char" isn't a valid C construct. I think you meant 'const char *' which is the traditional form to write the more proper 'char const *'. That is a "character constant"-pointer, i.e. a pointer to a character-constant. Contrast with 'char * const' which is a "character"-pointer constant. This is one of the more luxurious features in C, having the ability to keep a close eye on object mutability. How do I pass a constant array in, say, Java? I can't, there's no way to do it.

The rest of your comment, I have no problem with. C is not a one-size-fits-all solution.

Reply Parent Score: 4

RE[2]: Point by point
by telns on Fri 11th Jan 2013 17:36 in reply to "RE: Point by point"
telns Member since:
2009-06-18

'Collections.unmodifiableList()' will sometimes answer the need. But you are absolutely right; C has a lot more control.

Reply Parent Score: 1

RE[2]: Point by point
by ingraham on Fri 11th Jan 2013 22:22 in reply to "RE: Point by point"
ingraham Member since:
2006-05-20

You are positing a hypothetical question and drawing conclusions without any data to show for it.


Fair enough. I stand by the basic premise, however. Using function pointers to pass a compare function to a sort function is more complicated than blah.sort(). Particularly if your collection has a natural sort order, like strings.

"const *char" isn't a valid C construct.


Ha! Okay, it was 4 in the morning when I wrote that, but the fact that I screwed up my example kinda proves the point.

Reply Parent Score: 2

RE: Point by point
by Wafflez on Fri 11th Jan 2013 12:57 in reply to "Point by point"
Wafflez Member since:
2011-06-26

C# also has faster build-run-debug cycles.

And as for debuggers... Visual Studio blows C out of water - pause any time, IntelliSense to go back in steps, check variables, call stacks. Aaaand Paralel Tasks windows debugging threaded application. Unless gdb improved on debugging more than one thread.

Reply Parent Score: -1

RE[2]: Point by point
by saso on Fri 11th Jan 2013 14:35 in reply to "RE: Point by point"
saso Member since:
2007-04-18

And as for debuggers... Visual Studio blows C out of water

C is a language, Visual Studio is an IDE. You're comparing two different things.

pause any time, IntelliSense to go back in steps, check variables, call stacks. Aaaand Paralel Tasks windows debugging threaded application.

Correct me if I'm wrong, but VS supports all of the above on C++ (among other things), which is almost entirely a superset of C, i.e. it supports them on C as well. You're arguing against gdb, not C. And as for gdb, except for "Intellisense to go back in steps" (isn't Intellisense a code completion feature?), all that you mention can be done in gdb as well. Perhaps you mean some specific feature and/or problem?

Reply Parent Score: 6

RE: Point by point
by Valhalla on Sat 12th Jan 2013 14:23 in reply to "Point by point"
Valhalla Member since:
2006-01-24

Would Couchbase have been written at all if it hadn't started in Erlang? Sure, when it got big and successful and they needed speed improvements they re-coded in C. But could they have gotten that far without a higher level language to start with? The whole idea of "rapid prototyping" isn't just good because it makes programmers' lives easier, but also because get up and running with something functional quickly.

Hmm... I don't see your point. Prototyping in a higher-level language doesn't take away the usefulness of C. Judging by this thread I'm hardly the only one combining C and Python in my daily work, and yes I pretty much always write new code in Python first and then translate performance hotspots to C.

That said I'm certain Couchbase could have been written directly in C without prototyping in a higher level language, I think the initial thought was to have it running in Erlang but the performance was found lacking which prompted a rewrite in C.

The Linux kernel devs wrote git straight off in C during a very fast development phase and it's been a huge success in no small part due to it's much-lauded performance, but also it's stability.

Reply Parent Score: 3