C or C++?

W

weidongtom

Hi,

I am a newbie to programming, and sorry again that I have to ask the C
or C++ questions. Is C required before learning C++? And become better
in C does it also make you a better C++ programmer? Or that to be a C+
+ programmer, it's better not to have any knowledge of C and start a
new in the C++ way as some books suggest?
 
R

red floyd

Hi,

I am a newbie to programming, and sorry again that I have to ask the C
or C++ questions. Is C required before learning C++?

No.

And become better
in C does it also make you a better C++ programmer?

Not necessarily. Sometimes you have to "unlearn" some C ways of thinking.

Or that to be a C+
+ programmer, it's better not to have any knowledge of C and start a
new in the C++ way as some books suggest?

Again, not necessarily. C and C++ are two separate languages, much as
many people want to confuse them. However, if you know C++, I suspect
it's easier to learn C (since it's a not-quite-perfect subset of C++).
 
S

Salt_Peter

Hi,

I am a newbie to programming, and sorry again that I have to ask the C
or C++ questions. Is C required before learning C++? And become better
in C does it also make you a better C++ programmer? Or that to be a C+
+ programmer, it's better not to have any knowledge of C and start a
new in the C++ way as some books suggest?

Learn C++ first, C is not required to understand C++.
In many cases, learning C first is a detriment.

[28.2] Should I learn C before I learn OO/C++?
http://www.parashift.com/c++-faq-lite/how-to-learn-cpp.html#faq-28.2

book: Accelerated C++
[28.7] What are some best-of-breed C++ programming-by-example guides?
 
B

Branimir Maksimovic

Hi,

I am a newbie to programming, and sorry again that I have to ask the C
or C++ questions. Is C required before learning C++?

No.

And become better
in C does it also make you a better C++ programmer?

No.

Or that to be a C+
+ programmer, it's better not to have any knowledge of C and start a
new in the C++ way as some books suggest?

Yes.

I have to comment that it is common misconception that C
is required to learn C++ as C++ is based on C.
You can just adopt bad habits from C ;) It is easier
to peek language and work either in C or C++.
C is little bit more then portable assembler and that's
where it is it's power.
But, in order to understand how things work you will
need to learn at least one assembler first.
If you learn assembler beside C++ you can use it in
combination with it , and then you can fully understand C
part of C++.
Rhetorical question:
Why is nobody asking about learning assembler, then C ?:)
It makes much more sense.

Greetings, Branimir.
 
D

Default User

I have to comment that it is common misconception that C
is required to learn C++ as C++ is based on C.

It's also a common misconception that C is a hindrance.
You can just adopt bad habits from C ;)

You can learn bad habits in any language.
C is little bit more then portable assembler and that's
where it is it's power.

This comment indicates that you really know nothing of the C language,
and are just parroting back things others have told you.

C is not in any way shape or form an assembler, portable or otherwise.




Brian
 
B

Bo Persson

Default User wrote:
:: Branimir Maksimovic wrote:
::
::: On May 12, 5:55 am, "(e-mail address removed)" <[email protected]>
::: wrote:
:::: Hi,
::::
:::: I am a newbie to programming, and sorry again that I have to ask
:::: the C or C++ questions. Is C required before learning C++?
::
::: I have to comment that it is common misconception that C
::: is required to learn C++ as C++ is based on C.
::
:: It's also a common misconception that C is a hindrance.
::
::: You can just adopt bad habits from C ;)
::
:: You can learn bad habits in any language.
::

But after learning about malloc(), C string handling, casting, printf, and
using pointers to simulate pass by reference, you have a lot to unlearn. If
you want to learn C++, do that!


Bo Persson
 
B

Branimir Maksimovic

It's also a common misconception that C is a hindrance.

I don;t think so. C community is large and this language is main
tool in it's area.
You can learn bad habits in any language.

Well, I am joking here .
This comment indicates that you really know nothing of the C language,
and are just parroting back things others have told you.

C is not in any way shape or form an assembler, portable or otherwise.

Look, I have learned assembler first, then C.
Things like address of , dereference, pre and post increment/
decrement
operators, C arrays/strings and pointer arithmetic came from assembler
style programming and instruction sets obviously.
I had 17 years when first met C, with previous assembler experience,
I immediately recognized what this language is all about
and felt like home.
Only difference is that C has strict type system, structures,
parameter passing / cleanup is done automatically
and language has higher level constructs like if/switch/for/while ....
But then again any modern assembler have advanced features ,
even support for OO programming ;)
So real question is what can be done with assembly ,
that can't be done with C. In practice, except direct access to
hardware features that are unavailable to language due portability
issues, there are no real differences.
Other question is how C maps to machine code.
If you look at generated code it maps pretty close.
So in theory, yes , C can be very far from real hardware,
but always very close to it's abstract machine which
is in reality pretty close model to real machine
or, if not, (remember dos days?)
there are always non standard extensions to bring it closer;)

