DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 24th November 2010
guitarscn guitarscn is offline
Package Pilot
 
Join Date: Oct 2008
Posts: 166
Default Book(s) for learning C as a first language?

I wasn't sure where to post this thread because the Book Reviews section seems to be only for book reviews and not asking what books to read. I thought this section would be more suitable although I was also considering posting this to Off-topic.

My first language ever was Visual Basic, but I was 11 years old at the time and it was just an elective class I had to take that was mandatory towards getting 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 the "rem" statement which I recall as being equivalent to a comment in any other language.

Later when I began to rustle through much open source code and basically guessed what all the functions did and how the programs worked, I decided to 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 began on a book for beginners but again before I even learned the print function, I read 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.

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 advice on the OpenBSD website (since that's the OS I use). 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.

Are there any books that are more noob-friendly that want to learn C as their first language?
Reply With Quote
  #2   (View Single Post)  
Old 24th November 2010
rocket357's Avatar
rocket357 rocket357 is offline
Real Name: Jonathon
Wannabe OpenBSD porter
 
Join Date: Jun 2010
Location: 127.0.0.1
Posts: 429
Default

Python will ruin you forever. You'll wish you were using Python on every project after you get a taste. Avoid it, at least until you have a strong background in "less luxurious" languages.

I started off with TCPL and Linux kernel source. Pretty shortly after that I started reading OpenBSD source instead for various reasons (code is more straightforward and better documented, easier to read and comprehend, etc...).

Other books I've found that really help are "Advanced Programming in the Unix Environment" and "The Art of Software Security Assessment". "Advanced Programming in the Unix Environment" sounds like it'd be more advanced and less noob-friendly, but if you're running Unix (which you obviously are) it can take abstract ideas and bring them out into concrete code that you can work with in a very helpful way.
Reply With Quote
  #3   (View Single Post)  
Old 24th November 2010
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by guitarscn View Post
Are there any books that are more noob-friendly that want to learn C as their first language?
The first question to answer is why do you want to learn C programming? What is your goal?

Without being able to answer these questions, you may dabble at it for awhile, & as life continually presents issues which have to be dealt with immediately, further study will get pushed back, & back, & back again. Ultimately, nothing gets accomplished.

All languages have their learning curves, & understanding one's first language will be the hardest. From reading most of your posts over the last two years, I gather that programming isn't directly related to whatever you do professionally. That's fine, but for those outside of the industry, it is even more important to have a tangible goal in which you are wanting to surmount.

If your goal is to fix sound on your MacPro as discussed on misc@, that is a highly ambitious goal. To get from A to B will require a significant amount of time & dedication. You can expect full understanding to take months to years depending upon how effectively you attack the problem, & how much time you have to commit to this particular endeavor.

With no understanding of what your goals are, my suggestion is to start with something like Python first & learn to write increasingly more sophisticated code there. The learning curve is somewhat less steep in comparison to systems-level C programming, & you can become productive more quickly.

Yet to reiterate the main point, unless you have a specific problem you are wanting to solve, you could easily fall into the trap of getting nowhere.
Reply With Quote
  #4   (View Single Post)  
Old 24th November 2010
guitarscn guitarscn is offline
Package Pilot
 
Join Date: Oct 2008
Posts: 166
Default

I already know that writing drivers is definitely not an easy thing to do. I've heard from people that do code them that it is hell. So that isn't my goal (as far as short-term vision goes; I will probably get another computer or maybe write drivers in the very, very future but highly likely as I'm not really interested in that subject and there are lots of talented folk who are already doing a pretty good job IMO.

Being an OpenBSD user for some time, I would eventually like to get into the security field and start being able to audit code for zero day exploits, on top of performing the compulsory penetration testing routine as well. The way I see it, the scan for existing issues are just previously known or recently disclosed zero days, so wouldn't it just be better to stay one step ahead in the first place? Granted that code auditing takes much more time (and arguably, skill), this is the reason why I would like to start practicing now and be able to read C in order to start Assembly later on and understand buffer overflows and the related family more, eventually auditing operating systems themselves (the ones written in C, at least).

Does this clarify my intentions better so that I can be given more specific advice?
Reply With Quote
  #5   (View Single Post)  
Old 24th November 2010
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

If this is something you're interested in doing, enough to take the time to learn the ropes.. then don't let anyone discourage you.

It will take time, and effort, but if you read the latest undeadly article.. Henning Brauer only had a basic understanding of the C language when he first started using OpenBSD, but he has gone on to make very large and influential changes to the networking stack and PF.

There are a lot of people who prefer using high level languages for occasion programming tasks, but there is a lot to be said about learning how to use system-level languages and getting a better grasp on how things work, like memory allocations, pointer management.

I find obscuring those details to be a negative influence on programmers, languages like VB tend to shield even basic concepts about computers away from their users, adding a layer of eye candy and misdirection.

Indeed it is a matter of personal taste, perhaps you shouldn't limit your "pallet", but I would wager a person using C alone would be better off than someone who used an interpreted language.

http://undeadly.org/cgi?action=artic...20101115091138
Reply With Quote
  #6   (View Single Post)  
Old 24th November 2010
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

It may not be the best book for "Holding the newbies hand", as newbies have gotten greener since it was written, but for learning C, I would recommend The C Book and a copy of the ISO standard for C99 when you need a precise reference.

If you really want to *know* C, the C book is a good start.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #7   (View Single Post)  
Old 25th November 2010
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 1,027
Default

My 2 cents, assuming you choose to stick with C, is not to give up entirely on K&R. Yes, it definitely should be supplemented with some more modern reading (which I don't really have any good suggestions about), but K&R is a very good classic book.

When I first started to learn C (coming from a weak fortran background) I was lucky enough to have a copy of K&R sort of fall into my hands. First time into it it all seemed so freakin weird, and I soon gave up. But later I went back to it and things started to make more sense, and I ended up working through most of it. It's a concise book, so there's real meat in every paragraph, and no fluffy sidebars about "Understanding Semicolons For Dummies", so you can't really rush through it. But with every chapter you've accomplished something.

Also, since it sounds like you'd be not only learning the C language, but also learning programming alongside, it would be really important to work all (or most) of the problems to gain that sometimes painful experience.
Reply With Quote
  #8   (View Single Post)  
Old 25th November 2010
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by guitarscn View Post
...I would eventually like to get into the security field and start being able to audit code for zero day exploits, on top of performing the compulsory penetration testing routine as well.
Getting past the compulsory details first, here are two introductory C titles:These have been around for a long time, & many reviews can be found for each. I haven't read, used, or taught from either, so I cannot vouch for their fortitude.

I, too, learned C from K&R2, & I am also of the opinion that learning C as a first language is problematic. Others here may disagree, but anyone wanting to discuss this point should do so in a different thread. I only point this out here to admit my own bias.

I also cringe at the thought of learning assembly language without having some general programming experience first. The problem in both cases is that both C & assembly language are very rich in the manner that expressions can be chained together, & without maintaining some discipline which comes from experience, the resulting program structure can be an unintelligible mess.

If your goal is to become a pen tester, I see three aspects you need to focus upon to reach your goal or modify your expectations to be more realistic:
  • Pen testing is not a common gig within the industry. Conduct research to find out what jobs in your area resemble what you want. My experience has been that these jobs can only be found within companies peddling security products (& there are a lot of bad ones...), or these will be found in large companies (eg. Cisco, Juniper, IBM, etc.) either focusing on network or hardware products. There are some tiny shops who are eager to get their name in the press for finding some exploit, but they live on finding exploits such that someone else with either hire them or buy them out. Many of these companies come & go with the blink of an eye.

    Collateral to finding out what jobs are available is finding out what skill sets employers are looking for in potential employees. This is important because this will show you how you stack up to your competition.
  • Recognize that the OpenBSD project's view on security is only one among many. Although I don't advocate that certifications offer much additional credibility, having a cert on a resume is better than having a blank resume. More important is the knowledge & perspective which comes from studying general security issues. You might want to look at what is required by the CISSP to see where you stand in comparison.
  • As opposed to asking for book titles, you will gain from going to a local college/university library and/or bookstore to see what C books they have available, & perhaps looking through whatever textbook is currently being used in their fall/winter C programming courses. Night classes offered by the local public school system will also likely have an introductory C class. This may be an avenue to accelerate where you are on the learning curve.
I can only guess that pen testing would be a significant career change. At this point, you are looking to fill in your deficiencies. Most people I know who ended up in these positions were either very experienced sysadmins, or software or networking developers. This may give you an idea of the background expectations.
Reply With Quote
  #9   (View Single Post)  
Old 26th November 2010
unicyclist unicyclist is offline
Real Name: Mike
Fdisk Soldier
 
Join Date: May 2008
Location: Alaska
Posts: 63
Default

I'll send as pm first

Last edited by unicyclist; 26th November 2010 at 03:18 AM. Reason: pm
Reply With Quote
Old 12th December 2010
Mako_Elite Mako_Elite is offline
BSD_ROCKS
 
Join Date: Nov 2010
Posts: 75
Default

"Problem Solving and Program Design in C" by Hanly and Koffman is really good.
I have the second edition I am using it right now. There is already sixth edition
out there.

"C How to program" by Deitel and Deitel is good but I prefer "Problem Solving and Program Design in C".

I think you can only benefit to learn C, at least it wont hurt. I sure like the speed of compiled C code.
Reply With Quote
Old 12th December 2010
drhowarddrfine drhowarddrfine is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 377
Default

I agree that assembly language and C are key to learning how systems work and should be learned first. I don't believe anything should be abstracted away when you know nothing about it. However, esr believes Python is the best 'first language'.

It may depend on the person. In my case, as I'm coding, I visualize how the cpu fetches data from memory and physically sends it to ports and devices; but my background is hardware design. One may not need to think that way is writing a graphics program but doing driver development, my way of thinking would probably help immensley.
Reply With Quote
Reply

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
Can anybody recommend a book for learning how to work with OpenBSD firewalls? jepettrey OpenBSD Security 6 24th November 2010 02:28 PM
C language inventor spurns Google's language exam J65nko News 4 22nd April 2010 09:07 AM
Learning how to program Solaris_Delta Programming 9 24th December 2008 07:58 PM
Learning Programming Crypt Programming 35 27th October 2008 04:54 PM
Learning Perl mtx Book reviews 7 22nd October 2008 05:55 PM


All times are GMT. The time now is 03:38 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick