What are some proper books for learning C?

Programming, for all ages and all languages.
Post Reply
mac
Member
Member
Posts: 144
Joined: Tue Sep 23, 2014 6:12 pm

What are some proper books for learning C?

Post by mac »

I have a little bit of theoretical programming knowledge already, but what are some proper book suggestions for those starting to program C? Is ANSI K&R a good idea or not? I don't think it will matter, but I asked for an opinion.
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: What are some proper books for learning C?

Post by alexfru »

K&R 2nd ed.

C: A Reference Manual 5th ed. by Harbison & Steele Jr.

C99 + TC1 + TC2 + TC3, WG14 N1256:
http://www.open-std.org/jtc1/sc22/wg14/ ... /n1256.pdf

Rationale for C99:
http://www.open-std.org/jtc1/sc22/wg14/ ... eV5.10.pdf

The New C Standard: An Economic and Cultural Commentary:
http://www.knosof.co.uk/cbook/cbook.html
embryo2
Member
Member
Posts: 397
Joined: Wed Jun 03, 2015 5:03 am

Re: What are some proper books for learning C?

Post by embryo2 »

I think the toolchains are also very important. I have no deep expertise in C, so I hope for available toolchains review and recommendations. And may be some OS specifics like ELF or Portable Executable, DLLs vs SOs, POSIX vs Windows API and so on. But may be it's not the osdev.org where such information should be, then some links are very appreciated.
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability :)
mac
Member
Member
Posts: 144
Joined: Tue Sep 23, 2014 6:12 pm

Re: What are some proper books for learning C?

Post by mac »

Is C absolutely necessary for a aspiring OsDever? I do think it's interesting to learn, don't get me wrong.
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: What are some proper books for learning C?

Post by alexfru »

SeanMc wrote:Is C absolutely necessary for a aspiring OsDever? I do think it's interesting to learn, don't get me wrong.
No, you can write an OS in assembly language.
Is assembly absolutely necessary for an aspiring OsDever?
No, you can write an OS in machine code.
Is machine code absolutely necessary for an aspiring OsDever?
No, you can hire someone.
mac
Member
Member
Posts: 144
Joined: Tue Sep 23, 2014 6:12 pm

Re: What are some proper books for learning C?

Post by mac »

alexfru wrote:
SeanMc wrote:Is C absolutely necessary for a aspiring OsDever? I do think it's interesting to learn, don't get me wrong.
No, you can write an OS in assembly language.
Is assembly absolutely necessary for an aspiring OsDever?
No, you can write an OS in machine code.
Is machine code absolutely necessary for an aspiring OsDever?
No, you can hire someone.
Well, I guess that answer speaks for itself.
embryo2
Member
Member
Posts: 397
Joined: Wed Jun 03, 2015 5:03 am

Re: What are some proper books for learning C?

Post by embryo2 »

SeanMc wrote:Is C absolutely necessary for a aspiring OsDever? I do think it's interesting to learn, don't get me wrong.
Well, then you can learn something else. But your starting point was about learning C. Strange transition.
My previous account (embryo) was accidentally deleted, so I have no chance but to use something new. But may be it was a good lesson about software reliability :)
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: What are some proper books for learning C?

Post by Muazzam »

SeanMc wrote:Is C absolutely necessary for a aspiring OsDever? I do think it's interesting to learn, don't get me wrong.
I've written an OS, which is self-hosting, in an assembly language. And believe me or not, I know nothing about C. I can (barely) understand the code written in C, though. I've tried several times to learn it but it's too hard and probably useless. Just assembly is enough for me.
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: What are some proper books for learning C?

Post by alexfru »

muazzam wrote: I've written an OS, which is self-hosting, in an assembly language. And believe me or not, I know nothing about C. I can (barely) understand the code written in C, though. I've tried several times to learn it but it's too hard...
I believe you. Been there.
muazzam wrote: I've tried several times to learn it but it's too hard and probably useless. Just assembly is enough for me.
I don't think I could find a job in low-level areas (OS, embedded, etc), where I could get away with just assembly language. (NASA is looking for living dinosaurs who can program in assembly, FORTRAN and COBOL.) I've been cashing my C, C++ and assembly knowledge and skills for the past 15 years or so.

Nevertheless, I too had a tough transition to C. I learned my first programming languages in this order: ZX Spectrum BASIC, Z80 assembly, Borland/Turbo Pascal, i8051 assembly, x86 assembly, C. Like I said earlier, C is awkward for historical reasons. This is of little help to a beginner, of course, but C is not awkward for the sake of being awkward or keeping noobs out. The titles and the links shown above should be sufficient for learning proper C. But you also need to write lots of code to internalize the language. If you have a friend, who knows C well (preferably, very well, because it's not uncommon to learn bad habits from someone knowing it poorly or having major understanding gaps when it comes to things like undefined behavior), then their help can be tremendous. And, IMO, you don't need a lot of help. You probably just need some help with navigating through a few bad places. Otherwise the language is rather simple.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: What are some proper books for learning C?

Post by Kevin »

SeanMc wrote:Is C absolutely necessary for a aspiring OsDever?
Passive knowledge is pretty much a must because otherwise you won't understand most code examples. But you can always write your own code in a different language - not only assembly, which has already been mentioned, but also other high level languages. That said, I did write some kernel code in Pascal and while it's definitely workable, it's not quite as smooth as with C.
Developer of tyndur - community OS of Lowlevel (German)
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: What are some proper books for learning C?

Post by Schol-R-LEA »

The wiki does a fair job of covering the possibilities and pitfalls of using a language other than C or assembly for OS dev. See the Languages for OS Development and Developer Archetypes: Alta Lang entries for advice on this subject and critiques to this approach.

You can also look at the Bare Bones pages for Ada, D, Pascal, and FreeBasic. Someone probably should write up BB pages for Rust, Go, and C# as well, given the interest in them, but that's up to contributors familiar with them.

My own approach is rather unusual, in that I am writing my own (unconventional) assembler and designing a new language that will target it, with OS dev being the key but not sole purpose for them. My OS will be in layers, and much of the kernel for the OS proper will be in assembly.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Post Reply