Which to learn first C or C++?

D

dydx13

Hello,
I'm currently attending a university majoring in Computer Science.
I took C and C++ at a community college and got an A in both
classes. That was three years ago. I have not programmed or
anything like that in three years. I want to get back into the
programming scene so I have a question: Which should I relearn
first, C or C++? I have forgotten a lot about both languages so
please tell me which i should relearn first!

Thanks!
 
L

Lahsen

(e-mail address removed) a écrit :
Hello,
I'm currently attending a university majoring in Computer Science.
I took C and C++ at a community college and got an A in both
classes. That was three years ago. I have not programmed or
anything like that in three years. I want to get back into the
programming scene so I have a question: Which should I relearn
first, C or C++? I have forgotten a lot about both languages so
please tell me which i should relearn first!

Thanks!


--
--------------------------------- --- -- -
Posted with NewsLeecher v3.7 Final
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -
C++ ;-)
It's better.
And high level.
Well power for science.
;-)
 
J

Jim Langston

Nathan Brown said:
Hello,
I'm currently attending a university majoring in Computer Science.
I took C and C++ at a community college and got an A in both
classes. That was three years ago. I have not programmed or
anything like that in three years. I want to get back into the
programming scene so I have a question: Which should I relearn
first, C or C++? I have forgotten a lot about both languages so
please tell me which i should relearn first!

Thanks!

It depends on your goal. If your goal is to get going quickly with
programmer, than relearning C will definately put you back coding faster.
But, C++ is really a different language, and I've found that it may be
better to learn C++ first than C so you don't have to unlearn some things
(using void pointers, etc..).
 
C

Cinder6

On Oct 24, 4:13 pm, Nathan Brown ([email protected]) wrote:
Which should I relearn
first, C or C++? I have forgotten a lot about both languages so
please tell me which i should relearn first!

