Page 1 of 1
What are some proper books for learning C?
Posted: Sat Oct 31, 2015 7:02 pm
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.
Re: What are some proper books for learning C?
Posted: Sat Oct 31, 2015 10:38 pm
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
Re: What are some proper books for learning C?
Posted: Sun Nov 01, 2015 4:45 am
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.
Re: What are some proper books for learning C?
Posted: Sun Nov 01, 2015 6:58 pm
by mac
Is C absolutely necessary for a aspiring OsDever? I do think it's interesting to learn, don't get me wrong.
Re: What are some proper books for learning C?
Posted: Sun Nov 01, 2015 7:23 pm
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.
Re: What are some proper books for learning C?
Posted: Sun Nov 01, 2015 8:46 pm
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.
Re: What are some proper books for learning C?
Posted: Mon Nov 02, 2015 7:59 am
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.
Re: What are some proper books for learning C?
Posted: Mon Nov 02, 2015 8:52 am
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.
Re: What are some proper books for learning C?
Posted: Mon Nov 02, 2015 1:22 pm
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.
Re: What are some proper books for learning C?
Posted: Tue Nov 03, 2015 11:49 am
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.
Re: What are some proper books for learning C?
Posted: Thu Nov 05, 2015 8:01 am
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.