top | item 29498220

Ask HN: I'm looking for a good book on the fundamentals of CS

253 points| Karsteski | 4 years ago | reply

I'm at the beginning of my software dev career, and as I didn't go to school for anything related (B.Sc. Chemistry), I feel like I really would like to have the fundamentals of CS down. Doubly so as I would like to go into the field of VR, and right now I'm working on my own toy rendering engine, which I feel is really exposing my lack of knowledge...

Anyways, any suggestions welcome. Ideally it'd be more digestible than just a plain textbook but I'm open to anything. I imagine either way it'll be a tough but great read to work through :)

188 comments

order
[+] nomemory|4 years ago|reply
I had a good relantionship with Segdewick's books, before being turned off by Cormen a few times. They are less math focused, and overall have a beginner friendliness to them. They won't take you by the hand an explain things like you are 5, but nevertheless they are more easy to digest.

Also as a non-popular opinion in this current age, I recommend you to learn how to implement your algorithms in C, rather than an easier to grasp programming language. Even if you are probably not not going to program in C in your future career, understanding how memory management works will give you an edge later.

Also given C's loose style, you will also get some skills in organizing your code in a language that doesn't impose a lot of obvious constraints to the way you write your code. You will be able to build your own conventions, and evolve them once you get more skilled. Seeing what others are doing is also important.

Good luck!

PS: Don't fall into the macro trap, you will never get out. (inside joke).

[+] kevinventullo|4 years ago|reply
I’ll sort of second this by saying that Sedgewick’s Algorithms I/II courses on Coursera are top-notch and completely free. He is a truly thoughtful educator.

Completing those courses was probably the most useful thing I did when prepping for interviews as part of a career change 6 years ago.

[+] cloverich|4 years ago|reply
This was the book I used. It is more accessible yet interestingly some comments seem to characterize it as "beginner friendly" in a way that suggests it is less canonical. Make no mistake, if you learn the material in Sedgewick well you'd be light years ahead of 99% of your peers. It likewise provides depth and foundations for things like leetcode, thus far the majority of leetcode problems I've done were toy versions of things covered in the book.

On a more personal / subjective PoV, IMHO its just a much better book than the majority of the others. Its not as basic as Grokking Algorithms nor as interview focused as Cracking the coding interview. I would suggest the latter if you just want to be good at programming interviews.

[+] tomhallett|4 years ago|reply
I like how Segdewick's book comes with working examples in java, which feels very approachable for a practitioner. In comparison, Cormen's book has lots of pseduo code examples where the indexing is 1 based. Cormen lays out the reasoning for this early in the book, how 1 based indexing is clearer for teaching, which sounds completely reasonable but is an additional hoop to jump through when trying to build working examples of the algorithms.
[+] scns|4 years ago|reply
CS50 from Harvard on https://edx.org used to teach Computer Science using C and still might do so.
[+] randcraw|4 years ago|reply
"Foundations of Computer Science" by Aho and Ullman might fit your bill. Its focus is more on the concepts and principles of computing rather than math-centric CS theory. http://infolab.stanford.edu/~ullman/focs.html

Another nontraditional intro to computing worth mentioning is "Structure and Interpretation of Computer Programs" by Abelson and Sussman(s). It teaches programming concepts using the Lisp/Scheme language (seldom used any more), but does so brilliantly.

"Think Python: How to Think Like a Computer Scientist" by Downey might provide the right mix of computing concepts and programming practice.

If you do want a traditional intro to CS theory, two books that cover that topic well are: "Introduction to the Theory of Computation" by Sipser, and "Introduction to Automata Theory, Languages, and Computation" by Hopcroft, Motwani, and Ullman.

Three very good books that introduce algorithms are: "Introduction to Algorithms: A Creative Approach" by Manber, "The Algorithm Design Manual" by Skiena, and "Algorithms" by Sedgewick and Wayne.

Remember that CS theory doesn't age, so buying a used early edition of a textbook should serve your needs just as well as an new up-to-date edition.

[+] throwawaygh|4 years ago|reply
Based on the description you give, you probably want a Data Structures/Algorithms intro.

The canonical Algorithms textbook is Introduction to Algorithms by Cormen et al. The MIT OpenCourseware course on Algorithms -- which includes videos and assignments -- follows along with that book: https://ocw.mit.edu/courses/electrical-engineering-and-compu...