I would say it's valuable to know both of them. I would go with C
first, C++ second. It is really dependent on what you want to program
for. If you want to do OS-level coding, C is the traditional choice
(or so I'm told). Neither language is inherently "better" than the
other, and they have their own uses. One thing I've noticed, though,
is that many (most?) books assume you have prior knowledge of C and
programming.

On a personal note, when I first decided to learn C++, I learned C
first. Then, when I tried to learn C++, I didn't like it. I'm not
really sure why, but I just preferred the C way of doing things, and I
expected C++ to be more C-like (as if it were a superset of the
language, which it really isn't), so I halted on my C++ progress. It
was only recently that I decided to get over myself and learn C++ (and
I like it now). I don't know if other people have experienced this,
but I just wanted to put it out there.
 
S

Steve Pope

I'm currently attending a university majoring in Computer Science.
I took C and C++ at a community college and got an A in both
classes. That was three years ago. I have not programmed or
anything like that in three years. I want to get back into the
programming scene so I have a question: Which should I relearn
first, C or C++? I have forgotten a lot about both languages so
please tell me which i should relearn first!

It can't possibly take you more than a couple weeks to re-learn
C to the point where you have the entire language memorized.
So I would do this, just to get it out of the way. Since C
is a subset of C++, and is the subset in which most/all procedural
code is written, you need to know C thoroughly to learn C++.

Steve
 
S

Salt_Peter

Steve said:
It can't possibly take you more than a couple weeks to re-learn
C to the point where you have the entire language memorized.
So I would do this, just to get it out of the way. Since C
is a subset of C++, and is the subset in which most/all procedural
code is written, you need to know C thoroughly to learn C++.

Steve

I respectfully disagree with that point of view. C is not a subset of
C++.
I also happen to believe that learning C++ before C is healthier.

In the case of the OP, since its a re-learn and not a
do_it_from_scratch operation, he could choose either path - or both. As
long as the C brain is working while coding in C and the C++ brain when
coding in C++.

Thats just a point of view, and not neccessarily the right one.
I'll say this: its very hard to undo C'isms from infecting C++ code.
Typically, the reverse is not true.
 
B

Bart

Steve said:
It can't possibly take you more than a couple weeks to re-learn
C to the point where you have the entire language memorized.

There's a huge gap between 'memorized' and 'mastered'.
So I would do this, just to get it out of the way. Since C
is a subset of C++,

C is not a subset of C++. Lets see... reserved C++ keywords, void* not
being cast implicitly to other pointer types in C++, implicit
declarations of int returning functions in C, different semantics for
const objects, different rules for struct names and scope, character
litterals having type int in C and type char in C++, I could go on like
this...
you need to know C thoroughly to learn C++.

Not at all. C may actually be detrimental to your learning of C++ as it
may be necessary to unlearn things. For example, sane C++ developers
don't manipulate C-style char strings directly (except when interfacing
C code) and generally don't use the type unsafe mechanisms like void*
and varargs functions. You can usually judge how competent a C++
developper is just by looking at their use of C and C++ idioms.

Regards,
Bart.
 
G

Gernot Frisch

I'm currently attending a university majoring in Computer Science.
I took C and C++ at a community college and got an A in both
classes. That was three years ago. I have not programmed or
anything like that in three years. I want to get back into the
programming scene so I have a question: Which should I relearn
first, C or C++? I have forgotten a lot about both languages so
please tell me which i should relearn first!

I started with C and then tried to program C++. My C++ was C with
classes. Horrible. If I were you, I'd start with C++ directly. Then
you don't learn bad C habbits that you have to get rid of later.
String handling for one thing.
 
P

pkirk25

Learn C first.

People give all kind of reasons why learning C++ first is better. But
as someone who has jsut got into C++ after finishing K&R a month ago,
let me put the case for C.

1. C++ books either teach you a basic "C with classes" or are
incomprehensible without an understanding of C. Knowing C makes them
easier.
2. The majority of online articles and tutorials assume knowledge of C.
3. C is small. After 8 hours of K&R you will be able to download the
Linux kernel, read its code and understand it. C++ takes a lot longer
- it is way way bigger.
4. C makes C++ possible. My first steps into C++ have been C programs
with STL string and vector thrown in. Almost against my will my code
is using classes just because it does make things easier.

Of course thsi is only my opinion - it may be that your previous C++
skills mean you will be uo and running in no time.

Patrick
 
B

Bart

pkirk25 said:
Learn C first.

People give all kind of reasons why learning C++ first is better. But
as someone who has jsut got into C++ after finishing K&R a month ago,
let me put the case for C.

After a month of C++ you feel competent enough to give advice?
1. C++ books either teach you a basic "C with classes" or are
incomprehensible without an understanding of C. Knowing C makes them
easier.

Those books are crap. Modern C++ beginner books exist, which teach C++
the right way from start.
2. The majority of online articles and tutorials assume knowledge of C.

Those tutorials are crap. There are modern C++ tutorials too.
3. C is small. After 8 hours of K&R you will be able to download the
Linux kernel, read its code and understand it. C++ takes a lot longer
- it is way way bigger.

That's curious. After 10 years of programming in C and doing my own
kernel development I still can't understand some parts of the Linux
kernel (*).

(*) "Understand" can obviously have many meanings. YMMV.
4. C makes C++ possible.

I'm not sure what you mean by that. C and C++ are distinct languages,
despite the common misconception that one is a subset of the other.

Regards,
Bart.
 
F

Frederick Gotham

(e-mail address removed) posted:
Which should I relearn first, C or C++? I have forgotten a lot about
both languages so please tell me which i should relearn first!


Here's how I look at it:

(1) C is a candle.

(2) C++ is a lightbulb.

Candles were invented far earlier, and had widespread usage all over the
world. Lightbulbs were invented much later, and are generally accepted to
be better -- i.e. better lumination and greater convenience.

So why would anyone use a candle today? Either:

(A) Electrical current is unavailable.

(B) They just genuinely like candles!

So, if we move from "candles & lightbulbs" to "C & C++", I list the reasons
for using C as follows. Either:

(A) A C++ compiler is unavailable.
(B) They just genuinely like C!

It's MUCH easier to get a C compiler for a particular platform than it is
to get a C++ compiler. Getting a C++ compiler for systems like Windows,
Linux, Playstation 2, is a simple task. But try getting a C++ compiler for
a tiny little microchip that goes in a blender -- you'll probably have to
code it in C.

C++ can do everything C can do, and more, so don't use C.

I myself am a C++ programmer. I keep a few candles around the house because
they might come in handy at some stage! Similarly, I have hung around
comp.lang.c to pick up some C skills, should it come it handy!

My advice: Learn C++ FULLSTOP. Don't bother with C -- it's about as useful
as learning to fix cars that were manufactured a century ago. When you've
achieved high proficiency in C++, you might decide to learn how to use C
aswell.

I think a programmer who can program in both C and C++ is a good thing -- I
myself aspire to it in anyway. The two compliment each other.
 
T

Tom Smith

> I want to get back into the programming scene so I have a question:
> Which should I relearn first, C or C++?

There is nothing that can be done with C that can't be done with C++; there is
nothing that can be done with C++ that can't be done with C. Having said that,
there are a number of important modern programming techniques (object-oriented
programming, generic programming, even to a limited extent functional
programming) that are massively easier to do in C++, and also massively easier
to do well. (*)

On the other hand, C++ is a much, much bigger and more complex language than C:
unlike C, it's almost impossible to know it thoroughly. That's not necessarily a
bad thing; most people know a large enough subset of C++ for their needs, and do
perfectly well with it.

It's true that many books and tutorials on C++ assume a prior knowledge of C, or
at least of that (smallish) part of C++ which is very similar to C. (It's worth
knowing that even though this subset exists, and even though it would be
perfectly possible to write entirely C-style programs in C++, almost every
significantly big C++ program is constructed and written in an entirely
different idiom to a C one). I'd say in general though that these books tutorial
are inferior to those which don't take the start-with-C route (Someone with a
more detailed knowledge than mine of the C++ book world should be able to
recommend something); an awful lot of the postings for help you'll see on this
newsgroup, for instance, come from people using the start-with-C route who've
started bumping into "proper C++" - templates, standard containers, generic
algorithms, proper polymorphism - and become hopelessly lost.

