Re: Why C/C++ errors are SO obscure/devious??
- From: Eric Sosman <esosman@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 08:22:25 -0400
Massimo Soricetti wrote:
Joseph S. ha scritto:
I dont know the technical reasons for it, but, the Eclipse Integrated Development Environment (www.eclipse.org) for Java does things a little like this -suggesting at coding time what could be wrong with your code, giving alternatives on a popup textbox to change the type of your variable,. to add a cast here, to remove a line there etc.- It is not complete/foolproof, neither does it claim to be, but for most beginner to intremediate level Java coders it is useful, (of course, it is for the java language) It immediately suggests what could be wrong with your code -So, looking at this proficiency of Eclipse in Java, one wonders whether some of that kind of "interactive" coding can be brought to C.
So, something in this field CAN actually be done... Even if some of my ideas had proven naive, I think that a C "pre-preprocessor" looking for errors and making some guess based on coding style (detected from sources: every programmer has his own coding style, the prepreprocessor should be able to examinate code and detect kind of indentation, of parentheses placement etc) and common error sources and tries to suggest possible causes could eventually be useful...
Source code editors can be a help with some of the kinds of errors you've mentioned. My editor of choice is Emacs, but it's not the only one capable of matching up parentheses and braces and brackets -- and this can stamp out a lot of silly errors before the compiler even comes onto the scene. If you're typing along and suddenly Emacs auto-indents a line in a way you didn't expect, you become aware right away that you've forgotten a } or have too many ('s or some such. If you write something like `y[i] = f(x[i)]' the editor will complain as soon as the ) appears. Simple level-counting like this can be fooled (especially by the preprocessor), but is surprisingly effective at preventing bugs before they get written.
Fancier features like automatic code completion -- well, it's a matter of taste, I guess, but I personally don't like 'em. They distract me by interrupting my flow of thought, they annoy me by popping up their lists of suggestions right in front of the nearby piece of code I'm staring at, they guess wrong as often as right. (One such that I particularly disliked just didn't want me to write a reset() function. Every time I typed r followed by e, the damned thing would triumphantly supply t u r n and then sit there smirking while I cleaned up the mess.) Some people may like this brand of assistance; I'm not among them.
Editors that use built-in pieces of compilers can be helpful if you can moderate their puppy-like eagerness to write your code for you and chew on your slippers. For Java I use NetBeans, and although it's far too face-licking and tail-wagging for my taste I must admit it's nice to have a red squiggle appear when I call isWhiteSpace() instead of isWhitespace(). I don't know whether there are C-based tools that do this sort of thing (the separate compilation model and the preprocessor could make things hard), but I haven't looked. Seek, and ye may find.
-- Eric Sosman esosman@xxxxxxxxxxxxxxxxxxx .
- References:
- Why C/C++ errors are SO obscure/devious??
- From: Massimo Soricetti
- Re: Why C/C++ errors are SO obscure/devious??
- From: Joseph S.
- Re: Why C/C++ errors are SO obscure/devious??
- From: Massimo Soricetti
- Why C/C++ errors are SO obscure/devious??
- Prev by Date: Re: Greater sensitivity to off-topic than in other comp.lang
- Next by Date: Re: Why C/C++ errors are SO obscure/devious??
- Previous by thread: Re: Why C/C++ errors are SO obscure/devious??
- Next by thread: Re: Why C/C++ errors are SO obscure/devious??
- Index(es):
Relevant Pages
|