Clan x86

Technical (Development, Security, etc.) => General Programming => Topic started by: mfqr on September 22, 2005, 05:01:14 pm

Title: Learning
Post by: mfqr on September 22, 2005, 05:01:14 pm
Greetings.

I am trying to learn how to program, namely in C or C++. I was wondering if anyone could point me to the best places to learn.
My apologies if this has been asked over and over.

- mfqr
Title: Re: Learning
Post by: Sidoh on September 22, 2005, 05:29:41 pm
It is probably the most commonly asked question, but there's reason for that.

I always recommend buying a book to learn programming, math or any other thing that falls into the same general category.  I can't remember off hand the book I started learning with, but I'll try to find it.

Books are, in my opinion, the best way to learn because:
  -- They're published.  They've almost certainly been revised and written with care.
  -- They're more thourough than most internet tutorials.
  -- They're always there.  Websites aren't.
  -- They're usually more step-by-step.
Title: Re: Learning
Post by: mfqr on September 22, 2005, 07:33:38 pm
It is probably the most commonly asked question, but there's reason for that.

I always recommend buying a book to learn programming, math or any other thing that falls into the same general category.  I can't remember off hand the book I started learning with, but I'll try to find it.

Books are, in my opinion, the best way to learn because:
  -- They're published.  They've almost certainly been revised and written with care.
  -- They're more thourough than most internet tutorials.
  -- They're always there.  Websites aren't.
  -- They're usually more step-by-step.

