Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > The real world > Idle chatter

Reply
 
Thread Tools Display Modes
Old March 5, 2015, 18:41   #1
wobbly
Veteran
 
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,088
wobbly is on a distinguished road
Any good links for learning C?

Watching threads in the development sub-board is weird for me. I understand maths well enough that sometimes I can half follow what the code is meant to do, but don't know the syntax well enough to properly understand. I've been vaguely telling myself I should learn to code even if it's to just tinker around a bit for fun. Any good links for starting out? I used to be able to program a little in things like Basic, Fortran & Pascal so I'm not a complete coding Newbie (Though I've pretty much forgotten most of what I knew there).
wobbly is offline   Reply With Quote
Old March 5, 2015, 19:03   #2
Therem Harth
Knight
 
Therem Harth's Avatar
 
Join Date: Jan 2008
Location: New England winter
Posts: 921
Therem Harth is on a distinguished road
I would recommend shelling out for "The C Programming Language, 2nd Edition" (Kernighan and Richie):
http://www.amazon.com/The-Programmin.../dp/0131103628

The coding style it espouses is IMO a little dated; but it is still the best book on programming I know of, both as a tutorial and as a reference.

If you prefer a free book, I recommend this one:
http://publications.gbdirect.co.uk/c_book/

There's a PDF version at the link above.

Obviously, do the exercises. Maybe not so obviously, read other people's code. Angband is not a very pretty codebase at the moment, but it is handy for this.

Disclaimer: I'm actually a pretty awful programmer.
Therem Harth is offline   Reply With Quote
Old March 5, 2015, 19:28   #3
mrrstark
Adept
 
Join Date: Aug 2013
Posts: 101
mrrstark is on a distinguished road
Reading a book is great if you can do it.

I can't do it. It's too abstract.

I find the best way to learn something like C is to set a small goal I'm interested in, like say:
- "add a new spell or combat feature to Angband"
- "change the way that XYZ works"
- "write a little program that sends me an email reminder when I'm supposed to do that thing I hate doing"
- w/e you want.

Have a language reference to look at, follow examples you can find online, and then Google for any problems you run into, usually ending up at some stack exchange page.

The phrase "Cookbook" is sometimes a good start for example code on how to do something. I started learning C# from the O'Reilly C# Cookbook, coupled with a good reference, though I don't know of a specific book like that for C.
mrrstark is offline   Reply With Quote
Old March 5, 2015, 20:10   #4
fizzix
Prophet
 
Join Date: Aug 2009
Location: Madison, Wisconsin, US
Posts: 3,002
fizzix is on a distinguished road
Quote:
Originally Posted by mrrstark View Post
I find the best way to learn something like C is to set a small goal I'm interested in, like say:
- "add a new spell or combat feature to Angband"
- "change the way that XYZ works"
- "write a little program that sends me an email reminder when I'm supposed to do that thing I hate doing"
- w/e you want.
This is essentially how I learned C (although I had lots of experience in other languages.)

Can you get started here? Can you download angband source and compile?
fizzix is offline   Reply With Quote
Old March 5, 2015, 20:50   #5
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 54
Posts: 7,841
Donated: $60
Nick will become famous soon enough
Quote:
Originally Posted by Therem Harth View Post
Angband is not a very pretty codebase at the moment
I'm wounded
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old March 5, 2015, 20:51   #6
wobbly
Veteran
 
Join Date: May 2012
Location: Adelaide, Australia
Posts: 2,088
wobbly is on a distinguished road
Quote:
Originally Posted by fizzix View Post
This is essentially how I learned C (although I had lots of experience in other languages.)

Can you get started here? Can you download angband source and compile?
Will have a go over the weekend. Thanks to all, for the advice.
wobbly is offline   Reply With Quote
Old March 5, 2015, 20:55   #7
Therem Harth
Knight
 
Therem Harth's Avatar
 
Join Date: Jan 2008
Location: New England winter
Posts: 921
Therem Harth is on a distinguished road
Quote:
Originally Posted by Nick View Post
I'm wounded
I was talking about the pre-refactor code...

Edit: OTOH let's be fair, I wouldn't recognize "pretty" code if it wore flowers and a bow-tie.
Therem Harth is offline   Reply With Quote
Old March 5, 2015, 20:57   #8
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 54
Posts: 7,841
Donated: $60
Nick will become famous soon enough
Quote:
Originally Posted by Therem Harth View Post
I was talking about the pre-refactor code...
Oh, I agree then, that was garbage

*runs and hides from rest of devteam*
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old March 6, 2015, 00:36   #9
the Invisible Stalker
Adept
 
Join Date: Jul 2009
Posts: 164
the Invisible Stalker is on a distinguished road
Learning to program in C is easy. It's learning to debug C programs which is hard. And, of course, learning to write programs that other people can read and debug.

In general I agree with Therem Harth on this one: Kernighan and Ritchie is still the way to go. Except perhaps if you're going to be writing code where security is critical. K&R example code is often overly trusting of user-supplied input. I once mentioned this to Brian Kernighan, who told me that they had been aware of that even as they wrote it, but that in the computing environment of the time it didn't seem like a big issue. Fortunately for most of the things I do it still isn't much of an issue.
the Invisible Stalker is offline   Reply With Quote
Old March 6, 2015, 03:11   #10
buzzkill
Prophet
 
buzzkill's Avatar
 
Join Date: May 2008
Location: Indiana, USA
Posts: 2,939
Donated: $8
buzzkill is on a distinguished road
This is what I did.
Read C for Dummies.
Download an IDE.
Started writing simple programs.
Googled anything I didn't feel like looking up in a book.
Worked for me, though I'm nowhere near good enough to delve into a "band" and have since moved onto other interests.
__________________
www.mediafire.com/buzzkill - Get your 32x32 tiles here. UT32 now compatible Ironband and Quickband 9/6/2012.
My banding life on Buzzkill's ladder.
buzzkill is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bug: Good Grief, Good Greaves! mrrstark Sil 2 December 8, 2013 08:49
Posband links dead? Roch Variants 0 November 4, 2012 03:17
Broken Links buzzkill Oook! 4 December 16, 2011 10:41
Sangband links not working buzzkill Oook! 10 July 29, 2010 20:07
Learning.... Tonypantz Development 1 April 26, 2009 21:02


All times are GMT +1. The time now is 11:20.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.