How to start learning.

J

Johny

I would like to start learning C or C++.
Can you please answer my questions?

1.What book can you recommend for learning?
2.Shall I start with C or with C++? ( At present I use Python)?
3. Is there a free compiler/IDE for C/C++ ?

Can you please advice ( the best way) how to begin so that my
learning will be successful?
Thank you for help
L,
 
W

WANG Cong

Johny said:
I would like to start learning C or C++.
Can you please answer my questions?

1.What book can you recommend for learning?

The C Programming Language
The C++ Programming Language
2.Shall I start with C or with C++? ( At present I use Python)?

Either, I think. :)

3. Is there a free compiler/IDE for C/C++ ?

gcc/g++


Thanks.
 
M

matthew.pugsley

Accelerated C++ is highly recommended in this group, but I should admit
that I find it for the gifted ;), at least from my side, Thinking in C++
by Eckel is better I suppose(which is also free online), just my personal
opinion.



The only way is start coding and trying to improve by learning more...

Cheers,

I have studied "Visual C++ 2008: How to Program" in the Deitel
textbook series. I found it a very good introduction to C++ and C++/
CLI. Now that I'm reading Petzold's "Programming Windows" 5 ed., I'm
wishing I understood a bit more C. Also, the following website makes
me feel rather inadequate for not knowing C: http://www.yosefk.com/c++fqa/index.html.
I'm sure opinions differ, but apparently it's treated as a given by
many people that you program interfaces using C, not C++.

So my path has been to study C++ and then to C. I expect many people
who study either end up studying both. And it probably doesn't matter
which comes first. I plan on studying C with "The C Programming
Language" by Kernighan and Ritchie. (I'm hoping I get that for
Christmas.) I've read a little (i.e. maybe three chapters) of "The
Unix Programming Environment" by Kernighan... and WOW! I only stuck
with it for three chapters but was very impressed. That book is well
deserving of its reputation. I should get it again.
 
B

Bo Persson

I have studied "Visual C++ 2008: How to Program" in the Deitel
textbook series. I found it a very good introduction to C++ and C++/
CLI. Now that I'm reading Petzold's "Programming Windows" 5 ed., I'm
wishing I understood a bit more C. Also, the following website makes
me feel rather inadequate for not knowing C:
http://www.yosefk.com/c++fqa/index.html.

That's a page by someone trying REAL hard to find some problems in
C++. Most of the time he makes lots of birds out of just a few
feathers.
I'm sure opinions differ, but apparently it's treated as a given by
many people that you program interfaces using C, not C++.

Just if you want to publish the interface to other languages. A C
interface is the least common denominator, which almost anyone can
adapt to.


Bo Persson
 
M

Matthias Buelow

Bo said:
Just if you want to publish the interface to other languages. A C
interface is the least common denominator, which almost anyone can
adapt to.

Which exposes the biggest problem with C++ -- it exposes an interface
noone can reliably talk to, not even other C++ code compiled by a
different compiler.
 
B

Bo Persson

Matthias said:
Which exposes the biggest problem with C++ -- it exposes an
interface noone can reliably talk to, not even other C++ code
compiled by a different compiler.

Or even other C++ code compiled with the same compiler, but using
different configuration options.


And it shares this problem with Fortran, Pascal, Cobol, and whatever.
:)


Bo Persson
 
J

James Kanze

This is a popular, but unfounded, accusation. C++ is portable
at the source level, just not at the compiled, binary level.

In practice, it's not even totally portable at the source level.
Of course, C++ isn't the only language to have that problem
either. In a certain sense, you unavoidably have it as soon as
there are two different code bases for the compiler; compilers
have bugs, and two different code bases will have different
bugs. In the case of C++, we also have the question of how well
they implement the standard, with code which compiled with g++
3.x failing to compile with 4.x, etc.
[1] If you do need binary compatibility, the C subset Bo
mentioned offers much cleaner support for it than (say) Java's
JNI [2], or C-based extensions to the scripting language du
jour.

That's because is supports a lot less.
In fact, I'm having trouble bringing to mind any language
other than C with the kind of binary compatibility you're
suggesting.

Fortran IV:). Assembler.
1. Some implementations, e.g. GCC, do define versioned ABIs.
2. Even Java's byte-code is not forward compatible among JVM
versions.

You mean backward compatible, don't you? A modern JVM should
execute the older .class files.

Of course, even the underlying hardware has such problems: Sparc
added some instructions with v9, and if your code uses them, it
won't run on older processors. (The difference is, of course,
that we were promessed that this would never happen with the
JVM.)
 
D

Daniel de Kok

1.What book can you recommend for learning?

I'd second the recommendation for 'Accelerated C++' by Koenig and Moo.
I've recommended it to others, who have been very happy with it. Or,
if you have the luxury of having an educational institution that
offers a *good* C++ course nearby, I'd seriously consider that as
well. It really helps if someone more experienced can point out bad
style early on, and who can help you with problems/questions.
2.Shall I start with C or with C++? ( At present I use Python)?

I'd start with approaching C++ as a relatively high-level language (as
in Koenig and Moo's book). Once you picked up C++ at that level, you
could dive more into C. The danger of doing things the other way
around is, is that you'll use C++ as C with classes, but it is far
more advanced than that.
3. Is there a free compiler/IDE for C/C++ ?

Sure. g++ from the GNU Compiler Collection and Visual Studio Express
Edition are both high-quality compilers.

-- Daniel
 
J

James Kanze

There is a large, common subset.

Certainly. There's even a large common subset with CFront 2.1
or Zortech 1.x---I have some code originally written for the old
Zortech which still compiles today.

The problem is knowing the limits of that subset in advance, for
all of the compilers you have to target now, and may have to
target in the future. With a reasonable degree of accuracy; you
can't possibly get it perfect, because you can't know in advance
what errors might be present in some future version.
Incidentally, I wrote some code last week that compiled and
worked as expected with one GCC 3.x, but not with a later 3.x.
The issue was that I moved a template definition up in its
translation unit, before the declaration of one of the
non-dependent names in the definition. The older GCC 3 failed
to notice that the name was not yet in scope when the template
was defined, but found the intended name when the template was
instantiated. I wonder how much processing of template
definitions the various compilers actually do.

Variations in the lookup of non-dependent names are probably the
biggest portability problem today. Curiously enough,
portability seems work best using the reverse of normal
procedure: code which compiles and works with the most recent
compiler will usually work with older versions. (Usually, it's
the opposite: code which compiles and works with older compilers
continues to work, but the fact that some code compiles and
works with a newer version doesn't mean it will do so with an
older one.)

[...]
Assembler varies wildly from one assembler to the next. (I
don't know Fortran, so no comment.)

Assembler varies from one machine to the next, but I've rarely
encountered problems with upgrading the version of the assembler
for the same machine.
Yes, thank you for the correction.
Even more insidious are instructions that still "work," but
very slowly.

That's one advantage JIT compilers have; they know the exact
machine they're running on, and can tune for it.
 

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
474,166
Messages
2,570,901
Members
47,442
Latest member
KevinLocki

Latest Threads

Top