C++ PROGRAMMING

  • Thread starter Corey C. Carter
  • Start date
C

Corey C. Carter

I am new to programming. Over the years I have "tried" many langauges such
as basic, pascal(yea yea, I know, out of date), python and C. I was under
the impression that one must lean C before moving on to C++. Is that true,
or can I just begin with C++?
 
P

Phlip

Corey said:
I am new to programming. Over the years I have "tried" many langauges such
as basic, pascal(yea yea, I know, out of date), python and C. I was under
the impression that one must lean C before moving on to C++. Is that true,
or can I just begin with C++?

Read /Accelerated C++/. It shows how to treat the C++ Standard Library as a
high-level language. For example, always use std::string, and never deal
with the raw character pointers or arrays that it wraps.
 
D

David Harmon

On Fri, 1 Apr 2005 13:10:13 -0800 in comp.lang.c++, "Corey C. Carter"
the impression that one must lean C before moving on to C++. Is that true,
or can I just begin with C++?

This issue is covered in Marshall Cline's C++ FAQ. See the topic
"[28.2] Should I learn C before I learn OO/C++?" It is always good to
check the FAQ before posting. You can get the FAQ at:
http://www.parashift.com/c++-faq-lite/

See the welcome message posted in comp.lang.c++ under the subject
"Welcome to comp.lang.c++! Read this first." or available at
http://www.slack.net/~shiva/welcome.txt
 
T

Tim Slattery

Corey C. Carter said:
I am new to programming. Over the years I have "tried" many langauges such
as basic, pascal(yea yea, I know, out of date), python and C. I was under
the impression that one must lean C before moving on to C++. Is that true,
or can I just begin with C++?

Not true. You can start with C++.
 
I

Ioannis Vranos

David said:
This issue is covered in Marshall Cline's C++ FAQ. See the topic
"[28.2] Should I learn C before I learn OO/C++?" It is always good to
check the FAQ before posting. You can get the FAQ at:
http://www.parashift.com/c++-faq-lite/

See the welcome message posted in comp.lang.c++ under the subject
"Welcome to comp.lang.c++! Read this first." or available at
http://www.slack.net/~shiva/welcome.txt


The FAQ needs serious fixing in some areas. What is this OO/C++ about?


Check this:

http://groups.google.com/[email protected]&rnum=2
 
A

Andrew McDonagh

Corey said:
I am new to programming. Over the years I have "tried" many langauges such
as basic, pascal(yea yea, I know, out of date), python and C. I was under
the impression that one must lean C before moving on to C++. Is that true,
or can I just begin with C++?

C & c++ are different - one does not and for best results should not
learn C before trying C++

Syntactically they are similar, but then so is Java and C++.

C is a procedural language whereas C++ is an Object Oriented language.

Whilst C++ has a lot of backwards compatibility with C, its only to do
with the mechanics of the languages, rather than the design idioms.

If I was new to programming I certainly would NOT learn C before C++. I
would learn any other OO language before C++.

HTH

Andrew
 
V

Victor Bazarov

Andrew said:
[...]
C is a procedural language whereas C++ is an Object Oriented language.

That's not true. C++ is not an OOL. To quote the father of the language,
it's "a general purpose programming language with a bias towards systems
programming that
- is a better C,
- supports data abstraction,
- supports object-oriented programming, and
- supports generic programming." (TC++PL SE, chapter 2, sec 2.1)
[..]
If I was new to programming I certainly would NOT learn C before C++. I
would learn any other OO language before C++.

That needs a bit of clarification. Why would you learn another OOL before
C++? Why would you even consider learning any other language (except your
own, spoken one) before C++?

V
 
A

Andrew McDonagh

Victor said:
Andrew said:
[...]
C is a procedural language whereas C++ is an Object Oriented language.


