473,757 Members | 7,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is c++ only better c ?

I've read somewhere that c++ is something more than better c ... then
I talk with my friend and he claimed that c++ is nothing more than
better c ... I tried to explain him that he was wrong but I forgot all
arguments about it. Could someone told something about it?
Oct 24 '08
43 1861

"SG" <s.********@gma il.comwrote in message
news:f5******** *************** ***********@i76 g2000hsf.google groups.com...
On 24 Okt., 21:44, "Chris M. Thomasson" <n...@spam.inva lidwrote:
>You can get "fairly clean" abstract interfaces in C; something as simple
as;
quick code scribbling - may have typo:

[... C++ abstract class and virtual function emulation in plain C ...]

There... simple!

Well, that was a really simple case, wasn't it?
Indeed. Although, I personally like to use the minimalist technique I
described for plug-in frameworks.

Try inheriting from more than one abstract class. :-)
Ouch! :^(

My point is: You can code "OO style"
in plain C. But it's gonna be verbose and error-prone.
Fair enough.

I have to admit
I didn't try any of the available frameworks for "OO-emulation in
plain C" (like GObject). Spending time learning these frameworks
instead of learning C++ doesn't seem like a good choice to me since C+
+ has other neat things to offer:
- RAII (one of the biggest selling points IMHO)
- support for generic programming (via templates, also big selling
point)
Agreed.

Oct 25 '08 #11
Pawel_Iks wrote:
I've read somewhere that c++ is something more than better c ... then
I talk with my friend and he claimed that c++ is nothing more than
better c ... I tried to explain him that he was wrong but I forgot all
arguments about it. Could someone told something about it?
Do you write code in either of those languages?
Oct 25 '08 #12
Ian Collins wrote:
They tend to work them selves up into a lather about the added
complexity of C++ while refusing to acknowledge the complexity is optional.
What bothers me the most with their argument about "added complexity"
is that it feels like they have actually never even tried this "added
complexity" they are talking about.

The basic mistake in thinking is that "more features" equals to "more
complexity", which equals to "the language is harder to use and
understand". They emphasize that C is good because it's so simple.

There is no such equality. More features don't automatically make the
language more complex. In fact, it's often the exact opposite: More
features can make using the language *simpler*, not more complicated.
Oct 25 '08 #13
Pawel_Iks wrote:
I've read somewhere that c++ is something more than better c ... then
I talk with my friend and he claimed that c++ is nothing more than
better c ... I tried to explain him that he was wrong but I forgot all
arguments about it. Could someone told something about it?
I think that this is just an argument about semantics. If you say "C++
is something more than just a better C" that sentence has a positive
exalting tone to it, but if you say "C++ is nothing more than a better
C" that sentence has a belittling and unappreciating tone. In the end,
both sentences are saying the exact same thing. There's just a
difference in attitude.
Oct 25 '08 #14
On Oct 24, 2:44*pm, "Chris M. Thomasson" <no@spam.invali dwrote:
"James Kanze" <ja*********@gm ail.comwrote in message

news:de******** *************** ***********@34g 2000hsh.googleg roups.com...
On Oct 24, 11:55 am, Maxim Yegorushkin <maxim.yegorush ...@gmail.com>
wrote:
On Oct 24, 10:27 am, Pawel_Iks <pawel.labed... @gmail.comwrote :
I've read somewhere that c++ is something more than better c
... then I talk with my friend and he claimed that c++ is
nothing more than better c ... I tried to explain him that
he was wrong but I forgot all arguments about it. Could
someone told something about it?
Some actually consider C++ to be worse than
C:http://esr.ibiblio.org/?p=532
You'll find some idiot to defend just about any position. *(Not
that all people who are critical of C++ are idiots. *But the
intelligent ones don't like C either; the real problem with C++
is that it inherits too much from C.)
C++ definitely improves C. *It also adds a lot of things which
support idioms which aren't supported in C. *I suppose that you
could call support for OO,

[...]

You can get "fairly clean" abstract interfaces in C; something as simple as;
quick code scribbling - may have typo:

IShape.h
--------------------------------------------
struct IShape_VTable {
* void (*IObject_Destr oy) (void*);
* void (*IShape_Draw) (void*);
* /* ect... */

};

struct IShape {
* struct IShape_VTable* VTable;

};

#define IObject_Destroy (Self) ( \
* (Self)->VTable->IObject_Destro y((Self)) \
)

#define IShape_Draw(sel f) ( \
* (Self)->VTable->IShape_Draw((S elf)) \
)

That all the infrastructure. Now to create actual shapes...

Circle.h
--------------------------------------------
extern struct IShape*
Circle_Create(
*/* ... */
);