Note: In your case, I'll recommend against SICP as a first resource, which is mentioned in some other comments. It's more of an introduction to functional programming. From your description, I'm not sure you need an intro to programming. And functional programming in particular is not really on the critical path of knowledge you'll need to muck about in VR land. It's not irrelevant, but it's not the critical path. An algorithms course probably is indispensable for that endeavor, though.

By all means, read SICP if you'd like. It's a great resource. But if you're trying to get from "I can program" to "hardcore hacking on VR stuff", step 1 is probably a decent algorithms course taught in the imperative style.

[+] Turing_Machine|4 years ago|reply
CLRS is great, no doubt about it, but I think Sedgewick is probably friendlier to someone studying on his or her own. Note that there are several versions of Sedgewick, which use different languages (I think there are at least C, C++, and Java versions).

I'd go with Sedgewick, then get CLRS and Knuth for use as reference material.

[+] commandlinefan|4 years ago|reply
So my problem with CLRS is that a lot of the content is in the exercises. There are places in the text where it says, "refer back to solution to problem 34", etc. The problem is, there are no answers to exercises to be found - and the exercises are so open-ended there's no way to check to see if you actually got the right answer or not. IMHO, CLRS (or any educational text that doesn't make exercise answers available) is one of the worst options for self-study.
[+] molsongolden|4 years ago|reply
Grokking Algorithms is also a good quick read in this space. It's a high level "here are some things you should know about and how they might be used" which exposes the reader to important algorithms and patterns without going too deep.
[+] jhanschoo|4 years ago|reply
Note that a 4th edition of this book (frequently referred to as CLRS) is coming out sometime early next year.
[+] nostrebored|4 years ago|reply
CLRS truly is the canonical way to learn algorithms at most top CS institutions. I can't upvote this enough.
[+] kyleblarson|4 years ago|reply
I was lucky enough to have Cormen teach my algorithms class in school as well as a few other courses. He is a phenomenal teacher.
[+] yakubin|4 years ago|reply
I'm currently going through TAOCP[1]. So far, seems pretty good (although I found one mistake in an exercise).

Also, I can never recommend Computer Systems: A Programmer's Perspective[1] enough. (Also features a rare mistakes in an exercise or two, but that's detail.)

And for network protocols, Comer's Internetworking with TCP/IP[3] was just great (you only need volume 1). I've read Stevens' books on socket and IPC programming in Unix, but didn't like them, so I also stayed away from TCP/IP Illustrated, but others have different opinions.

[1]: <https://www-cs-faculty.stanford.edu/~knuth/taocp.html>

[2]: <https://www.csapp.cs.cmu.edu/>

[3]: <https://www.pearson.com/us/higher-education/program/Comer-In...>

[+] globular-toast|4 years ago|reply
> although I found one mistake in an exercise

Check on Knuth's website to see if it's already been corrected. If not, you could get a prestigious Knuth reward cheque for finding an error.

[+] commandlinefan|4 years ago|reply
Hm - I've read all three books and even tried working the exercises... I can't say I'd recommend TAOCP to somebody who's looking for a book on the fundamentals of CS. The books are fascinating, don't get me wrong, and I recommend every programmer read them, but they go way too deep into minutiae, while simultaneously ignoring other important topics to be useful as an introduction.
[+] amackera|4 years ago|reply
If you mail Don Knuth about the error you found in TAOCP, he'll send you a check for $1 -- he used to do that, anyway. People tend not to cash the cheque, but keep it.
[+] srcreigh|4 years ago|reply
God bless you. I tried reading the AOCP books and it's hard... and I have a degree in CS
[+] nickt|4 years ago|reply
I’m 27 years out of Uni and it’s great to see Comer's book still being used and recommended, and updated of course.
[+] decebalus1|4 years ago|reply
> I'm currently going through TAOCP[1].

When someone without a formal CS career is asking for a CS fundamentals book and you're dropping TAOCP I'm not sure if this is a humble brag or an attempt at trolling.