That's not true. C++ is not an OOL. To quote the father of the language,
it's "a general purpose programming language with a bias towards systems
programming that
- is a better C,
- supports data abstraction,
- supports object-oriented programming, and
- supports generic programming." (TC++PL SE, chapter 2, sec 2.1)

Whilst that is true to some extent, if we are to gain the most benefits
of C++, IMHO its through its OO-ness.

C++'s backwards compatibility with C was only to aid adoption of the
language. It meant that C programmers could cross train to C++ easier.
The 'father of the language' Stroustrup (book URL below) goes into great
detail of why's and hows of the language is the way it is.

http://www.research.att.com/~bs/3rd.html
http://www.research.att.com/~bs/dne.html

[..]
If I was new to programming I certainly would NOT learn C before C++.
I would learn any other OO language before C++.


That needs a bit of clarification. Why would you learn another OOL before
C++? Why would you even consider learning any other language (except your
own, spoken one) before C++?

V

What I mean, is that if I was too learn any kind of language before
learning C++, then I would learn an OOL rather than a procedural,
functional, etc kind of language.

That said, I personally don't think C++ is the best language to learn at
the same time as learning OO. There are other OOLs that are simpler than
C++, which aid the trainee learn OO skills which can be translated to
any OO language. This is why universities typically (but not
universally) Use Java or Smalltalk when teaching OO.)
 
V

Victor Bazarov

Andrew said:
Victor said:
Andrew said:
[...]
C is a procedural language whereas C++ is an Object Oriented
language.


That's not true. C++ is not an OOL. To quote the father of the
language, it's "a general purpose programming language with a bias
towards systems programming that
- is a better C,
- supports data abstraction,
- supports object-oriented programming, and
- supports generic programming." (TC++PL SE, chapter 2, sec 2.1)

Whilst that is true to some extent,

To "some extent"???
if we are to gain the most
benefits of C++, IMHO its through its OO-ness.

That is unfortunate and quite single-sided view of C++.
C++'s backwards compatibility with C was only to aid adoption of the
language. It meant that C programmers could cross train to C++ easier.

Not only "cross train". Consider millions of lines of code that could
be re-used virtually unchanged.
The 'father of the language' Stroustrup (book URL below) goes into
great detail of why's and hows of the language is the way it is.

I guess the sound of your own voice in your head didn't let you see
that I quoted one of the books you refer to here. Oh well...
http://www.research.att.com/~bs/3rd.html
http://www.research.att.com/~bs/dne.html

[..]
If I was new to programming I certainly would NOT learn C before
C++. I would learn any other OO language before C++.


That needs a bit of clarification. Why would you learn another OOL
before C++? Why would you even consider learning any other language
(except your own, spoken one) before C++?

V

What I mean, is that if I was too learn any kind of language before
learning C++, then I would learn an OOL rather than a procedural,
functional, etc kind of language.

That said, I personally don't think C++ is the best language to learn
at the same time as learning OO. There are other OOLs that are
simpler than C++, which aid the trainee learn OO skills which can be
translated to any OO language. This is why universities typically
(but not universally) Use Java or Smalltalk when teaching OO.)

I can see now that you're fascinated (and pre-ocupied) with OO-ness of
C++. Too bad. C++ has much more to offer.

BTW, Java is definitely not the best representative of OO languages out
there. Teaching it as an example of an OO language is a mistake, IMO.

V
 
E

Evan

C++'s backwards compatibility with C was only to aid adoption of the
language. It meant that C programmers could cross train to C++ easier.
The 'father of the language' Stroustrup (book URL below) goes into great
detail of why's and hows of the language is the way it is.

I've read D&E, and unless I'm vastly mistaken Stroustrup states
explicitly several times that one of the overarching philosophies of
C++ was to not push a particular idiom onto the programmer. If the
programmer wants to use C++ as an OO language, it provides that
functionality; if the programmer wants to use C++ as a procedural
language, "a better C", it provides that functionality.