what books do you think I should get?
Title: Re: Learning
Post by: MyndFyre on September 22, 2005, 08:31:11 pm
C for Dummies (http://www.amazon.com/exec/obidos/tg/detail/-/0764570684/qid=1127436138/sr=8-1/ref=pd_bbs_1/104-6700274-6198357?v=glance&s=books&n=507846).

Teach Yourself C++ in 21 Days (http://www.amazon.com/exec/obidos/tg/detail/-/0672327112/qid=1127436252/sr=8-2/ref=pd_bbs_2/104-6700274-6198357?v=glance&s=books&n=507846)

Code Complete (http://www.amazon.com/exec/obidos/tg/detail/-/0735619670/qid=1127436316/sr=8-1/ref=pd_bbs_1/104-6700274-6198357?v=glance&s=books&n=507846)

Rapid Development (http://www.amazon.com/exec/obidos/tg/detail/-/1556159005/qid=1127436316/sr=8-3/ref=pd_bbs_3/104-6700274-6198357?v=glance&s=books&n=507846)

Now, the last two books I read well after having programmed for a long time.  But, at the same time, I think they taught me more about programming technique and style than I ever could have learned from anywhere else.  They're probably not a good place to start, but they're great resources once you get the hang of it.

[edit]
Personally, I don't like e-books.  I don't like to have to stare at a computer screen to read, as well as operate the computer.  Plus, when I want to reference something in the book, I either have to have my screen at an obtusely high resolution or task switch.  Not convenient.
Title: Re: Learning
Post by: Eric on September 22, 2005, 08:47:08 pm
The Complete C Reference & The Complete C++ Reference.

Stay away from anything with "Learn x in y number of days"
Title: Re: Learning
Post by: Joe on September 22, 2005, 09:17:20 pm
I agree with LoRd (the latter part). I cruised through the first three days in about one day, and then I was lost. =p

As for MyndFyre, I would agree, but I have two screens on JoeMomma (well, thats a high resolution, but eh) so it works fine for me.
Title: Re: Learning
Post by: Ryan Marcus on September 22, 2005, 09:29:32 pm
You should first figure out if you really want to learn C...

If your on a mac, and your goal is cross-platform, look at REALbasic (http://realbasic.com)
If your on a PC, and your goal is cross-platform, look at Java.
If your on a mac, and your goal is mac, look at Cocoa.
If your on PC, and your goal is PC, look at (Go ahead and shot me) Visual Basic/.Net or Java. (Java.)



I really don't honestly understand why anybody would write in C, although I am considered a newb-ish programmer.

My summery: C is hard. I like Jello.
Title: Re: Learning
Post by: Sidoh on September 22, 2005, 09:33:31 pm
If your on PC, and your goal is PC, look at (Go ahead and shot me) Visual Basic/.Net or Java. (Java.)

/me shoots Ryan Marcus.

VisualBasic is like the Spanish of the world.  Everyone knows a little bit of it and it's dirty as hell.  (Sorry for the racial comment -- was making a crude attempt at humor).

Java is... Java.  It's not meant for JUST Windows designing.  If your end-goal is to develop programs on a PC platform, there's no way you should chose Java.

.NET is a decent choice, I'd say.  There's definitely a lot of job opportunity with it right now.

C is a great choice, IMO.
Title: Re: Learning
Post by: Ryan Marcus on September 22, 2005, 09:36:14 pm
If your on PC, and your goal is PC, look at (Go ahead and shot me) Visual Basic/.Net or Java. (Java.)

/me shoots Ryan Marcus.

VisualBasic is like the Spanish of the world.  Everyone knows a little bit of it and it's dirty as hell.  (Sorry for the racial comment -- was making a crude attempt at humor).

Java is... Java.  It's not meant for Windows designing.  If your end-goal is to develop programs on a PC platform, there's no way you should chose Java.

.NET is a decent choice, I'd say.  There's definitely a lot of job opportunity with it right now.

C is a great choice, IMO.

* Ryan falls over dead

Ya.. ok.. What he said is more likely true, because he knows what he is doing on a peecee and I do not... So.. ya... ;)

Sorry to bug you.
Title: Re: Learning
Post by: Sidoh on September 22, 2005, 09:37:19 pm
It's always better to hear both sides of the argument.  Just because I believe what I say is right, doesn't mean he should too.  I'm just giving my input.  :)
Title: Re: Learning
Post by: Ryan Marcus on September 22, 2005, 09:40:20 pm
Ya, but my input was wrong :-P

Well, anyway, you should take a look at REALbasic.. Really.
Title: Re: Learning
Post by: MyndFyre on September 22, 2005, 11:25:17 pm
Stay away from anything with "Learn x in y number of days"

Generally I'd agree, but the one I posted (one I've used) is pretty damn good.
Title: Re: Learning
Post by: Joe on September 22, 2005, 11:37:33 pm
Reasons to learn C:
Its fast.
Its been arround forever. There can't possibly be anything broken with it. If there was, it would have been fixed in the 40 (correct me if I'm wrong) years its been arround.
Again, its been arround forever. Many people know it, and there's many compilers for it.
Its cross platform.
I have no experience here, but as iago would say, when you learn it, you know everything else. Except BASIC. Screw BASIC. =p
Title: Re: Learning
Post by: Blaze on September 22, 2005, 11:43:53 pm
It is not been 40 years...
Title: Re: Learning
Post by: iago on September 23, 2005, 12:23:47 am
It is not been 40 years...

I believe that C was written in the early 70's, which would be around 35 years.  Close enough :P

Anyway, if you want to ever be a real programmer, you have to learn C.  It's good to know it.  You should understand how a computer works before you learn Java or any other abstract language. 

Anyway, I suggest picking up The C Programming Language, by Kernigham and Ritchie.  It was the original book on the subject, and was written by the authors. 
Title: Re: Learning
Post by: Quik on September 23, 2005, 12:46:44 am
It is not been 40 years...

I believe that C was written in the early 70's, which would be around 35 years. Close enough :P

Anyway, if you want to ever be a real programmer, you have to learn C. It's good to know it. You should understand how a computer works before you learn Java or any other abstract language.

Anyway, I suggest picking up The C Programming Language, by Kernigham and Ritchie. It was the original book on the subject, and was written by the authors.

Yes, but it was written by the authors, and therefore not the greatest guide for those just attempting to _learn_ the language.
Title: Re: Learning
Post by: mfqr on September 23, 2005, 01:23:17 am
hey guys, I'm deciding to learn C
hopefully it wont be tooooo hard  :P

- mfqr
Title: Re: Learning
Post by: AntiVirus on September 23, 2005, 04:09:37 pm
Well, if you ever want to learn C++ I would recommend checking out: www.cplusplus.com just because it's full of neat little things. :) 
Title: Re: Learning
Post by: Sidoh on September 23, 2005, 04:44:37 pm
hey guys, I'm deciding to learn C

Good man.  :)
Title: Re: Learning
Post by: rabbit on September 25, 2005, 09:52:03 am
There can't possibly be anything broken with it.
There's plenty wrong with it, but good enough programmers can get around the problems.
Title: Re: Learning
Post by: iago on September 25, 2005, 01:36:00 pm
There can't possibly be anything broken with it.
There's plenty wrong with it, but good enough programmers can get around the problems.
What, in C, would you consider "broken"? Or are you just arguing to be an asshole?
Title: Re: Learning
Post by: Ryan Marcus on September 25, 2005, 02:04:14 pm
There can't possibly be anything broken with it.
There's plenty wrong with it, but good enough programmers can get around the problems.
What, in C, would you consider "broken"? Or are you just arguing to be an asshole?

My dad programs mainly in PHP for his job, but he knows a little C... He said:

"There is nothing 'broken' in C. Its the base that everything is built on top of, and its just easier to work with languages that are built 'on top' of C."

Basically, there are shortcuts to C.
Title: Re: Learning
Post by: iago on September 25, 2005, 02:07:02 pm
My dad programs mainly in PHP for his job, but he knows a little C... He said:

"There is nothing 'broken' in C. Its the base that everything is built on top of, and its just easier to work with languages that are built 'on top' of C."

Basically, there are shortcuts to C.

It's easier for some things, yes.  But you should still know C.  Not knowing C is like driving a car and not knowing how the engine works.  Sure, you can still drive it, but you don't really understand it.  It's the basis for understanding how everything else works. 
Title: Re: Learning
Post by: Ryan Marcus on September 25, 2005, 02:23:41 pm
My dad programs mainly in PHP for his job, but he knows a little C... He said:

"There is nothing 'broken' in C. Its the base that everything is built on top of, and its just easier to work with languages that are built 'on top' of C."

Basically, there are shortcuts to C.

It's easier for some things, yes.  But you should still know C.  Not knowing C is like driving a car and not knowing how the engine works.  Sure, you can still drive it, but you don't really understand it.  It's the basis for understanding how everything else works. 

Ya, most people don't know how the engine works.

Its kind of like saying don't use AIM if you don't understand the protocol... It still works, and you still get its full potential.

But programming is not IMing. I agree with you. If you want to get down and dirty, and get to your computers full potential, C sounds good.
Title: Re: Learning
Post by: drka on September 26, 2005, 05:54:45 pm
dirty is for Visual Basic :P

If you want my advice on learning C, make sure to code perfectly. sometimes really sloppy and ugly code can result in memory leaks(mainly with pointers)
Title: Re: Learning
Post by: Newby on September 26, 2005, 06:00:17 pm
If you want my advice on learning C, make sure to code perfectly. sometimes really sloppy and ugly code can result in memory leaks(mainly with pointers)

Sorry. Hate to break it to you, but if everything was coded "perfectly", we would have no use for patching software.

And by the way, "sloppy and ugly code" that results in "memory leaks" has nearly nothing to do with pointers. (Unless you push the wrong address space in the pointer integer, and point to something wrong, but that isn't a leak. That's more of an overflow than it is a leak.)

Do you know what a memory leak is? Apparently, seeing as how you associated it with pointers, I'd say no.

EDIT -- Did you know THAT good looking code can have memory leaks still?
Title: Re: Learning
Post by: drka on September 26, 2005, 06:01:34 pm
ooooook. as perfect as can you can make it :P

edit:depends on what causes it :P
Title: Re: Learning
Post by: Newby on September 26, 2005, 06:06:42 pm
ooooook. as perfect as can you can make it :P

I seriously doubt programmers go into writing a program, thinking to themselves, "Man, I wonder how shitty I can make my coding. I bet I could declare a bunch of useless variables (char Var1[1024], char Var[1024], etc) and set them all to 1024 A's, and go through a lot of loops just to waste time, make my code ugly, and make my code inefficient."

(The message of this is that programmers TRY and make their coding perfect. :P)

I don't know of any. Do you?

edit:depends on what causes it :P

What's "it"?
Title: Re: Learning
Post by: iago on September 26, 2005, 06:15:59 pm
Memory leaks are normally caused by poorly structured code.  For example, if you malloc() your variables at the top of a function, then free them at the bottom, that's good; however, if you return in the middle of a function, that's bad.  Returning should only be done at the end, anything else is considered sloppy.  And if you return anywhere else, you could end up with a memory leak (for the reason I said above).  So yeah, sloppy code CAN cause memory leaks. 
Title: Re: Learning
Post by: mynameistmp on September 27, 2005, 02:53:04 pm
The Art of UNIX Programming -- Eric S. Raymond
Beginning Linux Programming (I've only seen the 3rd edition) -- Matthew and Stones

The first one is a must read for a unix programmer. These books are more for the guy who's done reading the how-to books and is interested in starting to develop applications. I know that's not what mfqr is looking for but It's obvious he's not the only one with interest in programming that is viewing this thread.
Title: Re: Learning
Post by: Windowlicker on September 27, 2005, 05:19:30 pm
If you want my advice on learning C, make sure to code perfectly. sometimes really sloppy and ugly code can result in memory leaks(mainly with pointers)

Sorry. Hate to break it to you, but if everything was coded "perfectly", we would have no use for patching software.

And by the way, "sloppy and ugly code" that results in "memory leaks" has nearly nothing to do with pointers. (Unless you push the wrong address space in the pointer integer, and point to something wrong, but that isn't a leak. That's more of an overflow than it is a leak.)

Do you know what a memory leak is? Apparently, seeing as how you associated it with pointers, I'd say no.

EDIT -- Did you know THAT good looking code can have memory leaks still?


Indeed. Most of my code never leaks memory, well according to Valgrind at least, but I'd be amazed if it ever passed a checkstyle. What might seem like ugly code to one programmer, could be perfectly acceptable to another. The international obfuscated C code contest comes to mind; I'd argue that the "ugly" source codes in those entries are pieces of art.
Title: Re: Learning
Post by: rabbit on September 29, 2005, 06:57:57 pm
There can't possibly be anything broken with it.
There's plenty wrong with it, but good enough programmers can get around the problems.
What, in C, would you consider "broken"? Or are you just arguing to be an asshole?
namespaces, mostly.