Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does good, modern c code look like? [closed]

Tags:

I'm primarily a c#/.NET programmer, but the hobby project that I am about to take on will involve coding in c.

I know that there is a ton of c code out there, but its very hard to separate a well structured c project from a badly structured project if you did not "grow up" with the language. Can anyone point me toward a newer, non trivial (but not enormous) project that is considered a good example of how to structure c code?

Edit

If you cannot find a project, feel free to discuss in words how you think a c project should be structured.

like image 543
Giovanni Galbo Avatar asked Aug 19 '09 22:08

Giovanni Galbo


People also ask

What is modern and Code C?

Modern C introduces you to modern day C programming, emphasizing the unique and new features of this powerful language. For new C coders, it starts with fundamentals like structure, grammar, compilation, and execution.

Is C still relevant?

C exists everywhere in the modern world. A lot of applications, including Microsoft Windows, run on C. Even Python, one of the most popular languages, was built on C. Modern applications add new features implemented using high-level languages, but a lot of their existing functionalities use C.

What is C used for today?

It is used in developing an operating system. Operating systems such as Apple's OS X, Microsoft's Windows, and Symbian are developed using 'C' language. It is used for developing desktop as well as mobile phone's operating system. It is used for compiler production.


2 Answers

Dave Hanson's C Interfaces and Implementations is a very well-crafted library of about 7000 lines of code. The book is great if you can afford it.

The implementation of the Lua programming language and libraries is about 17,000 lines of C code and is very well done but quite sophisticated in places—compilers and garbage collectors are not so easy to understand without background in those fields. But the code is beautifully engineered.

Git is over 125,000 lines of code. I can't recommend that anyone study it as an example of how to engineer C code. Just the design and public interfaces, let alone the implementations, are hard to understand—which is why there are so many git tutorials.

like image 53
Norman Ramsey Avatar answered Oct 21 '22 10:10

Norman Ramsey


Check out git source code: http://github.com/git/git/tree/master

like image 21
Piotr Czapla Avatar answered Oct 21 '22 08:10

Piotr Czapla