473,729 Members | 2,328 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 #1
43 1850
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

--
Max
Oct 24 '08 #2
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, or support for generic programming,
an "improved" C, but IMHO, that's stretching it. I suspect,
however, that what the friends of the original poster were
criticizing is C++'s C-ness; it does inherit a number of
problems (e.g. declaration syntax) from 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
Oct 24 '08 #3
"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?
IMO, the best place to get an answer for that kind of question is in the
link below..

http://www.research.att.com/~bs/bs_faq.html
Oct 24 '08 #4

"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

Oct 24 '08 #5
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 claim is completely
ridiculous for two reasons:

1) Anything you can do in C, you can do in C++.
2) You are not forced to use anything extra in C++ if you don't want to.

The only way C++ could even theoretically be worse than C would be if
you were *forced* to do something in C++ which you don't have to do in
C, and this something is detrimental to the program. However, C++ does
not force you to do *anything* you couldn't do in C as well. Anything
you can do in C, you can do in C++. Thus the very claim that "C++ is
worse than C" is plain BS.

For example one could argue that, let's say, "Java is worse than C",
and there can plausibly be rational reasons for this claim because in
Java you are forced to do things rather differently than in C. For
example in Java you are *forced* to write classes, which you don't have
to do in C. Java does not support everything C supports (at least not
verbatim).

Now, if the claim was changed to "what C++ adds to C only makes the
language worse", it could make even a little bit of sense. Of course
this claim is also complete BS, but at least it's a more logical and
sensible statement.

The hilarious thing about C++-hating C-hackers is that it's rather
easy to make them squirm: Just challenge them to implement a small
simple program which handles dynamic memory, to compare the simplicity
and safety of the equivalent C and C++ implementations . Then just sit
back and be entertained by the (often surprisingly) imaginative ways
they will try to cheat their way out of the problem (because they really
*don't* want to compare C and C++ implementations of the problem
side-by-side).
Oct 24 '08 #6
On Oct 24, 11:43*pm, Juha Nieminen <nos...@thanks. invalidwrote:
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 claim is
completely ridiculous for two reasons:
1) Anything you can do in C, you can do in C++.
That's not true:

int
main()
{
someFunction( 42 ) ;
return 0 ;
}

is a perfectly legal C program (supposing someFunction defined
in some other translation unit), but not a legal C++ function.
Among the things that you can do in C, but not in C++, are:

-- not declare external functions, then call them with the
wrong number or type of arguments,

-- assign a void* to a typed pointer, regardless of type, with
no explicit conversion to warn you that something extremely
dangerous is going on.

There are probably others, but these two come immediately to
mind.

Whether these possibilities can in any possible way be
considered an improvement, I leave to the judgement of the
reader.

In C99, there are a couple of more things you can do, like
VLA's and designated initializers. But since most of the people
who prefer C over C++ also reject C99, I'll not go into those.

--
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 25 '08 #7
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++".

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.

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).
Oct 25 '08 #8
SG
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? Try inheriting from
more than one abstract class. :-) My point is: You can code "OO style"
in plain C. But it's gonna be verbose and error-prone. 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)

Cheers,
SG
Oct 25 '08 #9
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.

--
Ian Collins
Oct 25 '08 #10

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

Similar topics

220
19104
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
2032
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
3463
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
3417
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
2580
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
2710
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
1867
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
2361
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
3084
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
3576
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
8921
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
9427
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...
1
9202
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
9148
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...
0
8151
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
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
4528
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.