Circle.c
--------------------------------------------
#include "Circle.h"
#include <stdlib.h>

static void Circle_IObject_ Destroy(void*);
static void Circle_IShape_D raw(void*);

static struct IShape_VTable Circle_VTable = {
* Circle_IObject_ Destroy,
* Circle_IShape_D raw

};

struct Circle {
* struct IShape IShape;
* /* ... */

};

struct IShape*
Circle_Create(
*/* ... */
) {
* struct Circle* Self = malloc(*Self);
* if (Self) {
* * Self->IShape.VTabl e = &Circle_VTab le;
* * return &Self->IShape;
* }
* return NULL;

}

void
Circle_IObject_ Destroy(
*void* IObject
) {
* free(IObject);

}

void
Circle_IShape_D raw(
*void* IShape
) {
* struct Circle* const Self = IShape;
* /* ... */

}

Now, finally we can use the Circle via. the abstract interfaces IShape and
IObject:

main.c
--------------------------------------
#include "Circle.h"

int main(void) {
* struct IShape* Shape = Circle_Create(/* ... */);
* IShape_Draw(Sha pe);
* IObject_Destroy (Shape);
* return 0;

}

There... simple!

;^D
I used to code C in ways very similar to that, but it's a total
nightmare. It's not what C was designed for, and it's not the way to
code it (incidentally, it's the only *productive* way to code it!).

It's basically a faking of basic OO concepts such as an abstract type
with operations bundled to it, and it can be a clean way to code basic
applications. At a large scale, however, the lack of language support
for these programming techniques leads to a great deal of verbosity
and boilerplate code, almost to the point where the disadvantages
outweigh the advantages (it even increases the risk of memory leaks!).

C just isn't a good scaling language.

Sebastian

Oct 25 '08 #15
In article <6m************ @mid.individual .net>, Ian Collins
<ia******@hotma il.comwrote:
Juha Nieminen wrote:

Of if I put that in other terms: If someone considered C++ to be worse
exclusively because you have to declare functions before you use them,
that would be a rather stupid and trivial argument. When C hackers bash
C++, they are not talking about function declarations and void pointers,
they are talking about what C++ *adds* to the language that C doesn't
have (such as templates).

They tend to work them selves up into a lather about the added
complexity of C++ while refusing to acknowledge the complexity is optional.
Won't someone think of the compiler writers???

That's a common argument I hear when it is pointed out that one can use
C++ as (almost) straight C, "extreme" C++, or anything inbetween.
Oct 26 '08 #16
On Oct 25, 11:33*am, Ian Collins <ian-n...@hotmail.co mwrote:
Juha Nieminen wrote:
Of if I put that in other terms: If someone considered C++
to be worse exclusively because you have to declare
functions before you use them, that would be a rather stupid
and trivial argument. When C hackers bash C++, they are not
talking about function declarations and void pointers, they
are talking about what C++ *adds* to the language that C
doesn't have (such as templates).
They tend to work them selves up into a lather about the added
complexity of C++ while refusing to acknowledge the complexity
is optional.
I believe it was Robert Martin that first pointed it out, but
the complexity is always there; it's inherit in the application.
In the case of C++, that complexity manifests itself in the
language; in the case of C, in the code we have to write to
solve the problem. Which means that in the case of C++, we have
to master it once, for all applications; in the case of C, we
have to master it for each application.

--
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
Oct 26 '08 #17
On Oct 25, 10:37*am, Juha Nieminen <nos...@thanks. invalidwrote:
James Kanze wrote:
1) Anything you can do in C, you can do in C++.
That's not true:
I didn't say "any C program is a valid C++ program". What I
said was "anything you can do in C, you can do in C++".
I'm not sure then what your point is. Both are Turing complete.
So is assembler, and Basic, and just about every other
language. What makes some people prefer C to C++ is that you
can do things in C that you can't do in C++, at the coding
level. Of course, these things are very bad software
engineering (like using a function without having declared it
first), but that's the way it is.
Sure, there are a few cases where the type system of C++ is
slightly stricter than C's (although I'm a bit surprised this
is still the case with C99), but I wouldn't say that's a very
radical difference.
The fact that you don't have to include headers to use a
function is IMHO a radical difference. I *think* this feature
was deprecated in C99; I'm not sure. But the people who prefer
C over C++ generally eschew C99 as well.
Of if I put that in other terms: If someone considered C++ to
be worse exclusively because you have to declare functions
before you use them, that would be a rather stupid and trivial
argument. When C hackers bash C++, they are not talking about
function declarations and void pointers, they are talking
about what C++ *adds* to the language that C doesn't have
(such as templates).
Have you looked at their code? I know what they say, but I also
know what they do.