Stroustrup, to the best of my knowledge, never wished that C++ could
drop the non-OO stuff in the least. It is there so that the programmer
can use it if he or she wishes.
 
S

Stephen Howe

C is a procedural language whereas C++ is an Object Oriented language.

James Coplien wrote a book on C++ called "Multi-Paradigm Design for C++".
See http://www.accu.org/cgi-bin/accu/rvout.cgi?from=0au_c&file=m002014a
for a review.

This endorses the view in the quote that Victor mentioned in that while C++
can be used to write OO code, you need not do so. Other styles (including
procedural) are possible.

Stephen Howe
 
J

John Carson

Corey C. Carter said:
I am new to programming. Over the years I have "tried" many
langauges such as basic, pascal(yea yea, I know, out of date), python
and C. I was under the impression that one must lean C before moving
on to C++. Is that true, or can I just begin with C++?

You can just begin with C++ and most people these days recommend doing that.
The reasons for recommending going straight to C++ are:

1. Learning C you will spend a fair bit of time on stuff that most
well-written C++ programs don't use (though you can generally still use it
in C++ if you want).

2. Learning C means you get into the habit of doing things a certain way and
may then be reluctant to switch to the better ways that C++ offers for some
tasks.

There is an argument on the other side:

1. Learning C forces you to become skilled in some things (notably pointer
manipulation) that are not greatly used in C++ but still need to be mastered
if you are to become really proficient as a C++ programmer. With C, you are
forced to be a little closer to the hardware, which can provide useful
knowledge.

Naturally, there are counter-arguments and counter-counter-arguments and...

Personally, I would recommend against extended study of C if your ultimate
goal is C++. However, it is a toss up whether or not you should read, say,
one C book before starting on C++. Some C++ books assume some level of prior
knowledge of C even when they claim they don't (i.e., they cover the C part
of C++ so quickly that it is rather hard to follow if you have no C
background).
 
I

Ioannis Vranos

Andrew said:
Whilst that is true to some extent, if we are to gain the most benefits
of C++, IMHO its through its OO-ness.


While it is true to full extent, it means that C++ is a multiparadigm language. The best
results are achieved by using the paradigms/combination of paradigms, suitable for a
specific problem.

It supports 4 paradigms, the procedural, the modular, the OO and the generic programming
paradigms. Each paradigm is supported *well* (=completely) with optimal space and time
efficiencies.



These can provide an interesting reading:

http://www.itworld.com/AppDev/710/lw-02-stroustrup/page_1.html

http://www.research.att.com/~bs/oopsla.pdf


C++'s backwards compatibility with C was only to aid adoption of the
language. It meant that C programmers could cross train to C++ easier.
The 'father of the language' Stroustrup (book URL below) goes into great
detail of why's and hows of the language is the way it is.


The procedural programming paradigm support is not provided only for backwards
compatibility with C.


That said, I personally don't think C++ is the best language to learn at
the same time as learning OO. There are other OOLs that are simpler than
C++,


You mean with less OO support, or in other words with crippled OO support. I can't see any
reason for this.

which aid the trainee learn OO skills which can be translated to
any OO language. This is why universities typically (but not
universally) Use Java or Smalltalk when teaching OO.)


I guess it depends on where you are. As far as I know most universities always teach C++
in some place (including OO courses).
 
A

Alf P. Steinbach

* Ioannis Vranos:
David said:
This issue is covered in Marshall Cline's C++ FAQ. See the topic
"[28.2] Should I learn C before I learn OO/C++?" It is always good to
check the FAQ before posting. You can get the FAQ at:
http://www.parashift.com/c++-faq-lite/

See the welcome message posted in comp.lang.c++ under the subject
"Welcome to comp.lang.c++! Read this first." or available at
http://www.slack.net/~shiva/welcome.txt


The FAQ needs serious fixing in some areas. What is this OO/C++ about?


Check this:

http://groups.google.com/[email protected]&rnum=2

Regarding your proposed new

