C++ equivalent to spaghetti code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Campy Happer

    C++ equivalent to spaghetti code

    Hello all,

    I would like to bring to your attention a concept
    and a term for it that I think is long overdue.

    But first: In the bad old days of programming,
    before subroutines were even available,
    people used to write "spaghetti code", which
    was an unreadable, unmaintainable mess of
    "goto" statements.

    With the increased availability of more
    languages such as Pascal and C, and the
    focus in programming courses on the importance
    of modularity and abstract data types,
    one might have thought that the days of
    commonplace incomprehensibl e code were over,
    or at least that the worst case scenario
    in average code was improved.

    In the case of C++, this is not so.
    C++, with its multiple inheritance,
    templates, and vastly bloated class libraries
    such as STL and Boost, which permit and
    seem even to require illegible coding practices
    in which 5-deep derived classes are not
    unlikely, has led to the C++ equivalent
    of spaghetti code.

    But how to describe it? Commonly people
    simply call it "bad coding practices" but this
    is too general. It's like calling a traffic accident
    "bad driving practices". What then is the
    term for an "accident" in C++? To describe this
    build-up of tangled incomprehensibl e bloat,
    I shall propose a new term:
    C++ plaque.

    It is similar to the plaque build-up in
    Alzheimer's insofar as it impairs memory,
    makes the programmer confused about
    what is located where and what day it is.
    In addition, when C++ plaque accumulates,
    it decreases the programmer's ability
    to function in his/her daily work life, ergo
    anything (s)he produces will be much more
    likely to crash, e.g. KDE.

    Fight code pollution by not polluting.

    C++ plaque: The cure is within you.

    Thank you for your attention.


  • Keith Thompson

    #2
    Re: C++ equivalent to spaghetti code

    Campy Happer <campyhapper@ya hoo.comwrites:
    Hello all,
    >
    I would like to bring to your attention a concept
    and a term for it that I think is long overdue.
    [snip]

    I would like to bring to your attention the fact that C and C++ are
    two different languages. This may be appropriate in comp.lang.c++;
    it's not appropriate in comp.lang.c or gnu.misc.discus s. Please
    restrict any followups to comp.lang.c++. (I doubt that this will do
    any good, but it's worth a try.)

    --
    Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

    Comment

    • Juha Nieminen

      #3
      Re: C++ equivalent to spaghetti code

      Campy Happer wrote:
      In the case of C++, this is not so.
      C++, with its multiple inheritance,
      templates, and vastly bloated class libraries
      such as STL and Boost, which permit and
      seem even to require illegible coding practices
      in which 5-deep derived classes are not
      unlikely, has led to the C++ equivalent
      of spaghetti code.
      Go troll somewhere else, Linus Torvalds.

      Comment

      • Lionel B

        #4
        Re: C++ equivalent to spaghetti code

        On Tue, 15 Jul 2008 08:03:29 -0700, Campy Happer wrote:

        <some nonsense>

        Can we phuleeeze not feed the troll.

        <plonk>

        --
        Lionel B

        Comment

        • Roberto Waltman

          #5
          Re: C++ equivalent to spaghetti code

          Campy Happer <campyhapper@ya hoo.comwrote:
          .... In the bad old days of programming,
          >before subroutines were even available,
          >people used to write "spaghetti code", which
          >was an unreadable, unmaintainable mess of
          >"goto" statements.
          >...
          >C++, with its multiple inheritance,
          >templates, and vastly bloated class libraries
          >such as STL and Boost, which permit and
          >seem even to require illegible coding practices
          >in which 5-deep derived classes are not
          >unlikely, has led to the C++ equivalent
          >of spaghetti code.
          >
          >But how to describe it?
          In the one and only true way. The object-oriented version of
          "Spaghetti code" is, of course, "Lasagna code". (Too many layers.)

          I have used that expression for years, but so far failed to obtain ISO
          certification for it, or have it included in Webster's dictionary...

          It goes without saying that any good chef can cook both Spaghetti and
          Lasagna codes in either C or C++. (If using the later I would
          recommend inheriting from the Pasta abstract base class.)
          --
          Roberto Waltman

          [ Please reply to the group,
          return address is invalid ]

          Comment

          • Gernot Frisch

            #6
            Re: C++ equivalent to spaghetti code


            Can we phuleeeze not feed the troll.

            Imagine a troll post and no responses for a week. I think he's gonna
            explode.

            Comment

            • s0suk3@gmail.com

              #7
              Re: C++ equivalent to spaghetti code

              On Jul 15, 10:24 am, Juha Nieminen <nos...@thanks. invalidwrote:
              Campy Happer wrote:
              In the case of C++, this is not so.
              C++, with its multiple inheritance,
              templates, and vastly bloated class libraries
              such as STL and Boost, which permit and
              seem even to require illegible coding practices
              in which 5-deep derived classes are not
              unlikely, has led to the C++ equivalent
              of spaghetti code.
              >
              Go troll somewhere else, Linus Torvalds.
              Does Linus Torvalds not like C++?

              Comment

              • fnegroni

                #8
                Re: C++ equivalent to spaghetti code

                On Jul 17, 7:22 am, s0s...@gmail.co m wrote:
                On Jul 15, 10:24 am, Juha Nieminen <nos...@thanks. invalidwrote:
                >
                Campy Happer wrote:
                In the case of C++, this is not so.
                C++, with its multiple inheritance,
                templates, and vastly bloated class libraries
                such as STL and Boost, which permit and
                seem even to require illegible coding practices
                in which 5-deep derived classes are not
                unlikely, has led to the C++ equivalent
                of spaghetti code.
                >
                  Go troll somewhere else, Linus Torvalds.
                >
                Does Linus Torvalds not like C++?
                No, he does not :-)

                Comment

                • John Bode

                  #9
                  Re: C++ equivalent to spaghetti code

                  On Jul 15, 11:16 am, gaze...@xmissio n.xmission.com (Kenny McCormack)
                  wrote:
                  In article <3ce476c4-3248-4a00-aaf1-a670c07b3...@l4 2g2000hsc.googl egroups.com>,
                  Campy Happer <campyhap...@ya hoo.comwrote:
                  ...
                  >
                  I shall propose a new term:
                  >
                  C++ plaque.
                  >
                  [snip]
                  1) I always associated plaque with dental problems, not
                  Alzheimer's. Is the Alzheimer's reference about the same as
                  the dental one?
                  Sort of. It refers to the buildup of amyloid plaques (sheets of
                  protein, IIUC) in the brain tissue of Alzheimer's sufferers. I think
                  this is closer to the meaning the OP is going for.

                  Comment

                  • Malcolm McLean

                    #10
                    Re: C++ equivalent to spaghetti code

                    "John Bode" <jfbode1029@gma il.comwrote in message
                    >
                    Sort of. It refers to the buildup of amyloid plaques (sheets of
                    protein, IIUC) in the brain tissue of Alzheimer's sufferers. I think
                    this is closer to the meaning the OP is going for.
                    >
                    If you are interested in computer models of amyloid, see my website. It's
                    the major focus of my work.

                    --
                    Free games and programming goodies.



                    Comment

                    • Wolfgang Draxinger

                      #11
                      Re: C++ equivalent to spaghetti code

                      fnegroni wrote:
                      >Does Linus Torvalds not like C++?
                      >
                      No, he does not :-)
                      Well, I know only the comments Linus Torvalds made about the
                      implications of using C++ to develop a kernel. And I totally
                      agree with him in his statements. Programming a kernel you want
                      to control every bit of the program (yes I know, that this
                      sentence can be interpreted in many ways, and each way totaly
                      matches what I mean).

                      A languages like C++, that hides (some) vital aspects of the
                      underlying mechanisms can break things at such a low level
                      application. I'm thinking mainly about the way, polymorphism is
                      implemented (there's no standard about that in current C++), how
                      name mangling is performed (dito), calling conventions if
                      objects are passed by reference (dito). Another problem is, that
                      the use of some C++ features (I'm looking at templates here)
                      will start a chain reaction in which code is created generically
                      w/o having any influence on the exact outcome. This is not the
                      same like using macros to create a similair effect; doing it
                      with a macro one must exactly know what's going on.

                      IMHO C++ was once a fine language, but it took some problematic
                      turns. The existence of tools like "moc" of Qt, a own, not fully
                      standardized interface description language (IDL) to be
                      translated in a set of abstract interface classes and from those
                      derived implementation classes, not to forget gccxml to give the
                      guy who want's some too to process C++ without getting into a
                      lof of trouble are symptoms for this. I dunno, but I got a row
                      of programming language books in my shelf and "The C++
                      programming language" by Stroustroup is easly the thickest. It
                      even beats "Modern Compiler Design" and goes equal with Volume 2
                      and 3 of "The Art of Computer Programming".

                      Wolfgang Draxinger
                      --
                      E-Mail address works, Jabber: hexarith@jabber .org, ICQ: 134682867

                      Comment

                      • James Kanze

                        #12
                        Re: C++ equivalent to spaghetti code

                        On Jul 18, 1:31 am, Wolfgang Draxinger <wdraxin...@dar kstargames.de>
                        wrote:
                        fnegroni wrote:
                        Does Linus Torvalds not like C++?
                        No, he does not :-)
                        Well, I know only the comments Linus Torvalds made about the
                        implications of using C++ to develop a kernel. And I totally
                        agree with him in his statements. Programming a kernel you want
                        to control every bit of the program (yes I know, that this
                        sentence can be interpreted in many ways, and each way totaly
                        matches what I mean).
                        C++ only hides what you want it to hide. The old Chorus OS was
                        written entirely in C++, and presumably, significant parts of it
                        have migrated into the current versions of Solaris, which would
                        mean that significant parts of Solaris are written in C++.

                        --
                        James Kanze (GABI Software) email:james.kan ze@gmail.com
                        Conseils en informatique orientée objet/
                        Beratung in objektorientier ter Datenverarbeitu ng
                        9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

                        Comment

                        • James Kanze

                          #13
                          Re: C++ equivalent to spaghetti code

                          On Jul 18, 9:27 am, Michael DOUBEZ <michael.dou... @free.frwrote:
                          Wolfgang Draxinger a écrit :
                          fnegroni wrote:
                          Polymorphism is only one aspect and one you can easily avoid
                          especially for something as simple as a driver.
                          Actually, drivers are, by their very nature, polymorphic, and if
                          you don't use an abstract base class and derive from it, you
                          have to implement by hand what the compiler does.

                          [...]
                          IMHO C++ was once a fine language, but it took some problematic
                          turns.
                          When was it, before the standard (CFront) ?
                          Back in the good ole days (which, of course, weren't so good
                          when we were actually living them).

                          For the rest, of course, there are places in an OS kernel where
                          you would want to restrict the use of certain C++ features---an
                          exception which tries to propagate back through your context
                          switch routine isn't likely to work very well. But off hand,
                          exceptions are about the only C++ feature I see which would
                          cause problems (and then only in specific contexts---which
                          represent less than 10% of the OS). And C++ gives you a lot
                          more safety than C, even when used as a "better C". I can see a
                          lot of OS's sticking with C because that's what they were
                          originally written in, and they're not undergoing active enough
                          evolution to warrent porting to C++, but other than that, it
                          would be foolish and irresponsible not to take advantages of the
                          extra safety C++ provides.

                          --
                          James Kanze (GABI Software) email:james.kan ze@gmail.com
                          Conseils en informatique orientée objet/
                          Beratung in objektorientier ter Datenverarbeitu ng
                          9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

                          Comment

                          • Juha Nieminen

                            #14
                            Re: C++ equivalent to spaghetti code

                            Wolfgang Draxinger wrote:
                            fnegroni wrote:
                            >
                            >>Does Linus Torvalds not like C++?
                            >No, he does not :-)
                            >
                            Well, I know only the comments Linus Torvalds made about the
                            implications of using C++ to develop a kernel. And I totally
                            agree with him in his statements.
                            His statements are not limited to the Linux kernel, and they are
                            completely irrational at times. For example, he states that C++ leads to
                            bad programming practices because of all the "high level stuff" (such as
                            abstraction, data hiding, etc), while C leads to good programming
                            practices precisely because it's so low-level. He also states that
                            programming in the C++ way leads to inefficient code, while programming
                            in C leads automatically to efficient code. Anyone who even considers
                            using things like std::string don't understand anything about efficiency
                            and low-level issues.

                            I have actually written an open letter to him about a really shameful
                            flamewar he participated in, regarding this subject.

                            Comment

                            • Tim Smith

                              #15
                              Re: C++ equivalent to spaghetti code

                              In article <4c15l5-fk5.ln1@darksta rgames.dnsalias .net>,
                              Wolfgang Draxinger <wdraxinger@dar kstargames.dewr ote:
                              Well, I know only the comments Linus Torvalds made about the
                              implications of using C++ to develop a kernel. And I totally
                              agree with him in his statements. Programming a kernel you want
                              to control every bit of the program (yes I know, that this
                              sentence can be interpreted in many ways, and each way totaly
                              matches what I mean).
                              >
                              A languages like C++, that hides (some) vital aspects of the
                              underlying mechanisms can break things at such a low level
                              application. I'm thinking mainly about the way, polymorphism is
                              implemented (there's no standard about that in current C++), how
                              name mangling is performed (dito), calling conventions if
                              objects are passed by reference (dito). Another problem is, that
                              the use of some C++ features (I'm looking at templates here)
                              will start a chain reaction in which code is created generically
                              w/o having any influence on the exact outcome. This is not the
                              same like using macros to create a similair effect; doing it
                              with a macro one must exactly know what's going on.
                              I have yet to encounter a C++ compiler that will refuse to compile a
                              program if it does not use polymorphism, passing objects by reference,
                              and templates. There is nothing forcing someone who writes a kernel in
                              C++ to do those (possibly) questionable things.

                              --
                              --Tim Smith

                              Comment

                              Working...