[+] lcuff|4 years ago|reply
I highly recommend "An Introduction to General Systems Thinking, by Gerald Weinberg. An orthogonal piece of advice that I got from a different book of Gerald Weinbergs' is to learn 3 or 4 Very Different languages simultaneously, to grasp the enormous difference between them all. In 2021 I'd recommend C (lowest level other than assembler: 1st caveat, I haven't looked at Rust) and then at least one Lisp-family language that has Lots of Insane Silly Parentheses, which Paul Graham argues is the most powerful language (by far). I'd also choose Smalltalk and Python. Caveat 2: Every programmer will have an opinion on this list, but the main point is to get exposed to the diversity of languages. Also, I'd recommend listening to a lot of talks by Alan Kay. There is lots of fun and interesting stuff to learn from lots of different people, but Alan Kay has focussed on how do we develop stuff that is radically simple, radically powerful, and completely accessible to children as a tool for learning and exploration. His notion of 'object-oriented' (a term he invented) is completely different from how the term is used today.
[+] pjmorris|4 years ago|reply
First, I want to support any mention of any Gerald Weinberg book. Every one is gold. IMO, Intro to GST is great for developing a scientific mindset, something broader than computer science itself.

I would suggest a grain of salt to go with the three-four languages at a time recommendation. I'd have to dig up a stored book to find the reference, but Weinberg typically suggests learning two different languages, at least at the beginning. He advocates for the benefits of recognizing it's possible to say the same thing in different ways. My knee-jerk reaction, knowing him, is that he picked two rather than three or four to make things manageable for people getting started. If programming becomes a hobby, vocation, and/or avocation you'll likely wind up learning most of those languages eventually.

[+] bmitc|4 years ago|reply
I would personally de-recommend Python. It essentially has no unique paradigm or even one that it does really well. I'd replace the Python suggestion with an ML-dialect such as F# or Ocaml. I agree with you though. I think everyone needs a bit of experience with a Lisp/Scheme, an ML dialect, a Smalltalk, Elixir/Erlang, Prolog, and Forth.

And I think it's better to think in paradigms rather than languages in that you choose a new language to learn a new paradigm.

[+] tomxor|4 years ago|reply
Interested in what gets suggested here...

There are a lot of "CS Course Online" type suggestions posted on HN, which are great - but for those of us with full time jobs and lives it's just a non-starter to approach that quantity of material.

I'm also more of a hands on learner which is how I got to where I am - but at the same time I can appreciate and happily absorb a well written, thoughtful book... In other words, I only have time for high quality, and high information density.

My meta suggestion in answer to the author: Not to downplay the utility in general CS knowledge and fundamentals, but you already sound like you are driven and have a direction - I recommend you ride that wave and buy books or seek out material that's more specific and relevant to what you are doing right now. You will soak it up so easily when you have something right in front of you to apply it to or think about - it's an opportunity, you will work on different things throughout your working life and this opportunity may pass. Personally, I have found CS fundamentals work their way to the surface through research into these more domain specific things - although I still recognise I could have much better awareness if I tackled it head on as you are suggesting.

[+] jonjacky|4 years ago|reply
Algorithmics by David Harel is not much mentioned anymore, but it's really good if you can find it. An easy and inviting read, it was written as a popular book not a textbook but nevertheless covers many topics with very thorough and clear explanations, and also touches on history and culture. I recall there were several versions with different titles - Algorithmics: The Soul of Computing was, I think, a cut-down version.

Seconding Petzold's Code for hardware and low-level programming. Also seconding Downey's Think Python (which has appeared in several versions with different titles). It is an easy read but is a bit deeper than many introduction to Python books.

Also seconding Wirth's Algorithms + Data Structures = Programs but it requires a lot more concentration and study than the previous suggestions. It is also old-fashioned, from the late 1970s I think, uses Pascal as its programming language. It teaches and celebrates a rigorous, economical programming method and coding style which is not much in vogue any more.

[+] tzs|4 years ago|reply
The Harel book is "Algorithmics: The Spirit of Computing", not "The Soul of Computing".

The book was actually originally just called "The Science of Computing" and published in 1987. The second edition in 1992 had the name changed to "Algorithmics: The Spirit of Computing". The third edition in 2004 kept that name and had Yishai Feldman added as coauthor. There was a 2012 reprinting of that which had a new preface written for it that talked about Turing (2012 was his centennial year).

I have the original 1987 edition. Comparing its contents to the third edition's via preview on Amazon, it looks like the first four parts are mostly the same topics.

The chapter on "Algorithms and Intelligence" had moved from the fourth section to a new fifth section and been renamed to "Algorithmics and Intelligence", and a new chapter, "Cryptography and Reliable Interaction" has been added to the fourth section.

Other new chapters, all in the fifth section are "Software Engineering" and "Reactive Systems".

