Re: Advice on learning C as first language

Previous thread: OpenBSD 4.8 crash unexpectedly by Bahador NazariFard on Wednesday, November 24, 2010 - 7:51 am. (7 messages)

Next thread: Can't build SOPE from ports. by Hugo Osvaldo Barrera on Wednesday, November 24, 2010 - 8:29 am. (3 messages)
From: James Hozier
Date: Wednesday, November 24, 2010 - 7:55 am

My first programming language ever was Visual Basic, but I was 11 years old at the time and it was just a mandatory elective class I had to take to get credits in order to graduate school, and I didn't even know what a programming language was back then. I thought I was just writing words on the screen to make the program do things (we made stuff like tic-tac-toe, shooting a basketball into a hoop by inputting correct coordinates/arch, etc.) I forgot everything I learned since then, so I have absolutely no recollection at all of VB except "rem" which I recall as being equivalent to a comment in any other language.

Later when I began to edit code to make programs do exactly what I wanted, I basically guessed what all the functions did and how the programs worked to modify them, and as long as they worked, I really wasn't concerned at all about how crappy the quality of the code was. So I decided to actually learn a language and I had heard Python was easy so I started learning Python first. But before finishing the first chapter I was told by several people that Perl was much "better." Considering their opinion was probably better than mine, I switched to Perl and picked up a book for Perl beginners but again before I even learned the print function, I read online that the first programming language one learns could be crucial to the person's future programming skills and habits that become ported to other programming languages they learn later on, and I don't want to develop any bad habits and practices. I've decided to choose C as my first language, for various
 personal reasons (mostly to audit code for security).

So, as a newbie with no knowledge in programming at all whatsoever and wanting to learn C, I bought K&R's The C Programming Language (2nd edition) as per the suggestion on the OpenBSD website. I read the disclaimers in the intro of the book, and read on anyway. But the book seems to move very fast and does not elaborate too much on the features of the language, I guess due to the book not ...
From: Jan Stary
Date: Wednesday, November 24, 2010 - 8:09 am

Start with LISP, I'm tellin' ya.

From: Jona Joachim
Date: Wednesday, November 24, 2010 - 8:49 am

Come on, LISP is from teh past, learn Haskell already.


-- 
Worse is better
    Richard P. Gabriel

From: Scott Learmonth
Date: Wednesday, November 24, 2010 - 9:06 am

It something I keep dabbling in - very sowly - I find this a good pace for my
totally noob self:

It started out as a reddit:

http://www.reddit.com/r/carlhprogramming


And morphed to:

http://www.highercomputingforeveryone.com/


It's certainly a "start from zero" but I like the pace, and the C bent.

Cheers




From: Nicolas P. M. Legrand
Date: Wednesday, November 24, 2010 - 11:27 am

From: Bret Lambert
Date: Wednesday, November 24, 2010 - 8:07 am

at the time and it was just a mandatory elective class I had to take to get
credits in order to graduate school, and I didn't even know what a programming
language was back then. I thought I was just writing words on the screen to
make the program do things (we made stuff like tic-tac-toe, shooting a
basketball into a hoop by inputting correct coordinates/arch, etc.) I forgot
everything I learned since then, so I have absolutely no recollection at all
of VB except "rem" which I recall as being equivalent to a comment in any
basically guessed what all the functions did and how the programs worked to
modify them, and as long as they worked, I really wasn't concerned at all
about how crappy the quality of the code was. So I decided to actually learn a
language and I had heard Python was easy so I started learning Python first.
But before finishing the first chapter I was told by several people that Perl
was much "better." Considering their opinion was probably better than mine, I
switched to Perl and picked up a book for Perl beginners but again before I
even learned the print function, I read online that the first programming
language one learns could be crucial to the person's future programming skills
and habits that become ported to other programming languages they learn later
on, and I don't want to develop any bad habits and practices. I've decided to
wanting to learn C, I bought K&R's The C Programming Language (2nd edition) as
per the suggestion on the OpenBSD website. I read the disclaimers in the intro
of the book, and read on anyway. But the book seems to move very fast and does
not elaborate too much on the features of the language, I guess due to the
book not being total-noob-friendly. I can barely follow along and get what's
going on, but have no idea what the terminologies and phrases being used in
the book mean since the book assumes the reader knows basic programming such