<quote>
[6.2] Is C++ a perfect language?

C++ supports 4 paradigms. It supports the Procedural paradigm, the Object
Oriented paradigm, the Modular paradigm (with namespaces) and the Generic
Programming paradigm (with templates). Each paradigm is supported *well*
with optimal space/time efficiencies.
</quote>

the thing about modular is pure rubbish: C++ does not support modules, and
it just barely enables them, notwithstanding that I think I recall Bjarne
writing something like that. And "each paradigm is supported *well*", that's
pure rubbish: OO isn't supported well, it's supported and that's it (in
particular C++ is very deficient in type safety, as exemplified by pointers to
arrays, and outright wrongheaded in its treatment of objects as assignable).
And "optimal space/time efficiencies", well, that's rubbish too.

As the current wording of that FAQ item says, "[The C++ language] has a few
warts, but the only place where it's appropriate to keep fiddling with
something until it's perfect is in a pure academic setting".

Besides, what's one who feels the need to consult the FAQ about that question
going to do with your answer? It answers nothing, to him or her. I think the
FAQ, on this point, is perfectly okay as it is: it actually answers the q.
 
I

Ioannis Vranos

Alf said:
Regarding your proposed new

<quote>
[6.2] Is C++ a perfect language?

C++ supports 4 paradigms. It supports the Procedural paradigm, the Object
Oriented paradigm, the Modular paradigm (with namespaces) and the Generic
Programming paradigm (with templates). Each paradigm is supported *well*
with optimal space/time efficiencies.
</quote>

the thing about modular is pure rubbish: C++ does not support modules, and
it just barely enables them, notwithstanding that I think I recall Bjarne
writing something like that.


By modular I mean what is mentioned in 2.4 of TC++PL (namespaces).

And "each paradigm is supported *well*", that's
pure rubbish: OO isn't supported well, it's supported and that's it (in
particular C++ is very deficient in type safety, as exemplified by pointers to
arrays, and outright wrongheaded in its treatment of objects as assignable).


