Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > As a programmer of both languages...

Reply
Thread Tools

As a programmer of both languages...

 
 
Ian Collins
Guest
Posts: n/a
 
      12-12-2007
jacob navia wrote:
> Ian Collins wrote:
>> jacob navia wrote:
>>> Ian Collins wrote:
>>>> jacob navia wrote:
>>>>
>>>>> The difference between C and C++ is the object orientation of C++.
>>>>> C is
>>>>> not object oriented.
>>>>>
>>>> Are you really dense, or just being obtuse? As you have been told many
>>>> times before, C++ is a multi paradigm language. You can *choose* to
>>>> write OO or procedural code in C++.
>>>>
>>> You can't program in C++ without using classes. Even if you define
>>> a simple structure it is actually a class.
>>>

>> Your ignorance continues to astound. Maybe you should take some time
>> out and learn C++ before slagging it off.
>>

>
> Yes Sir!
>
> struct A {
> int age;
> char *Name;
> };
>
> int main(void)
> {
> A jacob;
> }
>
> This is valid C++ but invalid C. In C++ each "structure" definition
> is just a CLASS where all members are PUBLIC by default. I see this
> explanation in all C++ books I read but in my ignorance I believe
> them. Stupid isn't it?
>

What's your point? The fact that struct is close to a synonym for class
is irrelevant. Your example struct is equally valid in both languages,
C++ treats it exactly the same as C. Saying you can't write anything
useful in C++ without classes is like saying you can't write anything
useful in C without using structs. In both languages we represent
collections of data in structures.
>
>>> Maybe, who knows what buzzword will be invented in the future, but
>>> the fact is that without classes you just can't do anything at all in
>>> C++.
>>>

>> If everything C does plus quite a bit more (like your beloved operator
>> overloading) amounts to nothing.....
>>

>
> You are just playing word games, a favorite sport in this group.
> Of course you can write programs in C and compile them with C++,
> modulo some differences it is possible.


That's not what I said. Are function templates OO? Is function
overloading OO? Are exceptions OO?

Does your beloved operator overloading make sense without structs?

> I would be surprised that you
> can use the STL without using implicitly a class!!!
>

Many of the C++ standard library algorithms work equally well with
pointers. Very little of the STL is OO, which ironically is a common
criticism of it from OO purists.

All of the extensions to C you keep pushing are available in standard
C++, today.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      12-12-2007
jacob navia said:

> Ian Collins wrote:
>> jacob navia wrote:
>>> Ian Collins wrote:
>>>> jacob navia wrote:
>>>>
>>>>> The difference between C and C++ is the object orientation of C++. C
>>>>> is not object oriented.
>>>>>
>>>> Are you really dense, or just being obtuse? As you have been told
>>>> many
>>>> times before, C++ is a multi paradigm language. You can *choose* to
>>>> write OO or procedural code in C++.
>>>>
>>> You can't program in C++ without using classes. Even if you define
>>> a simple structure it is actually a class.
>>>

>> Your ignorance continues to astound. Maybe you should take some time
>> out and learn C++ before slagging it off.
>>

>
> Yes Sir!
>
> struct A {
> int age;
> char *Name;
> };
>
> int main(void)
> {
> A jacob;
> }
>
> This is valid C++ but invalid C.


Yes, for reasons which have nothing to do with classes.


> In C++ each "structure" definition
> is just a CLASS where all members are PUBLIC by default.


