PDA

View Full Version : RFI - C++ information or "Where do I begin?" for the new programmer.



Ratt
03-05-2003, 12:20 PM
I get questions in my PM box and email a lot asking me where people can start for C++, what books are good to buy, etc... You've all seen the posts.

I honestly don't even know where to begin with this sort of question half the time.

I'd like to compile a list of books that people think are helpful, from FIRST HAND EXPERIENCE. Both for reference and for learning.

If any of you say the Deitel and Deitel UML w/ C++ book, I'm going to strangle you. Those of you who've read it, know what I'm talking about. Those of you who haven't, be thankful.

I can say, though, and if anyone has anything to add -> if you are just starting out and know nothing about C++, go to your local community college.

Take a beginning programming course, any language.

After that, your class progression, IMHO, should look something like this:

Basic C++ course (200 level)
OOP with C++ (230 level)
C++ Data Structures (250 level)
GUI programming with C++ (300 level)

After you have those 4 "required" courses, you can start diverging into the specific area you are interested in. You'll probably have reached the limit of what your local community college has to offer in that area, and will have to go to a 4 year or specialty school for further classes, but it will give you a solid foundation to either continue your formal education, or possibly strike out on your own and learn what you want to learn by yourself.

brinx
03-05-2003, 01:37 PM
When I first began programming in C++ I started with misc tutorials off of the web.

Some can be found here:

Cprogramming.com (http://www.cprogramming.com/tutorial.html)

About 4 or 5 years ago (when I found it) this was a very good tutorial for graphics programming written by Denthor of Asphyxia, aka Grant Smith (which I haven't been able to find in a while until it was recently added to this site).

I also recommend before starting any type of programming (especially graphics), that you should start with a solid foundation of english and mathematics.

Arrays, algorithms, and the like, make much more sense with a solid math background. It is also harder to read documentation about programming, in general, if you can't decipher what half of the words mean.

Hope this helps someone.

Edit :: Rifled through some books that I had and posted the good ones.

Practical C++ Programming, published by O'Reilly & Associates. Written by Steve Oualline.

C Pocket Reference, published by O'Reilly & Associates. Written by Peter Prinz & Ulla Kirch-Prinz.

Raistlin
03-05-2003, 02:14 PM
To add a little to this thread, I will mention a couple of books i've used myself.

First, if you are new to programming in general, start with a course or book in "basic". Yes, this is an old, outdated language, but there really is no easier to understand language that is more forgiving than basic. I use it as a prototyping and flow layout language all the time. It's easier to learn programming constructs like functions and recursion when you're reading a language that is readable and understandable.

For the very beginner in the C/C++ language the book "Structuring Techniques: An Introduction Using C++" Published By Prentice Hall, written by Andrew C. Staugaard, Jr. is a good book to start with. It's a few years old so I don't know if its still published or not, but it does give a good general layout for C/C++ programs, and gets into advanced data structures, memory management, and all that happy stuff that makes c/c++ the behemoth it is today. If you already know C/C++ this probably isn't for you as it's ment as a C++ Primer book so to speak (starts you with hello world and cout, and goes into data type discussions on the differences between int and char, etc.).

Another book I find helpful is not a C++ book at all, but a C book. "The Waite Group's C Primer Plus" Sams publishing, Written by Stephen Prata is a good refference book. I'm not sure how it reads as an introduction to C itself, but It's rare I can't find a function in there and a discussion on how to use it.

I also have at home (sorry, not with me) almost a master refference to the "Ansi" C++ language (though it was written prior to the ANSI standard being formalized for C++)...the book is arranged as a useage/command quick refference to both the C and C++ languages. This is by far the most helpful book I own when it comes to C/C++ Coding as if I have a question on useage of any function (or need to see an example of use) it is right there in an easy to find way. If I remember to look for it, i'll try to edit the post to include it.

throx
03-05-2003, 03:56 PM
First, if you are new to programming in general, start with a course or book in "basic"
Don't do this. For the love of God don't do this. If you have BASIC on your computer for any other reason than supporting code written by VB monkeys then learn how to uninstall it.

BASIC (at least any incantation prior to VB.NET) is a hideous malformed beast that will teach you exactly the wrong way to programming. Prototyping in BASIC will lead to horrible code. Mimicing BASIC's flow control and structure handling is the best method of obfuscation known to man. BASIC is pretty much the bane of efficient and elegant programming.

VB.NET is mererly a malformed beast that you can hammer into submission if you already know how to program nicely, but learning or starting with it will screw up any chance of your ever becoming a decent developer.

BASIC, especially VB, will lull you into the sense of security that your project is going well right up to the point where you hit the wall and the complete lack of decency inherent in the language smacks you in the face making you take all sorts of horrid shortcuts, introduce non-deterministic behaviors and generally turn your project into one large aborted mess. If a VB programmer ever tells you they are 90% done and are just sorting out one last little glitch then run away. Scream occasionally too - it will help.

This is not a prejudiced statement. This is an observation of fact after 10 years in the industry.

[Ratt/casey: delete this or move it to R6 if you don't want it here - I'm not fussy and I know it's a rant]

KaL
03-05-2003, 05:11 PM
I would agree that BASIC is a bad idea.

I also would reiterate the Waite Group's C Primer endorsement :) I had that little gem myself and it's very well-written.

Another good way to learn is to look at sample code. There are literally millions of lines of sample code available online.

That's how I became self-taught in C, Perl, and PHP, as well as MySQL. Just looking at sample code, then doing Google searches or manual checks for things I needed more information on.

C++, Perl, Python, shell scripting, Ruby, etc. etc.

Personally, I love Perl as a robust way to do things in a shell environment. Manipulating text and files is easy with Perl. Perl is for when your bash scripts just can't do exactly what you want.

PHP is great for web programming. The syntax is very similar to Perl.

C++ is what you want for writing something that you need performance for. Graphics, multi-user apps, etc.

Prorgramming can be a creative outlet instead of writing poetry, short stories, novels, or drawing or painting.

suseuser7341
03-06-2003, 11:47 AM
I have never done C++ or C++ GUI programming, only paralell number crunching using C and small stuff in Java. However there is one advice I got in my programming courses that I would like to pass on:
Think before you type anything.

As stupid as this sounds but this is the fundamental weakness introduced by BASIC.

Once your project exceeds 1000 lines you are damned if you got no "big plan".
As a rule of thumb, I spend usually about two third of my time on doing scetches on paper, a small fraction on actually coding and unfortunately still a lot on debuging.

So before starting to learn advanced C++, learn some OO software engineering.

baelang
03-06-2003, 12:39 PM
I think that perl is a very good language to learn the basics of programming and OOP. form there you only need to learn to be a bit more strict to fit right in to C and C++.

I am quite fond of the O'Reilly "zoo" books, although they are more a reference and less of a tutorial.

http://www.oreilly.com/

NDT
03-07-2003, 09:34 AM
written by VB monkeys

hehe...I play with both...and to be honest for businesses around here I make more money of VB then C++ heh...reason being is you can make a small business app for their needs in a fraction of the time that it takes in C++...Would a C++ version run better, faster? NO...because the small apps these people need wouldn't make a difference what I coded it in heh

Tyro
03-07-2003, 10:41 AM
From my limited programming experience so far;

To learn programming basics, Python (http://www.python.org) is an excellent place to start. The development environment is great and it is extremely easy to follow. I knew I had programming classes coming up, so I figured I'd get a head start and found Python (http://www.python.org). You can learn GUI programming quicker in VB, but I don't know enough C++ or VB to form any other opinions.

One more point I'd like to make is the syntax is only half of the equation. You also need to learn good programming practices. Once you know those, New languages are easy to learn, they just have different words to do the same thing.

-----------------------------------------------------------------------------------
End thread hijack

To learn C++, we used An Introduction to Programming with C++, Second Edition (http://www.amazon.com/exec/obidos/ASIN/0619033592/ref=pd_ir_imp/002-7265859-8764868) by Diane Zak. It is repetetive (ex. "you can take a break or continue with the next lesson" at the end of every lesson) but well written and understandable. It starts with the basics and in general teaches how to program as well as the syntax.

Freakyuno
03-07-2003, 10:51 AM
One more point I'd like to make is the syntax is only half of the equation. You also need to learn good programming practices. Once you know those, New languages are easy to learn, they just have different words to do the same thing.

AMEN.

If there is one thing you do before you write a single line of code, please make it learning the "Best Pratices" for programing, and for the language your using. Your whole programing life will be easier.

Joe Blow
03-11-2003, 01:36 AM
When I went to college they started us off in C++ from day one. It's not a bad place to start IMHO if you want to be serious about programming. My advice, when you start writing your first newbie cin/cout newbie programs and start learning the syntax, take a look at the iostream library files. Try to see how those functions work and also look at the style the programmers use. Always make your code orderly and well documented. Trust me, it will make you a lot better later on. As for a first book, I can't really say as my instructor taught only from lecture and just gave us handouts of source code (the way it should be). Mabye some others might be able to help in that.

For God's sake, DO NOT GET "Learn C++ in 24 hours" or "C++ for Dummies" type books. They will ruin you forever. (I've seen it happen ;) )

And always remember, no book can ever replace studying well written, well documented source code.

mxedisn
03-13-2003, 09:02 PM
At my school, the current computer teacher (this is a high school) and I are trying to figure out how to implement a less brain damaged (my term, not his) way to teach programming to the kiddos that want to learn it. He's doing an "Intro to Programming" kinda class that he does in VB. Why? I suspect it's because he's afraid of pointers... I haven't come right out and asked him, but that's my sneaking suspicion.

I'm thinking a neat programming curriculum might:
1. Teach kids how to make algorithms (doesn't really matter what language you're writing in, as long as you don't develop any bad habits..) Heck. Write it in LOGO for all I care (hehe... stick THAT in your flow control pipe and smoke it!) PASCAL! (eeech) Fortran..
2. Teach 'em how to implement that algorithm in at least 2 different languages -- their choice.. (Key here is showing 'em that it isn't the language, it's the algorithm behind it.)

My guess is that for quite a few programs, something like VB or (my personal favorite for something where I don't need to define a whole new class) QuickBasic (actually, not a bad little language... minus ANY kind of dynamic allocation support, it's not bad...) For other projects, a "healthier" language might be a better place to implement the algorithm. Heck... I've written Display Postscript and hooked it into Objective C >shudder<.
I'd LOVE to teach a VAX assembly class, but I'll probably end up doing a 2 semester C / C++ class.

What y'all think? Do you NEED to learn C (be happy and comfortable with, say, pointers to functions returning pointers to functions) before you can be happy and comfortable with C++ ? Or is all that horrid stuff we had to do before objects got invented useless now? (I still use pointers to functions all the time... old dog, new tricks, etc.)

Of course, where I've strayed from Ratt's prescription is the GUI bit... I still program (primarily) in a console. I'll go fullscreen and blit happily, but Windows gives me the willies.

Anyway, if my evil plan is successful, in a couple of years, I'll be teaching an A+ course, an intro to C(++), and an advanced (shudder) GUI based C++ class. Who knows what the future brings?
(Hopefully, a message from Ratt in Announcements that says, "CVS is up. Update like the wind, you crazy whiners.")

The Duck
03-16-2003, 02:19 PM
I can't speak for the actual "real" beginner, but I know there are a lot of people out there who actually feel they have a pretty solid grasp of basic programmatical logic that just don't understand C++.

For them I would recommend a dear and trusted friend of mine I picked up many, many years ago called:

C++ nuts and bolts for experienced programmers

It is a no-nonsense, we're going to teach you C++, not how to program, we assume you already know logic book. It talks just enough about objects and pointers if your previous language experience didn't have those that you aren't completely lost on those either.

Secondly, and I'm suprised it hasn't been mentioned here:

The C++ Programming Language

Written by Bjarne Stroustrup. This is byno means a beginners book. However, I hear a LOT of people on this forum who program casually, as a hobby. Many of the people who hack out little programs in their free time are fairly capable, but don't have the understanding of actual work experience behind them to really create diverse reusable code that's efficient. (Although almost all of them think they do, of course, but that's one of my primary sources of entertainment...anyway). This book will take someone with 2-3 years of casual experience to the "next level". Anyone without that probablly won't understand much of it.

*quack*

The Mad Poet
04-01-2003, 06:12 PM
For those of you that say you can code a small business app in VB faster than C++ I have two words for you:

Borland Builder.

There is nothing in VB that can not be done in CBuilder just as fast and with good programming behind it.

Joe Blow
04-01-2003, 08:09 PM
Possibly a little off topic. When I was in college getting my CS degree, some professors said it's perfectly OK to mix C and C++. Others would give an automatic "F" grade if stdio.h or any standard C library was included in a C++ program. I side with the camp that says it is OK to mix C and C++ (Especially now that I work primarily on the Unix platform). I'm wondering what you guys think.

Elmo
04-02-2003, 04:10 PM
some professors said it's perfectly OK to mix C and C++. Others would give an automatic "F" grade if stdio.h or any standard C library was included in a C++ program

I'd chalk that up to different goals. If your goal as a professor is to get your students to learn C++, there can be some value in forcing them (through grades) to accomplish the task only using C++. A professor like that could compare this to another student turning in an assignment that was simply a C++ shell that executed in-line assembly code. It might work, but it doesn't teach the student very much about C++.

Contrast that goal with the real world, where you're trying to get something done. When that's your goal, you don't care about learning C++, you just want to accomplish your objective. With that goal, using C (or assembler or anything else) is most likely fine, as long as there are good reasons for doing what you did. I'm sure there are plenty of exceptions to this--for example, if a company is "standardized" on a particular language, they might want you to use only that language for long-term maintainability, even if you would prefer to use something else. In the grand scheme of things though, using a C library within a C++ program is probably not a big deal.

mxedisn
04-27-2003, 03:56 PM
I had a prof like that.


I still can't figure out how to implement a "press any key to continue" functionality without appeal to getchar()


There just doesn't seem to be anyway to do it from iostreams


(Unless the any key is return)

adenine!
06-30-2003, 06:59 AM
Originally posted by mxedisn
I had a prof like that.


I still can't figure out how to implement a "press any key to continue" functionality without appeal to getchar()


There just doesn't seem to be anyway to do it from iostreams


(Unless the any key is return)

Best I could do without cstdio, although I don't think he'd care for windows.h much more...


DWORD numRead;
HANDLE hStdin;
INPUT_RECORD buffer[1];

hStdin = GetStdHandle(STD_INPUT_HANDLE);

while (true)
{
ReadConsoleInput(hStdin, buffer, 1, &numRead);
if (numRead && buffer[0].EventType == KEY_EVENT)
break;
}

toric
05-05-2004, 06:57 PM
You might try starting with C# since it uses C like code but is safer for beginners. You can start making GUI apps from day one by using the drag and drop forms and tools.
If you really are determined to learn C++ though here are some books I used to teach myself C++ .
"A First Book of C++" by Gary Bronson
"C++ How to Program" by Deitel and Deitel
"A book on C" by Al Kelley and Ira Pohl
"Developing Widows Application with Borland C++ 3.1" by James Mccord - I'm sure there is a newer version available now
"GNU C++ for Linux" by Tom Swan
"Using Visual C++ 5" by Kate Gregory
"Visual C++5 Unleashed" by Viktor Toth

That should get you started

pocketrocket
12-12-2005, 03:14 AM
I'm a n00blette when it comes to C or C++, I however took a VB course, a COBOL course, and a SQL/access course. VB has it downfall to...well...it can make for bad habits and that was very apparent when I hit cobol, I dont' know what C or C++ is like, but I found COBOL unforgiving when it came to errors. So anyone coming into the programming scene I would urge to follow the advice given here and probably skip VB and concentrate on something that gives you a better understanding of code and what it does exactly. I read an earlier post about once you learn one language, it is easy to learn another, this statement holds alot of weight. Since my formal training in cobol and crap, I have taught myself the basics of XML, HTML and a couple other various less known languages. I have alot of respect for the guys here that are able to keep SEQ going strong month after month, I do not know enough to do it and i'm glad they do:)

Rhino73
07-11-2008, 10:02 PM
This is abit off topic as well but would you guys recommend an IDE for teaching a beginner or a generic text editor and the command line? Being a Java programmer I use netbeans but am curious if / at what point in teaching someone I should start them with an IDE and which IDEs would be best for a beinner (Eclipse has been recommended to me). My plan was to have them do a single hello world app using the command line to learn the basics of how the language works and then get them started with an IDE. Suggestions?

The first language I learned was Java. I would highly recommended it for a learning language (the syntax and semantics are nice IMO) except for some obvious pitfalls such as: you don't learn memory management or the usage of pointers. I do recommend Java however if you want to learn the OOP conecepts.

When I got to high school they had a few programming courses offered in VB but coming from a language like Java I really didn't feel it was a very good learning language.

My university starts its computer science majors off with a course in C. Personally I think a new programmer should learn a language that handles memory management for them first so they can get the basics down before they start with C.

ieatacid
07-12-2008, 08:02 AM
I'm mostly self taught (aside from some online tutorials -- and also just do this as a hobby) but I've always used Microsoft's Visual Studio for Windows and KDevelop in Linux when I'm working on SEQ.

I know some people that code for a living that absolutely despise IDEs :p

uRit1u2CBBA=
07-12-2008, 12:34 PM
I'm one of them :) In my job, I use C and use command-line "vi" to do the work.

I've just never found a good IDE that I like. Now that I'm in school again to learn more languages, I'll be forced to use one or two new ones. I hope I find one that I like :) lol

BlueAdept
07-13-2008, 09:50 AM
Heh I havent touched C since the 80s when I used to use it for writing code for WWIV bulletin board.

I am better at assembly since I used to use it to "debug" software so it would work on my pc or for giving me better stats in the games I used to play. :D Anyone remember what int 13h was used for in OLD software? :D

uRit1u2CBBA=
07-13-2008, 09:53 AM
LOL! You were one of the people writing WWIV!? I've played with that a little in trying to get my own system up and running in the early 90s. I eventually used Telegard and Regegade. That's funny!

BlueAdept
07-13-2008, 01:04 PM
I used wwiv since the pascal days, when it went from v3 to v4 it migrated over to C.

Wayne Bell wrote it, I just did substantial modifications. If you were a registered owner, you could get to their mod section. I had about 50 mods appoved by Wayne and on his site. His C programming left a lot to be desired but it worked.

Teleguard was a direct rip off of wwiv. It was wwiv source modded, compiled and re-released as teleguard. There was an exploit that was found on WWIV, which a patch came out for. Since Teleguard was taken from wwiv, the flaw also existed on teleguard. A new version of Teleguard didn't come out for a while so the boards kept getting hacked. Most of the people running that ended up moving to a different bbs type.

WWIV is still around. It is open source now. http://wwiv.sourceforge.net/