The classic "The C Programming Language" is good.

After that, learn from good sources; for raw ...
From: Marco Peereboom
Date: Wednesday, November 24, 2010 - 8:47 am

That is a bit of a rough book to start with but very good.  It is very
dense but touches on most language features.  Its density is actually
what makes it so good.  You can read it twice in a weekend.  Once you do
that pick a simple utility from /bin and go read the code.  That will
put what you learned/read in the book in perspective.

The thing that that book does not teach is libraries and other things
since it simply focuses on the language itself.  Some other books I
found very helpful were:
http://www.amazon.com/Practice-Programming-Brian-W-Kernighan/dp/020161586X/ref=sr_1_1?...
http://www.amazon.com/Programming-GNU-Software-Andy-Oram/dp/1565921127/ref=pd_sim_b_5

The must have is:
http://www.amazon.com/Programming-Environment-Addison-Wesley-Professional-Computing/dp...

All that reading aside; the only way to truly "get it" is to read a
piece of code you are interested in and deconstructing it completely.
The trick is finding a piece of code that illustrates the things you are
interested in *and* is well written.  Most things in the OpenBSD tree
are well written but beware of the dragons.  Doing this a couple of
times will make almost anyone interested enough a good enough coder.

Learning C is easy; learning to using C right is the hard part.  Read
more code to learn from the experts.

Good luck.


From: Bahador NazariFard
Date: Wednesday, November 24, 2010 - 9:14 am

I agree with Marco Peereboom <slash@peereboom.us>
He told "Learning C is easy; learning to using C right is the hard part.
 Read
more code to learn from the experts."

I think if you are sharp u can learn C during one week.
But using C is not so easy. You should be able to think as a programmer.
I think all parts of a  program is important.
you should pay attention to design, algorithm, debug, data structure,
architecture and also libraries.
you can not be a programmer by learning syntax of every computer language.
 I think programming is an art And there is only one way to learn an art,
practice makes perfect.

you can learn programming by reading and writing real projects codes.


-- 
Gula_Gula =;=; BNF

From: Michael H Lambert
Date: Wednesday, November 24, 2010 - 9:28 am

And I'll add (I'm not a computer scientist!) that one should thoroughly
understand functional programming before even thinking about object-oriented
programming.

Michael

From: Daniel B.
Date: Tuesday, December 14, 2010 - 9:09 pm

From: Kenneth Gober
Date: Wednesday, November 24, 2010 - 8:55 am

C is a decent first language to learn; but I think that starting with C will
focus your attention on the mechanics of how things happen at a very
fundamental level, which is all well and good if you plan to write operating
system kernels or device drivers (or audit them for security).  and starting
with C will help you later learn all the C-derived languages that came
after: C++, Java, C#, etc.

but if you intend to write applications, you may be better served by
starting with a language that focuses your attention on the structure of
your programs and the relationship between their parts.  once you have a
good foundation about the structure and meaning of programs, it's a
relatively simple matter to learn any programming language, including C and
the C-derived languages, as well as languages that are not remotely C-like.

since you've indicated that you are interested in a 'first' language, I must
assume you plan to learn other languages later.  as a result, I strongly
recommend that you start with the book "Structure and Interpretation of
Computer Programs" (available online at
http://mitpress.mit.edu/sicp/full-text/book/book.html, or you can buy a
paper copy if you prefer, for example from Amazon:
http://www.amazon.com/Structure-Interpretation-Computer-Programs-Engineering/dp/026201...).
 this book will give you an excellent foundation on programming in general
(and the Scheme programming language in specific).

despite what some Scheme fans claim, I personally have not found Scheme to
be a terribly useful language for 'real' work.  however, I believe that it's
an excellent language to learn programming with, and when combined with the
book I mentioned, it will leave you in an excellent position to then choose
any other language (or set of languages) you wish.

