LWN.net Logo

Avoiding the tar pit

Avoiding the tar pit

Posted Feb 15, 2007 18:35 UTC (Thu) by ajross (subscriber, #4563)
In reply to: Avoiding the tar pit by IXRO
Parent article: Avoiding the tar pit

I'd suggest that the number of competent C developers was never that high to begin with, honestly. It's just that the past decade and a half has opened up the world of "development" to people who would otherwise never have learned to program at all. Their world is one of Javascript and VB, and we are all richer for it.

But to take from that that "C is dying" is just silly. It's just as useful for all the same tasks it always was. And many of its perceived shortcomings (raw memory indirection, for example) in fact aren't all that much a problem at all when using modern tools. I've done professional development both in Java (with checked arrays and typing) and in C (with regular valgrind use) and can honestly say that I'm equally productive in both environments.


(Log in to post comments)

Avoiding the tar pit

Posted Feb 16, 2007 3:06 UTC (Fri) by rjw (guest, #10415) [Link]

"I'm equally productive in both environments"

As someone who has just spent the last week debugging production problems in a messy C++ codebase, I very much doubt it. This involved replacing memory management functionality, and dynamically patching in assembly thunks into vtables just to work out what the hell was going on. So the "you just hate C because you don't understand it" response is not an appropriate one. I hate people where I work using C and C++ because it encourages them to do things that they can't fix, or even know what is happening. And no, its not just the C++ features that get people into a mess, its also the C ones, and the dodgy emulations of higher level features people create in these languages. If you really are as productive in C as Java, I'm sure you have your own fake OO system (structs of function pointers and data maybe indirected a bit), or "pass around a function pointer and a void*" psuedo closure convention. These are *nasty*, but if you don't have them, there is literally no way you can pretend to be as productive as in Java. Unless you program purely procedurally in Java. In which case....

There is simply no way that the mess people can get themselves into in languages with lax type systems ( ie void*, object slicing, reinterpret_cast etc) is an acceptable price to pay for the percieved or actual performance improvements, or the actual advantages like real templates (which are still less useful than macros + real parametric polymorphism) . The ease of debugging is enough to make you plump for Java. And to say you are just as productive in C belies the fact you have never used a decent refactoring environment, ie Eclipse or IntelliJ. These are useful enough for undoing mistakes (that will always be rife) that I would even advocate java + eclipse over "dynamic" or functional languages for a large number of projects - especially those involving a lot of programmers with no clue - ie most "enterprise" ones.

Avoiding the tar pit

Posted Feb 16, 2007 6:17 UTC (Fri) by bronson (subscriber, #4806) [Link]

Wow, that's a pretty accute case of language snobbery!

I contracted two years ago trying to add some database features to ~60 kloc of Java backend code. It was death by abstraction. BufferedStreamReader this, UmbrellaHackException that. Never have I seen so much code produce so little functionality. I could have rewritten it in about 10 kloc of C+glib+etc. Does this mean that Java sucks?

Crap code exists everywhere. Despite your protestations, rjw, Java's handcuffs won't save you from scary programmers (check the Daily WTF if you don't believe me). If a program's fundamentals are wrong, it's usually faster to just rewrite it than bang away on Eclipse's Shift-Alt-T for years. I use Eclipse every day nowadays. It's decent, but it's no panacea.

Avoiding the tar pit

Posted Feb 16, 2007 18:58 UTC (Fri) by dvdeug (subscriber, #10998) [Link]

So saying that one language is better than another is now language snobbery? How can you dismiss people who deal with problems in C that other languages don't have by design, and say it's just language snobbery?

Avoiding the tar pit

Posted Feb 16, 2007 19:10 UTC (Fri) by ajross (subscriber, #4563) [Link]

How can you dismiss people who deal with problems in C that other languages don't have by design, and say it's just language snobbery?

Stop flaming. Some of us use C and like it, and neither we nor the language are going away. If you can't handle that fact, and insist on engaging in flames even where none were provoked, then yes: you are a snob.

Make your design decisions, write your code, and make it work well. Presuming to tell smart people how to write their code is just random fanboi noise, and doesn't really belong in this forum.

Avoiding the tar pit

Posted Feb 16, 2007 20:05 UTC (Fri) by dvdeug (subscriber, #10998) [Link]

So saying that someone has an acute case of language snobbery is not a flame, but pointing out that there's valid points for the argument is a flame? Bringing up a claim that C and Java are equally productive is likely to bringing counter-claims, one of which was promptly attacked.

The question at the start of this topic is "What can we do to avoid a grim future where we bog down, our software collapsing under its own weight?". That is, this forum is all about design decisions and talking about what smart people should do.

Avoiding the tar pit

Posted Feb 17, 2007 10:37 UTC (Sat) by bronson (subscriber, #4806) [Link]

Yep! Just like saying Ford is better than Chevy is snobbery, or vi is better than Emacs, or San Francisco is better than New York. There are rational aguments that can be constructed, yes, but none of them boil down to "better".

To say that C suffers from problems that Java has fixed, and at the very same time ignore the many Java problems that C solves, well... I gotta admit, that sounds snobbish to me. Each language has its merits. Is Java better than PostScript? Or Forth? Or Lisp?

Generally pouring dirt on someone's choice of programming language is not productive, especially if you offer little more than personal anecdote to back it up.

Avoiding the tar pit

Posted Feb 17, 2007 15:15 UTC (Sat) by dvdeug (subscriber, #10998) [Link]

A tool is a tool, and rational people can discuss whether it's a better or worse tool than another tool without throwing around attack words like snobbery. Making things personal does nothing to rationally analyze the benefits and drawbacks of a tool.

Avoiding the tar pit

Posted Feb 17, 2007 23:23 UTC (Sat) by bronson (subscriber, #4806) [Link]

You're right, I worded that poorly. Instead of, "wow, that's a pretty accute case of language snobbery," I wish I had said "wow, that's a good example of language snobbery." I only wanted to ridicule the argument, definitely not the person doing the arguing.

Snobbery describes the act of advocating a single position while utterly ignoring merits of opposing positions. Your statement claimed that C has flaws and totally dismisses any possibility that it might also has benefits that overcome its flaws. If you can tell me a more appropriate word to use for this type of argument I'd be happy to use it.

If you'd like to continue to express your dislike of C, I'm probably interested in what you have to say. But I hope that you will use reasoned arguments and back them up with real world examples. Personal anecdotes and vague assertations aren't convincing and tend to impede discussion.

Personally, I have written tens of thousands of lines of Java and hundreds of thousands of lines of C. My position: Java has a problem domain that it solves very well, and C has a problem domain that it solves very well. At this point neither language can possibly be considered "better" than the other.

(I'm going on a 7-day unwired vacation tonight so a reply might be somewhat delayed...)

Avoiding the tar pit

Posted Feb 18, 2007 15:02 UTC (Sun) by rjw (guest, #10415) [Link]

Look, I don't even paticularly *like* Java. Theres all kinds of issues with it. But it seriously has the best tools available, for both debugging and coding, and we are talking about productivity, not purity, or holiness, or personal preferences...

There are certain classes of error that you are just not exposed to in Java, that you are in C:

- memory nightmares - unclear ownership, double frees, etc. Yes, you can get reference leaks in Java. With a heap inspector, these are really very easy to find. Yes, you can use smart pointers in C++, or a reference counting convention. Or even add in the boehm collector and hope that none of your values look a bit like pointers. But it still comes up again and again - and these problems do plague code written in C.

- home grown type systems. Less of a problem in C++, but really, show me any decent C program of a reasonable size that doesn't have some OO or closure hack hanging about. ( can we say gobject?) And please, lets not pretend that it doesn't take a bit of time to get these working decently, and the vast majority of them are very painful to debug.

Really, I don't mind C or C++ for programming things myself. I can navigate the potholes, because I know where they are. But it will take me longer, as I'll have to be worried about non-issues. The ones Java has for the vast majority of code people have to write are a lot shallower. There *are* advantages of C and C++. But those advantages are wildly outweighed by the disadvantage of either ending up with all kinds of nasty problems, or having a *very* very expensive hiring process - remember programmers often need to be hired for combinations of skills including knowledge outside - the damage that can be done in Java is limited in comparison.

"Despite your protestations, rjw, Java's handcuffs won't save you from scary programmers" - Way to ignore my entire post. Crap programmers can do less damage in java. Its very easy for people to think they know C well without knowing what the hell they are doing. I'm not saying this applies to you, but to the general ecosystem.

"I could have rewritten it in about 10 kloc of C+glib+etc"
and I would love to know what aspect Java would have prevented you writing it in less than that, and what added cost of maintenance it would have added for your client - "* Must know glib" is the kind of line recruitment consultants love to see.

Seriously, its not snobbery, its pragmatism.

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds