March 26th, 2002, 07:00 PM
I'm new to c++ & I need help!
I want to learn C++ to create programs in Linux. But I am a complete newbie (I've done programming in VB & PHP though).
What do I need & what tutorials do you recommend.
March 26th, 2002, 07:19 PM
March 26th, 2002, 09:42 PM
Tahnk you very much! I need all the help I can get <grin>
March 29th, 2002, 03:25 AM
OK, the whole thing with programming on linux is that there are really two schools of approaching the "process" of programming:
IDE and command line. Which you prefer will depend on what
you have to do (GUI work tends to be pretty much IDE-centric, server coding is usually command line work, etc) and your personal preferences. The cool thing about unix is that, becuase the command line is so well developed, programming there is just as easy as pointing and clicking at an IDE.
That said, IMHO, as a newbie you should use the command line tools (or at least, some editor you like and the command line to
invoke the compiler and such). Why? Becuase that is actually simpler than most IDEs (open up the options dialog sometime in VC++, heh), the knowledge is more "portable" (what happens if you only know, say, Visual C++ but then you have to
use CodeWarrior on a job?), and it gives you a better "feel" for what's going on as code becomes programs...
I strongly second the recommendation of Bruce Eckel's "Thinking in Foo" line of texts. The java one is excellent, and what I've seen of the C++ one is as well. There are varying schools of thought
about whether you should learn C, I say go for it becuase gaining
a useful working knowledge of C is not hard (say, up through non-esoteric uses for pointers, structs, that sort of thing) and once you learn C you've got an immediate head start on several languages (C++, Java, Perl, etc.). There are of course conceptual differences between how you think to be a good C++ programmer
and a good C programmer, but pointers are pointers. If you do want to learn C, there are many good books. I really like the Steve Oualline (sp?) O'Reilly (cow) C book, and of course "The C Programming Language" by Kernhigan and Ritchie (addison wesley?) is the classic in the field. If you want a book that focuses on the TOOLS rather than the LANGUAGE, then o'reillys
(swan) book "Programming with GNU Tools" is good as it provides useful introductons to the common range of gnu programming utils (and fundamentally, linux is a kernel with a thick coat of GNU).
Before you spend a fortune on books, you may wish to look into www.bookpool.com, they usually beat the other online booksellers on price and their service, as far as I've seen is flawless. My only gripe is that for some reason they don't carry books published by Manning (who has published some really great perl books, btw).
Anyway, here's a list of recommended programs to use:
gcc/g++: naturally. free and decent. you do need to use g++
on c++ source, this is a common newbie error.
Nano (or pico, if you have pine installed): easy command line editor
Vim: somewhat more complex, but nicer editor for the command line
(some people like emacs, but that's probably as much work as
learning c++, heh)
Nedit: simple, pretty
gdb: command line debugger
ddd: very nice gui shell around gdb, it's facility for graphically monitering complex data structures is really nice
make: can't live without it for those big projects
shell (bash, (t)csh, ksh, etc): learning the rudiments of
shell scripting will make your life easier in the long run as
a unix programmer for writing test scripts and other forms
of automation. there is a good howto on bash scripting
(it's got advanced in the title but starts off from zero) in the LDP.
perl: everyone's favorite glue language. it's not just for cgi, heh.
it's everything shell scripting is and more. It be all that and a bag of chips. Learning Perl by oreilly is a good starting point (I make my living coding perl).
(you didn't say what distro you're using, but if it's debian all these are apt-get'able, if it's (redhat/mandrake/corel/etc.) then you can probably find the right rpms either on your distro disk or at rpmfind.net)
Of course, the only thing programmers like to do more than sex in their spare time is code programs to make programming easier. So there are about a trillion and one utilties of various sizes and scopes for the myriad of tasks a working programmer faces, for example yacc and lex for writing custom languages (bison/flex from the gnu folks). Go for a browse on a site like freshmeat.net or something and you'll get a feel for what's out there.
OH, one last thing: after you've gotten up to speed on the basics of C++ (making classes, etc.), please please do yourself a favor and make an effort to learn how to use templates and the STL (standard template library), even if whatever book you got doesn't cover them. *These are absolute joy to work with.* (usually, heh) The STL is probably the thing i like best about C++.
March 29th, 2002, 03:36 AM
good luck, btw. this will all likely seem Totally And Completely Alien to you (coming as you do from vb/php), but it can be fun if you stick with it. Keeping track of variable types will probably be the thing that trips you up the most at first (e.g. in php a $foo holds 1, "1", and "I am a string of text." with equal ease, but in C(++) respectively those would have to be held in an int, a char, and a char*/char array (pointers (something that points to a chunk of memory) and arrays are two side of the same coin, sort of, but I'll leave that for you to discover)).