Refactoring browsers for C and C++

This is a discussion on Refactoring browsers for C and C++ within the Tech Board forums, part of the Community Boards category; Yes, of course, good old search-and-replace. CTRL-H, CTRL-R, etc. Actually, I have used "search and replace in selection" on occasion. ...

  1. #16
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,045
    Yes, of course, good old search-and-replace. CTRL-H, CTRL-R, etc. Actually, I have used "search and replace in selection" on occasion. But project-wide search-and-replace, for example renaming a function, tends to go wrong. And prompting you before each replace take way too long and you get bored and click "replace" on something that you shouldn't have without realizing it. Until you try to compile or run it.

    Quote Originally Posted by twomers' signature, originally Daved
    my code only generates a hundred or so bugs per feature.
    Did you know, while researching preprocessor macros (there are an average of 0.6 per line, I think), I found a statistic that stated that every new line of code written has between 2 and 5 bugs in it? Scary.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #17
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,045
    I should mention that I downloaded Elsa, and tried this program.
    Code:
    #include <iostream>
    
    int main(void) {
        std::cout << "Hello, World!" << std::endl;
    
        return 0;
    }
    Elsa requires preprocessed files, so I preprocessed that and tried parsing it with Elsa. It didn't work. g++ 4.1 worked, but not g++ 4.2. Anyway, I then got Elsa to print the elaborated abstract syntax tree. It was 692,000 lines. Ouch.

    Not that the abstract syntax tree is very concise. Something like this
    Code:
    int main() {}
    would give you at least ten or maybe fifteen lines. But still.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #18
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by dwks View Post
    Yes, of course, good old search-and-replace. CTRL-H, CTRL-R, etc. Actually, I have used "search and replace in selection" on occasion. But project-wide search-and-replace, for example renaming a function, tends to go wrong. And prompting you before each replace take way too long and you get bored and click "replace" on something that you shouldn't have without realizing it. Until you try to compile or run it.
    Yup, I recognize that...

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #19
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Quote Originally Posted by dwks View Post
    (there are an average of 0.6 per line, I think),

    every new line of code written has between 2 and 5 bugs in it
    Lies, damn lies, and statistics.

    Quote Originally Posted by dwks View Post
    Anyway, I then got Elsa to print the elaborated abstract syntax tree. It was 692,000 lines.
    Out of curiosity, how big was the preprocessed file?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #20
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,045
    I found the reference that says 0.6 macros per line. http://portal.acm.org/citation.cfm?id=1172980
    It has been shown that macro uses can occur as frequently as 0.6 macro uses per line [4].
    I can't remember where I found that 2 to 5 thing, although I think it was in a book. Nor do I have access to the preprocessed file at the moment, but I do remember that it was about 11KB.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #21
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Well, "can occur as frequently as" and "an average of" is quite different. One is the maximum per-program average they found, the other would be an average over all the code they looked at. I'll believe the former, but the latter is absurd.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #22
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,045
    Yes, of course you're right. I misunderstood it.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #23
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    So if Windows has a few kazillion lines of code and as many as 2-5 errors can occur per line with an average of 0.6, how many bugs are processed per second?

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21