Re: Why C/C++ errors are SO obscure/devious??



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
.



Relevant Pages

  • Would ruby be easy to code in using voice recognition?
    ... I was interested in giving ruby a try. ... I have been coding for years ... and makes coding less fun. ... For Java, I just kept getting annoyed that certain features weren't ...
    (comp.lang.ruby)
  • Re: CSharp
    ... Both SUN and MS has published coding conventions. ... I follow SUN coding concvention for Java and MS coding ...
    (microsoft.public.dotnet.languages.csharp)
  • **JOB POSTING** US-OH-Columbus - Java Developer - PERM
    ... Java Developer ... Able to work on programming projects with little supervision, ... design, unit coding, testing, debugging, and integration. ... Design and code applications from specifications. ...
    (comp.lang.java.programmer)
  • Re: calling a method from a method
    ... This is unlike languages such as Java and C++ where the source ... At least in Java they can by alternating classLoader and Class ... JavaScript/JScript is the only real principal difference (in this ... The coding style and coding approaches are just the ...
    (comp.lang.javascript)
  • Re: Why C/C++ errors are SO obscure/devious??
    ... Development Environment 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,. ... ideas had proven naive, I think that a C "pre-preprocessor" looking for errors and making some guess based on coding style and common error sources and tries to suggest possible causes could eventually be useful... ...
    (comp.lang.c)