The second edition, according to the preface in the 2012 printing, had little change from the first as far as the chapter content but added exercises and solutions.

From second to third chapter 3 changed from "Programming Languages" to "Programming Languages and Paradigms" and dropped APL and Snobol and added C, C++, and Java. Chapter 10 changed from "Parallelism and Concurrency" to "Parallelism, Concurrency, and Alternative Models" and added quantum computing and molecular computing.

[+] rramadass|4 years ago|reply
Excellent !

Your recommendations are right on the money and not just for noobs. This is the first i have seen Harel's book Algorithmics being mentioned on HN. More people should read this book; not sure why it is not that well known.

Just to add to your comment;

Students need to understand the distinction between Computing Science and Computer Science. Harel's Algorithmics explains the former while Petzold's Code explains the latter. Wirth's Algorithms + Data Structures = Programs marries the two.

[+] skripp|4 years ago|reply
”Code: The Hidden Language of Computer Hardware and Software” by Charles Petzold.

It will take you on a journey from a lightbulb to assembly language. It’s extremely well written and I wish there were more books like it.

[+] irony123|4 years ago|reply
Second this. A great book for understanding how computers work at a low level.
[+] aklemm|4 years ago|reply
Literally the perfect place to start.
[+] atsheehan|4 years ago|reply
I liked "Algorithms Unlocked" by Cormen (https://mitpress.mit.edu/books/algorithms-unlocked). It's the same author that co-wrote "Introduction to Algorithms" (or CLRS) that's referenced in a few other comments, but this one focuses on the what and why of algorithms and pulls samples from a few areas of interest.

It's not too long (~200 pages), so might be worth checking out before diving into one of the more comprehensive textbooks.

If you're interested in 3D programming, I found "3D Math Primer for Graphics and Game Development" to be the most accessible for the math fundamentals. I just discovered it's now available freely online as well: https://gamemath.com/.

[+] debo_|4 years ago|reply
A couple friends of mine in similar situations spoke very highly of The Imposter's Handbook (https://bigmachine.io/products/the-imposters-handbook/)

I have a CS degree and I still really enjoyed reading through the 1st ed. of the first volume. I haven't looked at what was done with the material since then.

[+] bern4444|4 years ago|reply
My favorite CS book is structure and interpretation of computer programs.

I used it for one of my college CS classes. The book was written to be a semester class and MIT even has various offerings of their version of the course recorded and available on YouTube.

The book is online and available for free.

https://mitpress.mit.edu/sites/default/files/sicp/full-text/...

[+] nixpulvis|4 years ago|reply
I can't recommend How to Design Programs (HtDP) enough.

The authors care deeply about not just the content, but the learning process itself. It may at times feel repetitious and even boring, but it's a principled introduction to CS which will set you up for success in ANY programming language. And the book is free online :)

https://htdp.org/

From here you can graduate to lower level programming concepts in C (or Rust), more practical languages like Ruby, Python or even Java for high level application design. Basically, it's time to learn about full-fledged memory management one way or another. Don't miss out on some type theory along the way, remembering that they are just codified data definitions and function signatures.

[+] revorad|4 years ago|reply
I haven't used it myself but have heard good things about the resources here - https://teachyourselfcs.com
[+] srcreigh|4 years ago|reply
Also haven't used it, but this link from there [0] regarding intro to CS-style discrete math proofs seems somewhat lacking.

There doesn't seem to be enough focus on teaching proof techniques, and skips straight to discrete math content.

Could be a decent beginner resource if combined with something that teaches proof techniques though.

EDIT: the MIT book also listed is actually good [1]

[0]: https://cims.nyu.edu/~regev/teaching/discrete_math_fall_2005...

[1]: https://courses.csail.mit.edu/6.042/spring17/mcs.pdf

[+] ivanech|4 years ago|reply
This is a great list. The person who made it runs a school for CS fundamentals, and I've been taking classes there for about a year. I strongly recommend it: https://bradfieldcs.com
[+] shmde|4 years ago|reply
This website is blocked in India with the message.

"The website has been blocked as per order of Ministry of Electronics and Information Technology under IT Act, 2000."

https://imgur.com/a/NuRxjFl

[+] ChrisArchitect|4 years ago|reply
Hope you're searching first, lots of book threads every few months here:

a month ago Ask HN: What are some of the best well-written books on computer science? https://news.ycombinator.com/item?id=29182386

3 months ago Ask HN: What are your top 5 favorite computer books? https://news.ycombinator.com/item?id=28308141

7 months ago Ask HN: Best book for software engineers (besides the well-known ones)? https://news.ycombinator.com/item?id=26833319

[+] 0x7E3|4 years ago|reply
Structure and Interpretation of Computer Programs, by Abelson, Sussman, and Sussman.

Also known as "The Wizard Book" or "SICP".

The full text is legally available online[1], but I found it worthwhile to buy a copy.

There are at least two really good sets of video lectures to go with it if you are so inclined. Personally I enjoyed the ones from Berkeley.

[1]: https://mitpress.mit.edu/sites/default/files/sicp/index.html

[+] andrewjanke|4 years ago|reply
Beware of the Cormen et al "Introduction to Algorithms". It's a good book. But while it says "introduction", it's typically used for like a third-year undergrad who has a fair amount of programming, data structures, and algorithm experience already. It's more about algorithm _analysis_ - that is, how to prove things about algorithms and formally establish their run-time/complexity bounds - than about how to use or write them. Probably not what you want to start with.

Knuth's Art of Computer Programming is even more hardcore than that, imho. Probably not what a beginner wants unless you want to dive right in to the deep end.

SICP is more accessible but still pretty textbook-y.

But I don't actually know what I'd recommend instead. I did a CS undergrad degree, so Cormen and other textbooks are how I learned. But I did that over 5 years with lots of professional help. Dunno what a good self-study-friendly alternative is.

[+] vngzs|4 years ago|reply
Surprised no one seems to have mentioned the godfather of CS books, The C Programming Language by Brian Kernighan and Dennis Ritchie [0]. At first glance, it's a programming language book rather than a "computer science" book, but you probably won't think that by the time you're finished ...

First, every operating system you'll use - likely in your lifetime - is a giant mountain of C code. From the kernel all the way to the userspace utilities. As a programmer, your career will be forged on the shoulders of giants, and those giants wrote in C. So to understand how your machine works, you must learn C.

Second, K&R covers far more than just a language - it presents a system of thinking about computing. It covers algorithms for line counting, memory allocation, and the construction of linked lists. The techniques you learn for pointer manipulation will enable you to author implementations of data structures that are considerably more elegant and simple than the naive methods [2].

It contains fundamental, influential insights about the computer science field on nearly every page.

Still, I'd discourage you from writing C professionally if you can help it. Rust retains nearly all the advantages of C while abandoning its unsafe memory model and replacing it with compile-time determined allocations and de-allocations. As roughly 70% of CVEs in C or C++ projects are caused by memory unsafety, this is a significant feature [1]. But the insights you make in studying K&R will translate to everything you build, regardless of language.

You'll walk away with a mental model for computers so powerful that it was the genesis of our modern technology era.

[0]: https://en.wikipedia.org/wiki/The_C_Programming_Language

[1]: https://www.chromium.org/Home/chromium-security/memory-safet...

[2]: https://grisha.org/blog/2013/04/02/linus-on-understanding-po...

[+] aidenn0|4 years ago|reply
FWIW, I liked Plum's "Learning to program in C" far better than K&R's book. I can't recommend Plum today though because it's pre-ANSI so the code all uses K&R style declarations.
[+] isabellat|4 years ago|reply
Bottom up cs is a great resource. https://www.bottomupcs.com/ It might feel very low level at first but once you understand these fundamental building blocks of computers you will be really well equipped to build upon this knowledge and learn higher level concepts. I also think the Rust Programming book (https://doc.rust-lang.org/book/) is a great resource for general programming knowledge. Some sections e.g. on the borrow checker and lifetimes aren’t 100% applicable to general programming knowledge but I still recommend it. It is more of a 201 level book instead of 101 though.
[+] vecter|4 years ago|reply
That website is poorly named. It's not about computer science any more than a resource on anatomy is about medicine.
[+] tomstuart|4 years ago|reply
I don’t think you’ll find a better return on investment than working through The Elements of Computing Systems (https://www.nand2tetris.org/) which recently got a second edition. It won’t teach you how to make a rendering engine, or even necessarily any data structures or algorithms, but it will give you a big-picture understanding of the practical fundamentals (literally “what is a computer and how does it really work?”) which you can then use to direct your own learning based on what you want to know next.