Greetings, Branimir.
 
R

Roland Pibinger

I am a newbie to programming, and sorry again that I have to ask the C
or C++ questions.

Why would you want to learn C++ today?
Is C required before learning C++?

No in theory, yes in practice. C++ is an extension of C done in
several evolutionary steps. If you don't know the roots of the
language it just appears weird to you.
And become better
in C does it also make you a better C++ programmer?

Certainly. Many basic programming concepts are the same. Some C++
libraries, e.g. STL, are directly derived from C.
Or that to be a C+
+ programmer, it's better not to have any knowledge of C and start a
new in the C++ way as some books suggest?

This point of view was propagated for some time and it probably left
many students in confusion.
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

Why would you want to learn C++ today?

Why not, it's still one of the most commonly used languages out there
and it's also one of the more advanced ones. I claim that anything you
learn while working with C++ can be of use in other languages as well,
the reverse however is not always true since some other languages are
simplified (to allow faster learning) which makes some constructs
impossible.
No in theory, yes in practice. C++ is an extension of C done in
several evolutionary steps. If you don't know the roots of the
language it just appears weird to you.

Most (I among them) would probably disagree with that statement,
knowledge of C is in no way necessary to learn C++, however if you want
to learn how to use "all" of the C++ language you'll sooner or later
come in contact with the C heritage of C++ and thus will learn how to
program in C also.

The roots of modern C++ (which is mostly concerned with OO and generic
programming and less with procedural programming) are not in C, but
rather Simula and I doubt that you'll recommend the OP to learn that,
will you?
Certainly. Many basic programming concepts are the same. Some C++
libraries, e.g. STL, are directly derived from C.

I'd say perhaps, that depends on which parts of C++ you'll be using, if
you focus on the OO parts you'll have less use of what you learned from
C, if you want to use C++ as C with classes then you'll have more use of it.
This point of view was propagated for some time and it probably left
many students in confusion.

The reason is simple, old habits die hard, and by learning to program in
C first you'll learn a certain "style", certain ways to do thing and
organizing your code, store data and so on. The problem is that C is a
procedural language while C++ is a multi-paradigm language supporting
procedural, object-oriented and generic programming, and all of these
paradigms leads to different "styles". If you learn C first it might be
harder to learn the "styles" needed to efficiently use the other
paradigms and to make the most use of C++ is to use a mix of them.
 
I

Ian Collins

Roland said:
Certainly. Many basic programming concepts are the same. Some C++
libraries, e.g. STL, are directly derived from C.
Do what? How does say, std::vector derive form C? The C standard
library (with some modifications) is part of C++, but that part of the
standard library that used to be know as the STL has nothing to do with C.
 
J

Juha Nieminen

And become better
in C does it also make you a better C++ programmer?

I would say the exact opposite: The "better" you are at C, the
worse you are at C++.

Most "advanced" C programmers have learned tons of kludges to
circumvent the limitations of the language, and in many cases there
are much better and cleaner solutions in C++ for the same things.
The problem with C programmers who have self-taught these kludges
is that the more they have used them, the more difficult is to
unlearn them. Coding too much C also tends to develop resistance to
change and make you prejudiced against C++.
 
D

Default User

Bo said:
Default User wrote:
:: Branimir Maksimovic wrote:
::
::: On May 12, 5:55 am, "(e-mail address removed)" <[email protected]>
::: wrote:
:::: Hi,
::::
:::: I am a newbie to programming, and sorry again that I have to ask
:::: the C or C++ questions. Is C required before learning C++?
::
::: I have to comment that it is common misconception that C
::: is required to learn C++ as C++ is based on C.
::
:: It's also a common misconception that C is a hindrance.
::
::: You can just adopt bad habits from C ;)
::
:: You can learn bad habits in any language.
::

But after learning about malloc(), C string handling, casting,
printf, and using pointers to simulate pass by reference, you have a
lot to unlearn. If you want to learn C++, do that!

That's absolutely true, and you'll see that I never said learning C was
a prerequiste, or even helpful. I'm not sure. I learned C first, as did
many, and found it to be helpful. Others report a different experience.



Brian
 
D

Default User

Branimir said:
Look, I have learned assembler first, then C.

Then you have little excuse for stating such bogus information. That
list of programming language features is no evidence of C being a
"portable assembler".




Brian
 
D

Default User

Juha said:
I would say the exact opposite: The "better" you are at C, the
worse you are at C++.

Most "advanced" C programmers have learned tons of kludges to
circumvent the limitations of the language, and in many cases there
are much better and cleaner solutions in C++ for the same things.
The problem with C programmers who have self-taught these kludges
is that the more they have used them, the more difficult is to
unlearn them. Coding too much C also tends to develop resistance to
change and make you prejudiced against C++.

What a load of crap. Seriously. Most C programmers I know are flexible
and knowledgable in multiple languages.