--
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
Oct 26 '08 #18
Juha Nieminen wrote:
Pawel_Iks wrote:
>I've read somewhere that c++ is something more than better c ... then
I talk with my friend and he claimed that c++ is nothing more than
better c ... I tried to explain him that he was wrong but I forgot all
arguments about it. Could someone told something about it?

I think that this is just an argument about semantics. If you say "C++
is something more than just a better C" that sentence has a positive
exalting tone to it, but if you say "C++ is nothing more than a better
C" that sentence has a belittling and unappreciating tone. In the end,
both sentences are saying the exact same thing. There's just a
difference in attitude.
Huh? "Something" != "nothing"; that's not just a different tone, it's
an altogether different meaning.
Oct 26 '08 #19
Juha Nieminen <no****@thanks. invalidkirjutas :
Maxim Yegorushkin wrote:
>Some actually consider C++ to be worse than C

In my personal opinion those are delusional prejudiced people who
suffer from a huge resistance of change.
The main difference IMO is that in C one has full control over the language
and does know exactly what code is generated. It is possible to gain the
about the same amount of control in C++, but it takes quite a long learning
curve to achieve. The need of control is always justified by performance
needs (either real or perceived), but I am quite sure that many people just
want to have maximum control as a rule and would prefer to code in
assembler if it was even slightly feasible. This is actually a strong point
in favor of C++, as here one can use or build much more powerful toys for
controlling the application, whereas retaining fine-grained control over
the code where needed.

In practical viewpoint, the main issue in switching from C to C++ is the
const correctness. Binding a temporary to a reference needs 'const' by the
language, and as soon as you bring one const in, it can trigger a avalanche
of needed consts all over the code base, the necessity of which is quite
difficult to explain to a seasoned C hacker.

Paavo
Oct 26 '08 #20

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

Similar topics

220
19136
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
3
2033
by: Muhd | last post by:
<usualDisclaimer>Please forgive me if this is in the wrong group, and if so, what is the right group.</usualDisclaimer> Let me start off by first saying im a newb. Ok, with that out of the way I am trying really hard and boy have I learned a lot in the last little while but I have a question i just can't seem to find a good answer to. Lets say i have a table that simply stores how many times someone has logged into a webpage. Is it...
24
3475
by: Faith Dorell | last post by:
I really don´t like C.You can write better programs in BASIC than in C, if you don´t like this language. I don´t understand how C became so popular, although much better programming languages existed in the 70s or 80s or 90s. Pascal is much better.
43
3422
by: Rob R. Ainscough | last post by:
I realize I'm learning web development and there is a STEEP learning curve, but so far I've had to learn: HTML XML JavaScript ASP.NET using VB.NET ..NET Framework ADO.NET SSL
33
2588
by: Protoman | last post by:
Which is better for general-purpose programming, C or C++? My friend says C++, but I'm not sure. Please enlighten me. Thanks!!!!!
22
2721
by: JoeC | last post by:
I am working on another game project and it is comming along. It is an improvment over a previous version I wrote. I am trying to write better programs and often wonder how to get better at programming. I tend to learn what is useful and gets the job done. I am always curious if there is some techique I don't know. I read books and study as well as write programs. My goal is to some day be able to get a job programming. I have a...
19
1869
by: Alexandre Badez | last post by:
I'm just wondering, if I could write a in a "better" way this code lMandatory = lOptional = for arg in cls.dArguments: if arg is True: lMandatory.append(arg) else: lOptional.append(arg) return (lMandatory, lOptional)
23
2367
by: mike3 | last post by:
Hi. (posted to both newsgroups since I was not sure of which would be appropriate for this question or how specific to the given language it is. If one of them is inappropriate, just don't send replies to it.) I'm making a bignum package for use in a program I've got (this is something different from the pi program you may have heard about). The package is going to support manipulating long floating point numbers.
20
3091
by: mike3 | last post by:
Hi. (Xposted to both comp.lang.c++ and comp.programming since I've got questions related to both C++ language and general programming) I've got the following C++ code. The first routine runs in like 65% of the time of the second routine. Yet both do the same thing. However, the second one seems better in terms of the way the code is written since it helps encapsulate the transformation in the inner loop better making it easier to read,...
3
3577
by: Ryan Liu | last post by:
Hi, Is Async I/O (e.g. NetworkStream.Begin/End Read/Write) always better than synchronous I/O? At least as good? When I don't concern about easy or difficult to write code, should I always use Async I/O?
0
9298
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
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
9885
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
9737
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
7286
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
6562
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();...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
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

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.