what are good books for learning to program C/C++

Discussion of chess software programming and technical issues.

Moderator: Ras

hawkeye
Posts: 62
Joined: Thu Apr 03, 2008 8:54 pm

what are good books for learning to program C/C++

Post by hawkeye »

I was wondering about what would be a good book(s) for learning to write code? I know nopthing about it but would like to learn.


Steve
Aleks Peshkov
Posts: 922
Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia
Full name: Aleks Peshkov

Re: what are good books for learning to program C/C++

Post by Aleks Peshkov »

Bjarne Stroustrup's book is much more then language introduction from the its creator, but a guide of the good modern programming style.

But you need to know about general computer architecture and programming basics (variables, memory pointers, loops) before reading this book.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: what are good books for learning to program C/C++

Post by mcostalba »

hawkeye wrote:I was wondering about what would be a good book(s) for learning to write code? I know nopthing about it but would like to learn.
If you know nothing about coding perhaps C comes easier if you know a bit of how a processor works, instead, if you don't have clues about how hardware works perhaps start with Java that is more clean and correctly laid out (we can say modern) then C
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: what are good books for learning to program C/C++

Post by zamar »

Hard to say where one should start with... I learned the basics by borrowing books from library. At least here in Finland in almost every public library there is a lot of books dealing with C++ or Java programming.
Joona Kiiski
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: what are good books for learning to program C/C++

Post by michiguel »

mcostalba wrote:
hawkeye wrote:I was wondering about what would be a good book(s) for learning to write code? I know nopthing about it but would like to learn.
If you know nothing about coding perhaps C comes easier if you know a bit of how a processor works, instead, if you don't have clues about how hardware works perhaps start with Java that is more clean and correctly laid out (we can say modern) then C
You can learn C even if you know nothing about how a processor works. You learn along if needed. For a complete beginner I may suggest Ruby or Python as valid alternatives. There is something very natural about these two languages. I learned with Pascal (I fooled around with BASIC, but I really *learn* programing with Pascal). Not a bad option.

Miguel
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: what are good books for learning to program C/C++

Post by mcostalba »

michiguel wrote:You can learn C even if you know nothing about how a processor works.
And please explain me how you justify you have stuff like integer, unsigned integer, long, long long, char, unsigned char, etc... just to say "an integer number".

And this is just a very silly example, but the list of stuff that exsists just because of how things are represented in hardware is very long in C, and _has_ to be like this given the reason why C was invented for.
Gian-Carlo Pascutto
Posts: 1260
Joined: Sat Dec 13, 2008 7:00 pm

Re: what are good books for learning to program C/C++

Post by Gian-Carlo Pascutto »

mcostalba wrote: And please explain me how you justify you have stuff like integer, unsigned integer, long, long long, char, unsigned char, etc... just to say "an integer number".

And this is just a very silly example, but the list of stuff that exsists just because of how things are represented in hardware is very long in C, and _has_ to be like this given the reason why C was invented for.
I don't think you need to "justify" anything to learn the language.
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: what are good books for learning to program C/C++

Post by michiguel »

mcostalba wrote:
michiguel wrote:You can learn C even if you know nothing about how a processor works.
And please explain me how you justify you have stuff like integer, unsigned integer, long, long long, char, unsigned char, etc... just to say "an integer number".

And this is just a very silly example, but the list of stuff that exsists just because of how things are represented in hardware is very long in C, and _has_ to be like this given the reason why C was invented for.
If you read K&R II book, you learn whatever is needed to get you going. It is not that complicated.

Miguel
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: what are good books for learning to program C/C++

Post by mcostalba »

michiguel wrote:
mcostalba wrote:
michiguel wrote:You can learn C even if you know nothing about how a processor works.
And please explain me how you justify you have stuff like integer, unsigned integer, long, long long, char, unsigned char, etc... just to say "an integer number".

And this is just a very silly example, but the list of stuff that exsists just because of how things are represented in hardware is very long in C, and _has_ to be like this given the reason why C was invented for.
If you read K&R II book, you learn whatever is needed to get you going. It is not that complicated.

Miguel
I have read it many years ago, thank you :-) ...and I am already going BTW

But "not complicated" doesn't mean elegant or logical or well designed from a learning point of view. C was not borne to be a language from where to learn how to program (Pascal was), but not because it is complicated, but because has a lot of tricks and low level design compromises so to be powerful and useful mainly by system programmers in the real world, not in a laboratory.

Regarding Python et similars, they are interesting of course, but far from the chess engine applications, if this is his intended ultimate target it would be better to start with something well designed and so with a good attitude toward being a learning tool but not too far away from what is commonly used to build up a chess engine.
User avatar
ilari
Posts: 750
Joined: Mon Mar 27, 2006 7:45 pm
Location: Finland

Re: what are good books for learning to program C/C++

Post by ilari »

C is a small language, and thus easy to learn. "The C Programming Language" by K&R is very good.

C++ is a huge language, and many things seem unintuitive at first. That's why I'd recommend a book like "Thinking in C++" which teaches good programming practices and helps the reader to understand the weird design of some of the language features.