I am not talking about type safety, but about paradigm support (single inheritance,
multiple inheritance, virtual inheritance/abstract bases (aka interfaces), virtual bases,
public, protected, private inheritance, public/private access members and so on.

And "optimal space/time efficiencies", well, that's rubbish too.


Why? Run-time/space costs have been taken *seriously* under consideration.

As the current wording of that FAQ item says, "[The C++ language] has a few
warts, but the only place where it's appropriate to keep fiddling with
something until it's perfect is in a pure academic setting".

Besides, what's one who feels the need to consult the FAQ about that question
going to do with your answer? It answers nothing, to him or her. I think the
FAQ, on this point, is perfectly okay as it is: it actually answers the q.


Actually it presents C++ as being an OO non-perfect language.
 
A

Alf P. Steinbach

* Ioannis Vranos:
Alf said:
Regarding your proposed new

<quote>
[6.2] Is C++ a perfect language?

C++ supports 4 paradigms. It supports the Procedural paradigm, the Object
Oriented paradigm, the Modular paradigm (with namespaces) and the Generic
Programming paradigm (with templates). Each paradigm is supported *well*
with optimal space/time efficiencies.
</quote>

the thing about modular is pure rubbish: C++ does not support modules, and
it just barely enables them, notwithstanding that I think I recall Bjarne
writing something like that.


By modular I mean what is mentioned in 2.4 of TC++PL (namespaces).

My TV set supports the modular paradigm, for some irrelevant meaning
of "modular paradigm".

I am not talking about type safety, but about paradigm support (single inheritance,
multiple inheritance, virtual inheritance/abstract bases (aka interfaces), virtual bases,
public, protected, private inheritance, public/private access members and so on.

A reasonable amount of safety, type and otherwise, e.g. object lifetime
management, is a requirement for OO.

C++ is deficient in this aspect, that's reality, and that's what the FAQ's
current wording conveys (in a more general manner).

It's a so far very successful trade-off between OO support and C
compatibility.

Why? Run-time/space costs have been taken *seriously* under consideration.

Yep, at the level of C, where it doesn't matter much today.

As the current wording of that FAQ item says, "[The C++ language] has a few
warts, but the only place where it's appropriate to keep fiddling with
something until it's perfect is in a pure academic setting".

Besides, what's one who feels the need to consult the FAQ about that question
going to do with your answer? It answers nothing, to him or her. I think the
FAQ, on this point, is perfectly okay as it is: it actually answers the q.


Actually it presents C++ as being an OO non-perfect language.

Not quite, but it's right on: the "++" means "with classes", and the language
isn't perfect.
 
I

Ioannis Vranos

Alf said:
A reasonable amount of safety, type and otherwise, e.g. object lifetime
management, is a requirement for OO.


There is a reasonable amount of safety in OO support of C++. Naturally, object lifetime
management is supported by C++. Do you think this is not supported?

C++ is deficient in this aspect,


From the above, it looks like that quite the contrary is the truth.

that's reality, and that's what the FAQ's
current wording conveys (in a more general manner).


Yes, it conveys inaccurate things on this matter.

It's a so far very successful trade-off between OO support and C
compatibility.


I do not think there is much trade-off between the OO paradigm support and C
compatibility. The only trade off is in procedural paradigm type-safety for POD types,
which hasn't anything to do with OO.

Also OO is not related with type safety, these are separate issues. For example, UML is an
OO modelling language. Is there some syntax in it regarding type safety?

And again, the type safety that exists in C++ OO support (=non-POD types) has not anything
to do with C compatibility.


Yep, at the level of C, where it doesn't matter much today.


No, run-time and space efficiencies have been taken under consideration in all paradigms.
For example in virtual methods case, the time-cost of a virtual member function call is
the same regardless the depth of abstraction.

Not quite, but it's right on: the "++" means "with classes", and the language
isn't perfect.


Then you are stuck in a decades old C++. C++ is not "C with classes" any more.


So the FAQ needs updating in this.
 
A

Alf P. Steinbach

* Ioannis Vranos:
There is a reasonable amount of safety in OO support of C++. Naturally, object lifetime
management is supported by C++. Do you think this is not supported?

I don't feel like giving a CS101 course right here, but as _one_ example you
might consider what e.g. "smart pointers" are all about, and how they're
different from references in e.g. Java and C# wrt. polymorphism and supported
data structures.


[snip]
Yes, it conveys inaccurate things on this matter.

Considering the sheer number of very competent people involved in the FAQ
perhaps it's your perception that is inaccurate?

I do not think there is much trade-off between the OO paradigm support and C
compatibility. The only trade off is in procedural paradigm type-safety for POD types,
which hasn't anything to do with OO.

Buy a book.
 
I

Ioannis Vranos

Alf said:
I don't feel like giving a CS101 course right here, but as _one_ example you
might consider what e.g. "smart pointers" are all about, and how they're
different from references in e.g. Java and C# wrt. polymorphism and supported
data structures.

C#/CLI has the garbage collection of a CLI VM. C++ has also access to the same garbage
collection mechanism and other features of a CLI VM (like generics).

In the same way, "Java" are two things. The Java language (the syntax) and the proprietary
Java framework which is closed for other languages. If C++ was allowed to write
applications for the Java framework (JVM), it would also have the JVM's garbage collection
in these applications.


In addition, C++ also provides deterministic destruction (implicit with objects in the
stack and explicit with delete), and that's why in VS 2005 and afterwards, C++ is
considered as the systems programming language of .NET.


Considering the sheer number of very competent people involved in the FAQ
perhaps it's your perception that is inaccurate?


I do not think so. And I am not sure how many are involved, and if the site owner always
listens to them.


Buy a book.


:)
 

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

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,661
Latest member
sxarexu

Latest Threads

Top