473,803 Members | 4,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Jul 15 '08
40 2691
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: he******@jabber .org, ICQ: 134682867

Jul 17 '08 #11
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:ja******* **@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
Jul 18 '08 #12
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:ja******* **@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
Jul 18 '08 #13
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.
http://warp.povusers.org/OpenLetters...oTorvalds.html
Jul 18 '08 #14
In article <4c************ @darkstargames. dnsalias.net>,
Wolfgang Draxinger <wd********@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
Jul 18 '08 #15
On Jul 18, 11:24*pm, Tim Smith <reply_in_gr... @mouse-potato.com>
wrote:
In article <4c15l5-fk5....@darksta rgames.dnsalias .net>,
*Wolfgang Draxinger <wdraxin...@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.

--
you can call it C++ code but without them you are just codding in C
and the trouble is that many high level featuers do not always suit to
kernel programming ,on the other hand C++ is not high level enough for
some tasks such as web programming,mul tithreading ...
In short words today`s C++ cannot be considered as general purpose as
C used to be in good old days.
Q:Is there any alternative?(I mean a true ** modern general purpose
flexible** language with **suitable for mixed-level programming**)?

regards,
FM.
Jul 19 '08 #16
terminator wrote:
Q:Is there any alternative?(I mean a true ** modern general purpose
flexible** language with **suitable for mixed-level programming**)?
If I'm not mistaken Ada was intended to be one, but it never got
widely popular.
Jul 19 '08 #17
On Jul 19, 11:25 am, terminator <farid.mehr...@ gmail.comwrote:
On Jul 18, 11:24 pm, Tim Smith <reply_in_gr... @mouse-potato.com>
wrote:
In article <4c15l5-fk5....@darksta rgames.dnsalias .net>,
Wolfgang Draxinger <wdraxin...@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.
Anyone who codes a kernel without using polymorphism just has to
reimplement it by hand. Ditto passing objects by reference.
And I fail to see any problem with templates, although given
that most of the data structures in a kernel are very
customized, they'll probably be used less than in the
intermediate layers.
you can call it C++ code but without them you are just codding in C
and the trouble is that many high level featuers do not always suit to
kernel programming,
Some (like exceptions) don't, but most do.
on the other hand C++ is not high level enough for
some tasks such as web programming,mul tithreading ...
Funny, I use it for that, with no problem. (Well, I'm not sure
what you consider web programming, but Firefox is written mainly
in C++. But maybe you don't consider that web programming.)
In short words today`s C++ cannot be considered as general
purpose as C used to be in good old days.
C was never really a good general purpose language. It was
never used (nor even usable) in commercial software, for
example.

--
James Kanze (GABI Software) email:ja******* **@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
Jul 20 '08 #18
James Kanze wrote, On 20/07/08 09:23:
On Jul 19, 11:25 am, terminator <farid.mehr...@ gmail.comwrote:
<snip>
>In short words today`s C++ cannot be considered as general
purpose as C used to be in good old days.

C was never really a good general purpose language. It was
never used (nor even usable) in commercial software, for
example.
The company I currently work for was initially built on selling SW
written in C to large UK corporations. We still do a lot of business
with that old SW which is still mostly written in C.
--
Flash Gordon
Jul 20 '08 #19
James Kanze said:

<snip>
C was never really a good general purpose language. It was
never used (nor even usable) in commercial software, for
example.
So MS Windows is not commercial software? Interesting.

(Early versions of MS Windows were written almost entirely in C.)

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 20 '08 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1763
by: Brent Mondoux | last post by:
Hey everyone, I'm trying to find the best non-spaghetti code way to do the equivalent of a ColdFusion CFQUERY GROUP command so that I can display a FAQ with categories as follows: -- Example: Begin -- General
7
2050
by: CoreyWhite | last post by:
You know what I have to say to the giant spaghetti monster? Do you want to know? Do you? Well I'm tired of sucking on your spaghetti and chewing on your fresh meat balls! It isn't only about writing open source code that's free. That's obviously nice. But the Open Source code just facillitates all of this negative energy in the world, the same as the Windows Operating system and the Giant
0
1286
by: CoreyWhite | last post by:
In any kind of communication and language, even in computer programming. We can see a difference between total spaghetti and celtic knot work. But it is easy to confuse the two, because sometimes a ball of spaghetti still makes sense and sometimes celtic knot work is total nonsense. I don't look at religion as spaghetti, and I don't look at my own writting as spaghetti. The philosophers, thinkers, and intellectuals who create beautiful...
20
6683
by: Victor Smootbank | last post by:
I did program in BASIC for more than 20 years and for me it's still the ultimate programming language. Unfortunately, I was forced to upgrade to C++ and now I'm confused. While programming in BASIC, my favourites were GOTOs and sometimes GOSUBs and spaghetti code was my trademark. How can I write spaghetti code in C++???
35
247
by: Campy Happer | last post by:
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.
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.