Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Linux kernel (or other low level stuff) a "good" example of how to write C [closed]

Tags:

c

linux-kernel

Following the "what's the best use for C" question.

The Linux kernel seems to be a famous and very well thought of C program. But is it a good example of mainstream "best-practice" C?

like image 361
interstar Avatar asked Jan 14 '09 00:01

interstar


1 Answers

I'm prepared to get dinged for this, but the Linux kernel is a student project that got out of hand. More seriously, what the Linux kernel does well from a programming point of view is lay down a very rigid set of design and coding guidelines that make it possible for a very large number of people to contribute while still having everything fit together.

People I trust who have made operating systems their life's work tell me that the BSD kernel is a much better example of good C programming and good OS design. I know enough of the professors at Berkeley that I'm not surprised by this claim.

More broadly, OS kernels are highly specialized things---there's nothing mainstream about a kernel. If you want examples of good C practice you might try Kernighan and Pike's book on The Practice of Programming. Or if you want to study a real system, the implementation of Lua is small enough that you can read it all, extremely well engineered, and incredibly portable---runs on any platform with an ANSI C compiler.

Apologies for the subjective and argumentative reply :(

like image 176
Norman Ramsey Avatar answered Sep 28 '22 04:09

Norman Ramsey