C was one of my first languages, and while I cannot say that I regret it, I
can't help but feel that in the long run I would have been better served
learning Scheme first.

-ken

From: Christiano F. Haesbaert
Date: Thursday, November 25, 2010 - 5:20 am

http://www.amazon.com/Structure-Interpretation-Computer-Programs-Engineering/

Are you insane ?
Recommending  SICP to a guy that just started programming and CS in general ?
Have in mind that not everyone is a MIT grad.

Learning lisp/scheme as ones first language is sweet, but it just
doesn't happen in 2010, that makes me said, but it's the truth. Before
flaming me, I'm quite fond of scheme and elisp.

Stick with Marco's books and you should be fine. I also recommend the
following, disregard the name, it isn't all that:
http://www.amazon.com/Expert-Programming-Peter-van-Linden/dp/0131774298

Another advice is, make yourself small goals like "try to write a
wc(1) program", try to write a strtok(3) function and stuff like that.
Also have in mind that learning C can be quite painful.

From: Sevan / Venture37
Date: Thursday, November 25, 2010 - 5:44 am

Absolute beginners guide to c is very lightweight & accommodating
http://www.amazon.co.uk/gp/aw/d/0672305100/ref=mp_s_a_1?qid=1290688733&sr=8-1

If you're going the k&r route there is the c answer book which goes with it
apparently, I've not read it myself but it explains the answers to the
exercise in k&r

http://www.amazon.co.uk/gp/aw/d/0131096532/ref=mp_s_a_1?qid=1290688949&sr=8-1

Sevan / Venture37

From: Kenneth Gober
Date: Thursday, November 25, 2010 - 7:26 am

On Thu, Nov 25, 2010 at 7:20 AM, Christiano F. Haesbaert <

SICP isn't used to teach MIT grads, it's used as the entry-level course to
teach MIT undergrads how to program (or so I understand, I never went to
MIT).  if a college undergrad can use it to learn programming while also
taking 5-6 other classes at the same time, then I'm confident the OP (who I
assume isn't trying to learn 4-5 other things at the same time) can manage
the task as well.

that is, if the OP wants a solid foundation in program design, rather than
merely learning a language.  it roughly corresponds to the difference
between someone who wants to learn to be a draftsman, versus an architect.
 they both start out doing similar things, but one of them will end up going
farther.

I stand by my recommendation - SICP and Scheme to learn the basics, most
importantly how to *think* about programs.  after that, K&R will suffice to
teach you how to express your already well-structured thoughts in C syntax.

-ken

From: Nicolas P. M. Legrand
Date: Thursday, November 25, 2010 - 7:42 am

actualy I'm not sure it's used anymore

http://www.wisdomandwonder.com/link/2110/why-mit-switched-from-scheme-to-python

It's on the list of books I want to read anyway :)

From: Ludo Smissaert
Date: Thursday, December 2, 2010 - 1:59 pm

I have read that book after I learned C from "The C Programming
Language" and I found it especially useful in the way it explained
complicated declarations in C. Only for that it is already worth the money.

I have spend much more than one weekend with "The C Programming
Language" and immediately after finishing it, I dived into studying
about linked lists. These documents where tremendously helpful:

http://cslibrary.stanford.edu/103/
http://cslibrary.stanford.edu/102/

But I stopped using "Pointers to Pointers" as was suggested here.

Also this video is on my list of recommendations:

http://cslibrary.stanford.edu/104/

	Regards, Ludo

From: Brad Tilley
Date: Wednesday, November 24, 2010 - 9:36 am

I'm no expert, but I do program C for applications (not operating
systems). My advice would be to study data structures, pointers and
concepts such as const, struct, etc. and to understand why types are
important. When you script with Python/Perl/Ruby much of that is glossed
over, but is really important.

By itself, C is very basic and small and can be learned quickly.
However, if you need a data structure to do useful things, you need to
find a library or roll your own.

I would suggest learning C++ as a C with more stuff built-in. Its STL
has well-tested lists, queues, stacks, maps, vectors, hashes, etc.
built-in to it so you are not rolling your own or looking at external
libraries. It also has references (but you can still use raw pointers if
you like) and the C++ compiler won't let you get away with nearly as much.