My advice to you is to learn C++ - for almost all applications it's more
powerful than C - but to do it properly. What I mean by that is, learn from a
source which starts you off straight away with proper standard containers and
only mentions arrays in passing; which is absolutely pedantic about what is and
isn't allowed, and what will cause "undefined behaviour"; which never requires
you to write, say a linked list, except for one single exercise late on in the
section on pointers and arrays (which should be late on in the book)...

Hope that helps,


Tom



(*) Note to nitpickers and C++ gurus: I'm well aware that there are some rather
esoteric things in C++ - template metaprogramming for instance - that can't
reasonably be done in C; and some more that don't directly translate. But for
the purposes of day-to-day programming, and certainly beginner programming, I
think my statement is broadly true.
 
I

IndyStef

C++ is very powerful, but may be difficult to understand without prior
knowledge of C. Conceptually the biggest difference between the two is
OO programming, and generic programming. Both are topics that are not
explicitly tied to C++, but without knowledge of them you won't have
your C++ code fire on all possible cylinders.
However, C++ is a subset of C (even Bjarne describes it that way, and
he should know), which implies that it is definitely good to have
knowledge of C before tackling OOP and generics in C++.
The more you use C++, however, the more you begin to 'forget' about C
libraries, and use C++ libraries instead. But that is a conscious
choice then, and the understanding of the value of strong type safety
and other C++ benefits is better when you know the alternative.
 
A

arnuld

Tom said:
(e-mail address removed) wrote: <snip>
There is nothing that can be done with C that can't be done with C++; there is
nothing that can be done with C++ that can't be done with C. Having said that,
there are a number of important modern programming techniques (object-oriented
programming, generic programming, even to a limited extent functional
programming) that are massively easier to do in C++, and also massively easier
to do well. (*)

here, you are right.
On the other hand, C++ is a much, much bigger and more complex language than C:
unlike C, it's almost impossible to know it thoroughly. That's not necessarily a
bad thing; most people know a large enough subset of C++ for their needs, and do
perfectly well with it.

yeah, C++ is much bigger & complex.

My advice to you is to learn C++ - for almost all applications it's more
powerful than C - but to do it properly. What I mean by that is, learn from a
source which starts you off straight away with proper standard containers and
only mentions arrays in passing; which is absolutely pedantic about what is and
isn't allowed, and what will cause "undefined behaviour"; which never requires
you to write, say a linked list, except for one single exercise late on in the
section on pointers and arrays (which should be late on in the book)...

hey... i know such a book, it is exactly like that you described. you
just have *put* my 4 months of experience with both C & C++ into
"words" here. well, i will unleash the mystery, the book, it is "C++
Primer 4/e", notice i said 4/e (not 3/e, 3/e is *utterly*
incomprehensible to persons without a good amount of programming
experience, so it is utterly incomprehensible to me :-(, C++ Primer 4/e
is not available in my country but 3/e is :-(

4/e teaches Modern C++,right from the beginning, (as a bouns it also
teaches how C++ interacts with hardware). i banged my head with its 3rd
chapter for 1 week (vectors & strings) & 1 more week for its 4th
chapter on pointers & arrays & trust me after learning about "vectors,
iterators & strings" "character arrays, free & malloc" were really like
a breeze :) (still, i have seen some people, approx. 15-20%, who have
found C++ easier after learning C, contrary to the other 80-85% people
& me :) who find C easier after C++. now, only you know where you
belong, you can check it by reading C++ Primer 4/e & C programming
Notes by Steve Summit, one of the "gems" of C community:
http://www.eskimo.com/~scs/cclass/cclass.html )


thanks
Hope that helps,

yeah, it helped me too (to understand my own experience)

arnuld ;-)