Brian
 
R

Roland Pibinger

The reason is simple, old habits die hard, and by learning to program in
C first you'll learn a certain "style", certain ways to do thing and
organizing your code, store data and so on. The problem is that C is a
procedural language while C++ is a multi-paradigm language supporting
procedural, object-oriented and generic programming, and all of these
paradigms leads to different "styles". If you learn C first it might be
harder to learn the "styles" needed to efficiently use the other
paradigms and to make the most use of C++ is to use a mix of them.

IMO, that's the "you can't teach old dogs new tricks" myth that is
employed when a new technology isn't adopted by the real world as
expected. We saw it with OOP ("nobody can learn OOP who has been
contaminated with procedural programming") and later - under different
circumstances - with STL or "generic" programming ("nobody can learn
STL who has been contaminated with procedural or OO programming").
It's just a myth.
 
R

Roland Pibinger

Do what? How does say, std::vector derive form C?

STL is a mix of functional programming concepts and C idioms. A
container is an abstraction of a C array, an iterator is an
abstraction of a C pointer and algorithms are designed in C style,
e.g. std::sort has almost the same interface as qsort (sans template
obfuscation). That's pretty obvious. The success of STL among 'geeks'
(and only among them) was mainly driven by the fact that it ditched
(falsely used and overused) OOP and reverted to the C programming
style in new templatized cloths.
 
S

Sherm Pendley

Juha Nieminen said:
The problem with C programmers who have self-taught these kludges
is that the more they have used them, the more difficult is to
unlearn them. Coding too much C also tends to develop resistance to
change and make you prejudiced against C++.

Speak for yourself. Maybe *you* have these difficulties and prejudices,
but I certainly don't - I can adapt to different languages quite easily.

sherm--
 
B

Branimir Maksimovic

Then you have little excuse for stating such bogus information. That
list of programming language features is no evidence of C being a
"portable assembler".

Brian
Let's not be formalists here ;)
Well, I will quote someone who wroted following blog on internet
as I couldn't said it better in my previous post:):

"

C has been the "new assembly language" for at least 20 years. The
problem is too many developers hadn't noticed this.

I think I noticed it first when I read an article about using a
limited subset of C that mapped one-to-one on 68K assembler. The
registers were name d0-d7, a0-a7, you could assign to registers, add
to them, etc., e.g.:
a0=some calculation;
a0+=sizeof(int);
*a0++=d0;

It was eye-opening not because I realized that C could map to
assembler, but because I realized that C was so close to the original
PDP-11 instruction set, which has echoes in 68K.

So C has ALWAYS been "portable assembly language", where "portable"
depends more on the libraries than on anything inherent in the C
language itself.

And I'm referring to original K&R C, not that sissy standardized
thing.

And yeah, that was when I were a lad.

"

To conclude my posting. C is designed to attract assembler
programers. C++ is designed to attract C programmers.
So techniqally, claim that C is required to learn C++
is same one as claim that assembler is required to learn C.
That is my point ;)

Greetings, Branimir.
 
D

Default User

Branimir said:
C has been the "new assembly language" for at least 20 years. The
problem is too many developers hadn't noticed this.

Pure and utter nonsense.
I think I noticed it first when I read an article about using a
limited subset of C that mapped one-to-one on 68K assembler.

What does that have to do with the C language? You could probably do
the same thing with C++.
The
registers were name d0-d7, a0-a7, you could assign to registers, add
to them, etc., e.g.:
a0=some calculation;
a0+=sizeof(int);
*a0++=d0;

That's not something you can do in C.
It was eye-opening not because I realized that C could map to
assembler, but because I realized that C was so close to the original
PDP-11 instruction set, which has echoes in 68K.

No it couldn't. Some particular dialect of pre-standard C could. So
what does ANY of this have to do with the modern C language?
So C has ALWAYS been "portable assembly language", where "portable"
depends more on the libraries than on anything inherent in the C
language itself.

You've produced no evidence at all of that.
And I'm referring to original K&R C, not that sissy standardized
thing.

Ridiculous. Do you make the same references about C++?
To conclude my posting. C is designed to attract assembler
programers.

False. C is a procedural language with robust standard library,
designed to attract programmers who wish to work in a compact language.
C++ is designed to attract C programmers.

I don't believe that to be true either.
So techniqally, claim that C is required to learn C++
is same one as claim that assembler is required to learn C.
That is my point ;)

Your point is bullshit. And all the winkies and other emoticons don't
change that fact.



Brian
 
I

Ian Collins

Branimir said:
C has been the "new assembly language" for at least 20 years. The
problem is too many developers hadn't noticed this.
There's a huge difference between being "close to the machine" and being
a "portable assembler". C++ is as close to the machine as C, but I
don't hear you calling C++ a "portable assembler".

Patch panels, machine code, assembler, C and C++ are just steps along
the evolutionary path of programming languages.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top