Just my experience, good luck.

Brad

From: Brad Tilley
Date: Wednesday, November 24, 2010 - 10:02 am

Forgot to mention a book... If you decide to take the C++ route, I
suggest "Accelerated C++".

http://www.acceleratedcpp.com/

From: Marco Peereboom
Date: Wednesday, November 24, 2010 - 3:32 pm

I'll call crap on c++

It doesn't really qualify as a language but more as a "let me show you how
smart i am" tool for tools.

Object orientation is interesting on the surface however the promises have
never materialized.

I'll reiterate my previous point. Learn C, if required you have most tools and
ideas figured out to use other fancy languages (which ultimately degenerate
into understanding C anyway).

C is somewhat hostile and that is a good thing. Nothing brings attention
quicker to an app than crashing. Crashing is good; running in some sort of
unknown state is bad.

I happened to learn assembly first and C was just an easier way to do things.
Honestly, not much has changed over the years. I tried many languages and have
always gravitated back to C. New things are new and last a couple of years and
then something new pops up that will write all the code for you. Unfortunately
when writing code you have to do that pesky task of writing code.

FWIW


From: Peter J. Philipp
Date: Wednesday, November 24, 2010 - 10:27 am

Hi, 

I see you already bought the book, perhaps an online primer could help you
too.  I have dabbled in writing a C primer on Hackepedia at

http://www.hackepedia.org/?title=C_Primer

You can read it, and you can modify it and add other parts if you wish.
The C examples have a line number in front of them ala w.r. steven's books
it helps explaining what each line does in that regard.  To make them work
use awk '{$1= ""; print;}' or something.

And my advice regarding learning C is that you not only read source code
but also write your own and learn from your mistakes by comparing.

Cheers,

-peter

From: Darrin Chandler
Date: Wednesday, November 24, 2010 - 2:20 pm

If you go to the book store or Amazon, look at the page counts on books
to learn computer languages. Many of them are huge. They give you lots
and lots of words so that you don't have to think very much and get your
information in tons of very small doses.

On the other hand, K&R gives you concentrated goodness. But you will
have to approach it differently. If you read something and don't
understand it completely, stop and think about it. Then reread that part
again and think some more until you do understand. *Carefully* read the
code they show until you understand it. *Really* try the exercises (I
mean it). If you're not used to doing this it will be difficult, but it
will be worth it. If you can do this you will have a better grasp of C
than some professionals. If you give up and get the 800 page book you
will finish it and still not know important things about C and
programming.

But you do not have to read only 1 book. So maybe some of the books
others have recommended will help, but still keep K&R.

Also see http://www.highercomputingforeveryone.com/ for free online
material for beginners.

-- 
You've been warned.

From: Tomas Bodzar
Date: Thursday, November 25, 2010 - 12:00 am

Hi,

that one is quite funny and not too technical (as one you mentioned)
book
http://www.dummies.com/store/product/C-For-Dummies-2nd-Edition.productCd-0764
570684,navId-322467.html
. But best jump to C and assembler (in my opinion) is that one
http://nostarch.com/hacking2.htm . Good description of C keywords with
real examples which are immediately examined in gdb. Even if you will
not read rest of the book (just chapters 1 and 2) you will learn a lot
about C, gdb and assembler.

at the time and it was just a mandatory elective class I had to take to get
credits in order to graduate school, and I didn't even know what a programming
language was back then. I thought I was just writing words on the screen to
make the program do things (we made stuff like tic-tac-toe, shooting a
basketball into a hoop by inputting correct coordinates/arch, etc.) I forgot
everything I learned since then, so I have absolutely no recollection at all
of VB except "rem" which I recall as being equivalent to a comment in any
basically guessed what all the functions did and how the programs worked to
modify them, and as long as they worked, I really wasn't concerned at all
about how crappy the quality of the code was. So I decided to actually learn a
language and I had heard Python was easy so I started learning Python first.
But before finishing the first chapter I was told by several people that Perl
was much "better." Considering their opinion was probably better than mine, I
switched to Perl and picked up a book for Perl beginners but again before I
even learned the print function, I read online that the first programming
language one learns could be crucial to the person's future programming skills
and habits that become ported to other programming languages they learn later
on, and I don't want to develop any bad habits and practices. I've decided to
wanting to learn C, I bought K&R's The C Programming Language (2nd edition) as
per the suggestion on the OpenBSD website. I read the disclaimers in ...
From: Tomas Vavrys
Date: Thursday, November 25, 2010 - 4:06 am