Stroustrup says much the same thing, albeit more quietly. But it can be
said just as correctly (or incorrectly) that, in C++, each "class"
definition is just a struct where all members are private by default. So
if the claim is that C++ is "all about classes" (which I don't accept),
then it can just as logically be said that C++ is "all about structs".
And, just as it is possible in C to write programs - *useful* programs -
that don't use structs, so it is possible in C++ to write useful programs
that don't use classes.

> I see this
> explanation in all C++ books I read but in my ignorance I believe
> them. Stupid isn't it?


Yes - if you really want to know what a C++ struct is, the place to look is
ISO/IEC 14882.

<snip>

> If you write
>
> int main(void) { printf("hello\n");}
>
> you do not need classes but is it C++?


The behaviour of that program, either in C or in C++, is undefined. (I
believe that C++ even requires a diagnostic message to be produced during
translation of that program.) If you want people to treat your views about
C seriously, you might want to start off by learning enough about C that
you can write a simple "hello" program properly.


<snip>


--
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
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      12-12-2007
jacob navia wrote:
>
> struct A {
> int age;
> char *Name;
> };
>
> int main(void)
> {
> A jacob;
> }
>
> This is valid C++ but invalid C. In C++ each "structure" definition
> is just a CLASS where all members are PUBLIC by default. I see this
> explanation in all C++ books I read but in my ignorance I believe
> them. Stupid isn't it?
>

I think I see your conceptual problem, do you claim that

class A {
public:
int age;
char *Name;
};

Is OO while

struct A {
int age;
char *Name;
};

isn't?

You appear to be confusing the use of structures with object orientation.

One can choose to write OO code in C or in C++. The choice depends of
the nature of the problem. One of the cleanest OO designs I have seen
is the old OpenView GUI toolkit, a textbook example of OO C.

--
Ian Collins.
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      12-12-2007
Richard Heathfield, the pedant in chief wrote:
>> If you write
>>
>> int main(void) { printf("hello\n");}
>>
>> you do not need classes but is it C++?

>
> The behaviour of that program, either in C or in C++, is undefined. (I
> believe that C++ even requires a diagnostic message to be produced during
> translation of that program.) If you want people to treat your views about
> C seriously, you might want to start off by learning enough about C that
> you can write a simple "hello" program properly.
>


All this crap because there wasn't an

#include <stdio.h>

I am not compiling heathfield. I am writing to people, and
people can understand (contrary to compilers that can't)



--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      12-12-2007
Ian Collins wrote:
> What's your point? The fact that struct is close to a synonym for class
> is irrelevant. Your example struct is equally valid in both languages,
> C++ treats it exactly the same as C. Saying you can't write anything
> useful in C++ without classes is like saying you can't write anything
> useful in C without using structs.


I have never written anything serious in C without using data types and
structures. Even a "hello world" program needs stdio.h that has (at
least) the definition of FILE.

Structures are central to C, as classes are to C++.

> In both languages we represent
> collections of data in structures.


C++ uses inheritance. Didn't know that you can inherit from a C
structure.

>>>> Maybe, who knows what buzzword will be invented in the future, but
>>>> the fact is that without classes you just can't do anything at all in
>>>> C++.
>>>>
>>> If everything C does plus quite a bit more (like your beloved operator
>>> overloading) amounts to nothing.....
>>>

>> You are just playing word games, a favorite sport in this group.
>> Of course you can write programs in C and compile them with C++,
>> modulo some differences it is possible.

>
> That's not what I said. Are function templates OO? Is function
> overloading OO? Are exceptions OO?
>


Exceptions are objects in C++. The exceptions I am proposing for C
aren't objects but just integer error codes, what is quite different.

>
> All of the extensions to C you keep pushing are available in standard
> C++, today.
>


Yes, and so what?

Why wouldn't those extensions be acceptable then?

Why must C be frozen for the benefit of C++?

This attitude:

"The better C is C++, improving C has no sense" has destroyed any
development of the language and left us with bugs that are fixed
forever in some distant past.

It is time to stop this situation.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      12-12-2007
jacob navia said:

<snip>

> All this crap because there wasn't an
>
> #include <stdio.h>


The "crap", as you put it, is in the code you posted. You asked whether it
was a C++ program, and I answered your question. If you don't want
answers, don't ask questions.

> I am not compiling heathfield. I am writing to people, and
> people can understand (contrary to compilers that can't)


People understand better than you realise.

--
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
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      12-12-2007
jacob navia said:

> Ian Collins wrote:
>> What's your point? The fact that struct is close to a synonym for class
>> is irrelevant. Your example struct is equally valid in both languages,
>> C++ treats it exactly the same as C. Saying you can't write anything
>> useful in C++ without classes is like saying you can't write anything
>> useful in C without using structs.

>
> I have never written anything serious in C without using data types and
> structures.


A C program that did not use any data types would be astoundingly empty.
But if you have *never* written anything serious in C that didn't use a
structure, this says less about C than it does about the limits of your
programming experience. Are you really sure that you meant to say that?

> Structures are central to C, as classes are to C++.


Structures are important, but I wouldn't say they were central.

>> In both languages we represent
>> collections of data in structures.

>
> C++ uses inheritance. Didn't know that you can inherit from a C
> structure.


He didn't claim otherwise.

<snip>

>> All of the extensions to C you keep pushing are available in standard
>> C++, today.
>>

>
> Yes, and so what?


So if people want them, they'll use C++. If people want their *absence*,
for reasons of simplicity or portability or whatever, they'll use C. You
do C no favours by trying to move it closer to C++.

<snip>

--
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
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      12-12-2007
Richard Heathfield wrote:
> jacob navia said:
>> I have never written anything serious in C without using data types and
>> structures.

>
> A C program that did not use any data types would be astoundingly empty.
> But if you have *never* written anything serious in C that didn't use a
> structure, this says less about C than it does about the limits of your
> programming experience. Are you really sure that you meant to say that?
>


If I #include <stdio.h> I include the definition of FILE, that is
a structure... If I include time.h I include several structures in
there, as in stdlib.h that defines div_t and others...

Really, I can't imagine a program not using a structure definition!

Of course, you can find a contrived example but... let's be realistic.


--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      12-12-2007
jacob navia said:

> Richard Heathfield wrote:
>> jacob navia said:
>>> I have never written anything serious in C without using data types and
>>> structures.

>>
>> A C program that did not use any data types would be astoundingly empty.
>> But if you have *never* written anything serious in C that didn't use a
>> structure, this says less about C than it does about the limits of your
>> programming experience. Are you really sure that you meant to say that?
>>

>
> If I #include <stdio.h> I include the definition of FILE, that is
> a structure...


FILE isn't actually required to be a structure. It is "an object type
capable of recording all the information needed to control a stream,
including its file position indicator, a pointer to its associated buffer,
an error indicator that records whether a read/write error has occurred,
and an end-of-file indicator that records whether the end of the file has
been reached", which does seem to suggest that a structure is a sensible
implementation, but it's *not* actually required by the Standard. So a
program that uses streams may or may not be using structures - you can't
actually tell. Certainly the visible code (for who in their right mind
pokes about in standard headers?) bears no evidence of the use of structs
where FILEs are concerned.

But anyway, it is now clear that you regard including a header that
contains a structure type definition as somehow "using" that structure,
regardless of whether the structure type is referred to within the C
source itself, in which case your statement is pretty meaningless really.

--
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
 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      12-12-2007
On 11 Dec, 18:31, "Tomás Ó hÉilidhe" <t...@lavabit.com> wrote:

> There seems to be constant vacuous debate about which is better or
> preferable, C or C++, and it looks like one of these discussions is on-
> going right now in this newsgroup.
>
> I'm a programmer who started out in C++, and who's currently doing
> an embedded systems project in C. The relationship and comparison
> between the two languages is very simple in my opinion.
>
> The objective of C++ was to build upon C; to take everything that C
> can do, and then add a few more features, such as classes, operator
> overloading, and exceptions.


"a few"! You missed templates (and consequently the STL).

- inline
- references


> Overlooking the small differences between the common subset of the
> two languages (e.g. converting from void*, the type of character
> literals), it's quite accurate to say that C++ is C with some more added
> features.


C with a large pile of new features...


> So at the most basic, you can say that C++ is better than C in that
> it can do everything C can does, and that it has a few more extra
> features.


that's not the way I use "better". I'm not knocking C++. I like C++.
But X isn't "better" than Y because it does more. Would you carve
your dinner with a Swiss Army Knife?

I can claim to pretty well know C.

Admittedly I've never used signal.h, locale.h, float.h, wctype.h,
longjmp.h or volatile. I've used goto once and seen register and
continue in other people's programs. I know auto is a keyword.

Ok so I don't *really* know C.

C++ is a a tougher nut. I've just about grasped what to put in
my thrown objects but I would not dare claim to have reached the
dizzy heights of "Exception Safe". algorithm slightly scares me.
STL error messages almost don't frighten me anymore. I've barely
touched templates and the only namespace I've used is std.
Then there's Template Metaprogramming...

Should all my virtual functions be protected?


> That's great and all, but the price to pay for these extra
> features is the increased complexity of the compiler.


riight. So C++ *isn't* an unqualified "better"?


> I'm currently
> writing a program for the PIC 16F684 microcontroller (which is less than
> the size of a postage stamp),


I'm amazed it's so large. Isn't that the size of a pentium? Or do
you have very small stamps where you come from?


> and there wouldn't be a snowball's chance
> in hell of me finding a C++ compiler for it. Why? Because nobody's
> bothered writing one. I mean *have* *you* *seen* the size of the C++
> Standard? :-O


yup. I even have access to a hardcopy. And you then need a book on
STL and Myers books and...


> Not only that, but when programming for embedded systems,
> the nature of the programs doesn't tend to give rise to a desire for
> object-orientated programming. The current program I'm writing is a
> Connect4 game, and there hasn't be one instance yet in which I've
> yearned for object orientation (even though I use classes extensively
> when writing PC applications).


I suppose it depends how embedded, embedded is. Designing OO still
makes sense. Protocols often look like inheritance trees.


> So my own point of view is that while C++ is the programming
> language to be used today for PC's, game consoles and the like, C is
> still the king when it comes to embedded systems, and that doesn't seem
> like changing any time soon. And for the less-than-proficient among us,
> there's Java for PC's, and Basic for micrcontrollers.


Basic? Basic for microcontrollers? ug.



--
Nick Keighley

"If you think C++ is not overly complicated, just what is a protected
abstract virtual base pure virtual private destructor, and when
was the last time you needed one?"
-- Tom Cargil, C++ Journal.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent positions: Sr Programmer Analyst (SPA) and Programmer Analyst(PRA)-06+month's- Carson City, NV. Isaac Java 0 12-08-2010 05:34 PM
Who gets higher salary a Java Programmer or a C++ Programmer? Sanny Java 391 01-06-2010 02:48 AM
Who gets higher salary a Java Programmer or a C++ Programmer? Sanny C++ 396 12-17-2008 06:13 PM
compilation error: file exists in both in both 'c:\WINNT\Microsoft.NET\Framework\v2.0.50727 ABCL ASP .Net 0 05-29-2008 04:59 PM
2 computers, both online, both invisible to each other ? b Computer Support 9 04-21-2006 04:06 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57