Should I Learn C Programming from an Old Book?

In summary: That's a good question. I don't really know.I have the gut feeling that you can't really learn compsci from booksThat's a common misconception. Many people think that you need to be an "expert" in order to learn compsci, but that's not the case. You can learn the basics from any book.In summary, I think it's worth trying to learn from "the c programming language" by Kernighan and Ritchie, but I think it's a better use of time to just try and bang out some of the exercises on Project Euler or something.
  • #1
ergospherical
966
1,276
My dad gave me his old copy of "the c programming language" by Kernighan and Ritchie, but I was flicking through it and it comes across as quite old-fashioned and has a lot of random sh*t like pointer arithmetic, memory allocation etc.

Being an idiot, and one who's pretty out of practice with any of this stuff for a few years, is it worth trying to learn from it? I have the gut feeling that you can't really learn compsci from books, and it's a better use of time to just try and bang out some of the exercises on Project Euler or something.
 
  • Wow
Likes sysprog
Physics news on Phys.org
  • #2
ergospherical said:
you can't really learn compsci from books,
I looked and can't find my copy.
 
  • #3
ergospherical said:
My dad gave me his old copy of "the c programming language" by Kernighan and Ritchie, but I was flicking through it and it comes across as quite old-fashioned and has a lot of random sh*t like pointer arithmetic, memory allocation etc.

Being an idiot, and one who's pretty out of practice with any of this stuff for a few years, is it worth trying to learn from it? I have the gut feeling that you can't really learn compsci from books, and it's a better use of time to just try and bang out some of the exercises on Project Euler or something.
What the hecK? Pointer arithmetic is not random stuff. That's a good book. I suggest that you not only work some of the excercises; Please go ahead and write some code. "Can you code?" is something that one of my bosses said was the main thing that he cared about in a prospective employee.
 
  • Like
Likes Delta2
  • #4
nah my issue with it is that it’s a) old and b) I don’t really care about the subtleties of computer architecture at this stage

but I don’t know how far I can get just winging it, without ever eventually sitting down to learn the nitty-gritty stuff, if you catch my drift
 
  • #5
Is it the 2nd Edition? It is *much* better than the 1st Edition, IMO.

Yes, pointers are very important to learn, and so are data structures. K&R 2nd Edition is all that I use for my C programming. (I've had separate classes in data structures, compilers, etc. back in university)
 
  • Like
Likes sysprog
  • #6
ergospherical said:
nah my issue with it is that it’s a) old and b) I don’t really care about the subtleties of computer architecture at this stage

but I don’t know how far I can get just winging it, without ever eventually sitting down to learn the nitty-gritty stuff, if you catch my drift
Wow. Just wow. I think that regarding the "subtleties" and the "nitty gritty stuff" ##-## that's 'where it's at' ##-## please read, for example, some of @pbuk's and @Mark44's and @Baluncore's and @jbriggs444's and @berkeman's and other techie persons' posts here on PF ##\dots##
 
  • #7
ergospherical said:
I have the gut feeling that you can't really learn compsci from books
That's a little like saying, "You can't really learn physics/chemistry/whatever from books." The only difference I can see between these disciplines and programming is that you get immediate feedback when you're programming, possibly in the form of compiler errors or weird results.

I don't think you'll get very far by "banging out" exercises from Project Euler.
ergospherical said:
but I don’t know how far I can get just winging it, without ever eventually sitting down to learn the nitty-gritty stuff, if you catch my drift
Without understanding the "nitty-gritty stuff," like pointers and addresses, arrays, and memory allocation, you really won't get very far.
 
  • Like
Likes symbolipoint and sysprog
  • #8
berkeman said:
Is it the 2nd Edition? It is *much* better than the 1st Edition, IMO.
I have both. I agree that 2nd Ed. is better.
 
  • Like
Likes berkeman
  • #9
I seem to remember the original version of K&R explained how to write C, but not what it would do if you did.
A few years later a new programmer trained in C, told me that FORTRAN was useless because you couldn't declare a pointer. I had to point out that in FORTRAN everything was a pointer.
 
  • Like
Likes nsaspook, sysprog and pbuk
  • #10
ergospherical said:
it’s old
No older than Jackson. Does that make Jackson a bad book?

ergospherical said:
and has a lot of random **** like pointer arithmetic
If you think pointer arithmetic is "random stuff" then the book is too advanced for you.
 
  • Like
  • Haha
Likes vanhees71, sysprog, jim mcnamara and 1 other person
  • #11
Vanadium 50 said:
If you think pointer arithmetic is "random stuff" then the book is too advanced for you.
ROFL!
 
  • Like
Likes vanhees71 and sysprog
  • #12
ergospherical said:
nah my issue with it is that it’s a) old and b) I don’t really care about the subtleties of computer architecture at this stage

but I don’t know how far I can get just winging it, without ever eventually sitting down to learn the nitty-gritty stuff, if you catch my drift
On Nat Sci you can go all the way just winging it. If you are interested in a rigoruous background to Comp Sci then K&R is a great work of historical importance and interest. But it's 2021 and you need to focus: why do you want to learn C?