their first language and explain basic programming terms along the way?

I tried a lot of things and if I could go back I would choose "How to
Design Programs". It's free and it uses DrScheme which is great for
learning purposes. It allows you to run and watch your program
step-by-step. Definitely do not start with SICP, it's as dense as C
Programming Language by K&R.

"How to Design Programs" is available for free here
http://htdp.org/

After that I would jump to C Programming Language by K&R, because C is
fundamental knowledge , but mainly because I love operating systems.
But if you do not want to go through "How to Design Programs" just
stick to "C Programming language by K&R" and use Google a lot. I love
that book and I think it's great book even for start, but you have to
think and work on your own a lot. After all there there is nobody who
holds your hand forever. Get used to harder approach, it makes things
easier later.

One last recommendation if you plan to stick to operating systems.
Learn shell programming first and along "C by K&R" read also "Computer
Systems: A Programmer's Perspective".

1)
http://www.amazon.com/Teach-Yourself-Shell-Programming-Hours/dp/0672323583/
2)
http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/
along with
3)
http://www.amazon.com/Computer-Systems-Programmers-Perspective-2nd/dp/0136108
040/

Good luck!

"I will persist until I succeed. Henceforth, I will consider each
daybs effort as but one blow of my blade against a mighty oak. The
first blow may cause not a tremor in the wood, nor the second, nor the
third. Each blow, of itself, may be trifling, and seem of no
consequence. Yet from childish swipes the oak will eventually tumble.
So it will be with my efforts of today."

From: Friedrich Locke
Date: Wednesday, December 15, 2010 - 3:57 am

Let's go:

at the time and it was just a mandatory elective class I had to take to get
credits in order to graduate school, and I didn't even know what a programming
language was back then. I thought I was just writing words on the screen to
make the program do things (we made stuff like tic-tac-toe, shooting a
basketball into a hoop by inputting correct coordinates/arch, etc.) I forgot
everything I learned since then, so I have absolutely no recollection at all
of VB except "rem" which I recall as being equivalent to a comment in any

Visual Basic: the eternal disease. It is very good you forget VB. Keep
basically guessed what all the functions did and how the programs worked to
modify them, and as long as they worked, I really wasn't concerned at all
about how crappy the quality of the code was. So I decided to actually learn a
language and I had heard Python was easy so I started learning Python first.
But before finishing the first chapter I was told by several people that Perl
was much "better." Considering their opinion was probably better than mine, I
switched to Perl and picked up a book for Perl beginners but again before I
even learned the print function, I read online that the first programming
language one learns could be crucial to the person's future programming skills
and habits that become ported to other programming languages they learn later
on, and I don't want to develop any bad habits and practices. I've decided to

To the point, the first language one learns is very important for
unlearing is not a possible experience. I suggest you go into Djkistra
wanting to learn C, I bought K&R's The C Programming Language (2nd edition) as
per the suggestion on the OpenBSD website. I read the disclaimers in the intro
of the book, and read on anyway. But the book seems to move very fast and does
not elaborate too much on the features of the language, I guess due to the
book not being total-noob-friendly. I can barely follow along and get what's
going on, but have no idea ...
Previous thread: OpenBSD 4.8 crash unexpectedly by Bahador NazariFard on Wednesday, November 24, 2010 - 7:51 am. (7 messages)

Next thread: Can't build SOPE from ports. by Hugo Osvaldo Barrera on Wednesday, November 24, 2010 - 8:29 am. (3 messages)