(*) Note to nitpickers and C++ gurus: I'm well aware that there are some rather
esoteric things in C++ - template metaprogramming for instance - that can't
reasonably be done in C; and some more that don't directly translate. But for
the purposes of day-to-day programming, and certainly beginner programming, I
think my statement is broadly true.

i understand that point

last advice:

1.) never, ever forget C++ FAQs & C FAQs. they are precious & much,
much correct & helpfull
2.) never, ever try to learn C++ or C from "online tutorials", all,
except Summit's, teach WRONG C & C++.
3.) also check, "Accelerated C++", i am saying so because, there is
*no* "ONE best book" for everyone. i have heard many praises for
"Accelerated C++".

http://arnuld.blogspot.com
 
A

arnuld

Tom said:
Superset. C is a subset of C++.

nope, C & C++ are different languages, they are really, very, very
different. my 4 months of experience with both of these langugaes has
convinced me enough to not to believe 90% of book authors (IFF, you
want to learn "Pure C++" a.k.a "Modern C++"). C was chosen as an
"inspiration" (as a "base") to create C++ & their "designs" & "ways"
of solving problems are completely different. at least this is what i
have found.

-- arnuld
http://arnuld.blogspot.com
 
A

arnuld

IndyStef said:
The more you use C++, however, the more you begin to 'forget' about C
libraries, and use C++ libraries instead. But that is a conscious
choice then, and the understanding of the value of strong type safety
and other C++ benefits is better when you know the alternative.

Indy carries experience & he is right, as per my experience, as i am
doing the same thing he described here but i am doing it
unintentionally, implicitly.

thanks Indy

-- arnuld
http://arnuld.blogspot.com
 
A

arnuld

Bart said:
After a month of C++ you feel competent enough to give advice?

In my case, my 4 months of experience is "exactly" contrary to my 1
month of experience.
Those books are crap. Modern C++ beginner books exist, which teach C++
the right way from start.

YES, those are really *crap*. i know 3 'Modern C++" books:

1.) "C++ Primer" 4/e
2.) "Accelerated C++"
3.) "The C++ programming Language" by Bjarne Stroustrup (tough for a
beginner & very *dense*)
Those tutorials are crap. There are modern C++ tutorials too.

"online" tutorials are a BIG crap. (except of Steve Summit's)
I'm not sure what you mean by that. C and C++ are distinct languages,
despite the common misconception that one is a subset of the other.

it takes experience to understand & break-out of the "misconceptions".

so far, its my 3rd reply, all are explaining by themselves that
........... you already know what i will say :)
 
E

Earl Purple

Frederick said:
My advice: Learn C++ FULLSTOP. Don't bother with C -- it's about as useful
as learning to fix cars that were manufactured a century ago. When you've
achieved high proficiency in C++, you might decide to learn how to use C
aswell.

I cannot agree with that, not if you want to work in the practical
world, or at least in the world I work in.

Firstly, if you learn all of C++ then you are learning most of C too.
You cannot ignore arrays and char pointers because we now have vectors
and strings.

In the real world you are probably going to have to maintain legacy
code, written in C-style. In the real world you will have to work with
3rd party libraries with a C interface.

Now if you can tell me where the jobs are where I won't have to do
those things...
I think a programmer who can program in both C and C++ is a good thing -- I
myself aspire to it in anyway. The two compliment each other.

That seems rather strange, although they might complement each other.
C++ was designed to be backwardly compatible with C so that companies
could adopt it without throwing away all their existing and working C
code.

C is far more portable across libraries than C++. Thus many libraries
written in C++ have a C interface. (There are also many written in C
with a C++ wrapper interface. The ideal is written in C++ with a C
interface and then a C++ client wrapper on top of that. The client
wrapper should be all inlined code).
 

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

Forum statistics

Threads
473,787
Messages
2,569,629
Members
45,332
Latest member
LeesaButts

Latest Threads

Top