Edit: there are 59 courses here on scientific computing, not a lot of them have any C as a prerequisite: https://www.training.cam.ac.uk/ucs/theme/scientific-comp?providerId=36407
 
  • Like
Likes vanhees71, symbolipoint, sysprog and 1 other person
  • #13
pbuk said:
On Nat Sci you can go all the way just winging it. If you are interested in a rigoruous background to Comp Sci then K&R is a great work of historical importance and interest. But it's 2021 and you need to focus: why do you want to learn C?

The main reason I'm trying to get some practice now is that I want to join the hackathon society next yearr, and I don't particularly want to learn C (although I've done some objective-c for iOS, which is a bit different... hehe), since I think I'm mainly going to use python from here on.

What should I be doing to practice? It's fun just messing around with it, but I don't want to get into the habit of writing complete spaghetti code haha
 
  • Like
Likes vanhees71
  • #14
Yes objective-c is a 'bit' different :biggrin:.

The first 100 problems in project Euler are an OK way of practicing a language, although you can solve them just as well with ugly code as with good code. After that it is more about knowing a number theory trick than good coding.

Only a few days till the start of term, can you wait to meet up with current members to work on some stuff together/in competition?
 
  • Like
Likes vanhees71 and ergospherical
  • #15
C is probably the lowest of all "high-level" programming languages, just one step above Assembly. Memory allocation and all this other "random stuff" is the whole point of programming in C, that's why people choose it to write device drivers, operating systems (or at least their kernels), embedded software, and other stuff like that.
 
  • Like
Likes berkeman, sysprog and vanhees71
  • #16
Most programming languages use many different abstractions, lots of encapsulated black box functionality and a huge standard library. The C standard, on the other hand, defines a very clear and simple programming model with a tiny standard library. This model is also very close to the metal. It allows for a deep understanding of programming based on fundamental building blocks. C is beautiful and K&R is the book which makes this beauty tangible.

A completely different kettle of fish is the question of whether C is the right language to do a project you have on your mind (it probably isn't).
 
  • Like
Likes vanhees71, berkeman, sysprog and 1 other person
  • #17
Low level languages are written in the bare instructions to the CPU. So if you want to know what the computer is actually doing then that's what you need to know. The trouble with that is that low level languages are verbose and error prone, and any program written in that language works only on that CPU. It's not portable.

All operating systems were written in assembly language. That meant whenever you came up with a new computer you had to write the operating system more or less from zero. Bummer. So K&R came up with C and used it to write the UNIX operating system. It's basically a replacement for assembly language. It's much easier to port UNIX to your system than to start with nothing. So C is a sort of medium level language. It's good for writing programs that operate machines.

If you don't care about operating systems or machines or what the CPU is doing then you can go with a higher level language like C++ or Python or whatever. The emphasis of C++ is more on writing modular programs that are error-free and less on something that executes at the highest possible speed. Python is more flexible -- not that that is always a good thing -- and slower. And so forth and so on.

If you want to write quick programs then it is necessary to know exactly what the computer is doing and how much time each operation takes. If you don't care about that then you don't care about that.
 
  • Like
Likes vanhees71

1. Should I learn C programming from an old book?

It depends on your learning style and the resources available to you. Old books may still contain valuable information and concepts that are relevant to C programming. However, it is important to supplement your learning with updated resources and practice with modern tools.

2. Are there any disadvantages to learning C programming from an old book?

Yes, there are a few potential disadvantages. Old books may not cover newer features and updates to the C language, making it difficult to keep up with current practices. Additionally, the examples and exercises in old books may not be compatible with modern compilers and tools.

3. How can I determine if an old C programming book is still relevant?

You can research the publication date of the book and compare it to the release dates of newer versions of the C language. You can also read reviews and ask for recommendations from experienced C programmers.

4. Are there any benefits to learning C programming from an old book?

Yes, there are a few potential benefits. Old books may provide a thorough and in-depth understanding of the fundamentals of C programming. They may also offer a historical perspective on the evolution of the language and its usage.

5. Can I use an old C programming book as my only resource for learning?

No, it is not recommended to rely solely on an old book for learning C programming. It is important to supplement your learning with updated resources, practice with modern tools, and seek guidance from experienced programmers.

Similar threads

  • Science and Math Textbooks
Replies
1
Views
930
  • Programming and Computer Science
2
Replies
69
Views
4K
  • STEM Academic Advising
Replies
3
Views
923
  • Science and Math Textbooks
Replies
3
Views
1K
  • Programming and Computer Science
4
Replies
118
Views
6K
  • Programming and Computer Science
3
Replies
73
Views
4K
  • Programming and Computer Science
Replies
9
Views
2K
  • Science and Math Textbooks
Replies
28
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
3K
  • Programming and Computer Science
Replies
4
Views
2K
Back
Top