How to practice Unix programming in C?

After five years of professional Java programming (and to a lesser extent, Python) and a slow sense of my CS education, I decided that I want to expand my horizons / general usefulness for the whole world and do what I feel more), as if I really affect the car. I decided to learn C and Unix programming, as I feel that many of the most interesting problems exist.

My ultimate goal is to do it professionally, if only for the reason that I have to spend 40-50 hours a week on work paying my bills, so this may be the type of Coding I want to get better. Of course, you are not hiring to do what you did not have before, so for now I am not building up my strength.

To this end, I started with K & R, which was a great resource, in part thanks to the exercises distributed throughout each chapter. After that, I moved on to Computer Systems: a programmer perspective , and then ten chapters of Advanced Unix Programming . When I'm done with this book, I will read Unix Network Programming .

What I miss in Stevens books is the lack of programming problems; they mostly document functionality and provide examples with a few questions at the end of the chapter. I feel that I would benefit much more from challenging the use of knowledge in each chapter of ala K & R. I could write some test program for each function, but this is a less desirable method, since (1) I would probably be less motivated than if I went up to some external challenge, and (2) of course, I will only think about using the function in what has already happened to me.

So, I would like to get some recommendations on how to practice. Obviously, my first choice is to find some kind of resource that has problems with Unix programming. I also looked at searching and trying to contribute to some open source C project, but it's a bit complicated, as learning to use the software will incur some overhead and then learning the code. The only open source C project I can think of, I use Python regularly, and I'm not sure how easy it is to start with it.

However, I am open to all suggestions because there are things that I did not even think about.

+43
c unix
Jun 01 '10 at 13:44
source share
8 answers

Restore many basic Unix utilities. Most of them have been (and still are) written in C, so they are a good way to start learning. Depending on your skill, choose more complex or simple utilities for copying.

Try writing your own malloc. You'll learn a lot about Unix and C programming.

Google for CS operating system courses and complete projects there. Many schools have these projects on public websites so that you can get everything you need. There is a link to the Purdue website. Give the shell project a shot, it was difficult, but really educational.

+23
Jun 01 '10 at 13:49
source share
— -

Here are a few stackoverflow posts discussing C / Unix programming books. Their main claim to fame is an extensive splitter for other resources.

Practice some of the idioms (understand the inputs and outputs of pointers, etc.) and choose projects that will help with this. The third item on the list has an answer (disclaimer, I wrote it) with a bunch of high-level C-idioms, where the idiomatic C program will be different from Java.

Learning XLIB or Win32 GUI programming with C is probably less useful, since almost everything is better than C for GUI programming, and wrapping the C core with another language is usually much simpler - if you are really not interested in speed. As a starting point, focus on “system programming” applications where you are more likely to get a real run from C. Find out how the C interface of a single scripting language such as Tcl or Python works.

Writing some kind of hard code with a bit rate and a pointer (for example, collecting network packets or interpreting a protocol) or server-side elements using sockets will lead you to C. If you have some of the WRS books, try pthreads (for IIRC UNP2 has a large section on pThreads). For contrast, write something that uses non-blocking I / O. This material is C home turf and you will gain a good knowledge of C by doing this. Scroll through the RFC for some ideas on network protocols to implement.

  • What are some good Linux / Unix books for the advanced user?
  • What are some good resources for learning C outside of K & R
  • Resources for Learning Software C
  • What is a good way to start learning about data structures and algorithms?
  • Algorithms in C
+5
Jun 01 '10 at 14:01
source share

Can you reserve offers? Although it's a bit dated (where “a little” is probably a huge understatement), Maurice Bach's “Unix Operating System Design” is a great book. It belongs next to K & R on your bookshelf.

+1
Jun 01 '10 at 16:38
source share

You can try to work through all the examples from the book Software Tools (Amazon). Most of them are quite pedestrian (right-justify text, de-tabify, etc.), but this is a great introduction to unix philosophy and basic C programming.

+1
Jun 01 2018-10-06
source share

This is pretty interesting. Since we know that Unix is ​​designed using the C language, this may not be easy to learn. If you are using Windows, you can use the Windows Services for Unix application to practice your programs. If you use unix, we can use editors like vi.

+1
Mar 03 '11 at 9:50
source share

The best way to consolidate your knowledge is to practice. Therefore, just select the type of application that interests you and begin to develop it (for example, a simple cli / server application for the network). Try testing most UNIX-APIs (files, sockets, etc.) to find out how this works. For example, you can get the Unix programming book, follow its chapters, and test everything you read on your application by creating your own functions. Thus, you can start developing your own library of functions that will be used in other projects.

0
Jun 01 '10 at 14:01
source share

Write a web server.

  • Make it multithreaded.

  • Does it support the new scripting language that you are developing (a la PHP, etc.).

  • Allow booting from authenticated users.

  • Write a plugin for your favorite tool (i.e. integrate with SVN to give a web overview).

0
Jun 01. '10 at 14:12
source share

I would recommend one thing highly.

Try overwriting all the usual Linux command line tools like ls, mkdir, cd, etc.

You will gain a lot of knowledge about programming and Linux at the same time.

Choose the teams from the simplest ones, say “time” and go through all the more difficult ones.

0
Jul 05 '16 at 7:43
source share



All Articles