Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Books that teach programming by building a series of small projects?
473 points by newsoul on Jan 17, 2023 | hide | past | favorite | 203 comments
It is common knowledge that when first learning programming, one should start with small projects to build something real rather than learning rules and syntax of the language only.

Which are some of the best books that take a project based approach in teaching programming to a beginner?




While not for beginners, if you'd like to learn rust I recently finished "Command line Rust" [1].

It was my first introduction to rust and the book was quite enjoyable. It starts off with teaching you the very basics of a command line (what it means to exit, true, or false, etc) and each chapter has you recreate a popular command line tool (like grep, cal, tail, wc) while introducing a new rust concept.

The book also does TDD, test driven design, by first teaching you how to create these tests then in subsequent chapters having the tests prewritten for you.

It's definitely worth a look, the author has a great writing style as well that isn't as monotonous as most programming books I've read.

[1] https://www.oreilly.com/library/view/command-line-rust/97810...


Glad we can buy the book standalone without getting a membership to O'Reilly.


I may sound like a shill but I think paying for O'Reilly is worth it. You get access to many books and videos outside the O'Reilly publisher. Definitely worth it, I tend to read a tech book a month (maybe 2 if it's "light.")

Many of the books being suggested in the other comments are available as well (will definitely start Hands-On Rust because it seems very cool, and Practical Common Lisp shortly afterwards).

Out of all the "tutorial" offerings I only pay for three services:

O'Reilly (four years so far)

Educative.io (two years)

Frontendmasters (eight years)

Every year I test out other services (pluralsight, lynda/linkedin learning, egghead, etc) but outside of one or three core offerings they don't seem to be a good value for what I want.


I'm curious why you pay for those services and not the others. Is it a matter of topics, teaching style?


I find the quality for frontend masters to be extremely high, over the last 4 years they've gotten workshops from people working at Netflix, Google, Microsoft, LinkedIn, Amazon; while some of the courses have a short shelf life due to versioning issues of tech they are discussing/teaching, I tend to watch all of them when they get released.

Compare this to pluralsight, which I feel like 80% of the courses are just regurgitating the documentation back to the user very poorly, or udemy that whose courses are typically stretch to 20-40 hours when they topic barely warrants 4 hours (see any frontend course).

I like educative.io because they are the best interview prep site out there IMO, I also enjoy some of their specific topics outside of interview prep (devops, concurrency, threading, etc); what's nice about educative.io is that it's all text based, I read way faster than I can watch. Also helps that they had a really good discount a few years ago that I'm still using (something like 3 or 4 years for the price of a single year).

O'reilly is great because, as I stated elsewhere, they have an enormous collection of books not just from O'Reilly but Packt Publishing, Manning, Apress, No Starch Press; they also have decent video courses from the same publishers as well.

There are very few technical books I'm willing to buy a physical copy of, I don't live in a large space so I have limited area for the books I do have, I do however like reading technical books. I'm also grandfathered in at a previous price point, so I feel like I'm "forced" to get my moneys worth. So reading 12-15 books is the "worth it" spot for me.


That's fair. I think some people just like the option of buying the book.


I like having a physical book sitting on my desk practically screaming "Read me, why did you buy me if you're not gonna read me?" ... As opposed to all those ebooks not even downloaded, let alone seen.


It's free if you have a Toronto Public Library card.


Just to clarify, when you say "not for beginners" do you mean beginners to Rust or programming in general?

edit: Based on your "It was my first introduction to rust" comment I think maybe you meant programming beginners?


Sorry, I meant that you need some programming experience. It will not teach the basics of if loops, making structs, etc; it's a good introduction to rust, prior programming experience required.


I'm assuming you also need to understand pointers and memory layout perhaps?


Definitely pointers, but IIRC it does go over the concepts. I don't recall if it ever touches lifetimes tho.

The book basically uses the crate clap to create all the CLTs, along with specific crates for regex and creating ascii tables for the cal clone.


Came here to mention just that book. It is excellent.


Thank you! I needed this one, how fun, I did this when learning Haskell, now I can do it with Rust.


There’s quite a few:

- Zed Shaw’s Learn More Python the Hard Way[1]

- Brian Hogan’s Exercises for Programmers (best for beginners or for learning a new language)[2]

- Hal Fulton’s The Ruby Way[3]

- Chris Ferdinandi’s Vanilla JS Academy[4]

- Marc-Andre Cournoyer’s Great Code Club (it’s old, and the community doesn’t exist anymore, but i think he still maintains it)[5]

- A few python books from No Starch Press (notably those authored by Al Sweigart)

I learned the most as a beginner from Zed Shaw’s work, and from reading open source code.

Once you’re done with the initial “learn from tutorials” phase, there’s no better resource than reading open source code.

[1] https://www.amazon.com/Learn-More-Python-Hard-Way/dp/0134123...

[2] https://www.amazon.com/Exercises-Programmers-Challenges-Deve...

[3] https://www.amazon.com/Ruby-Way-Programming-Addison-Wesley-P...

[4] https://vanillajsacademy.com/

[5] https://www.greatcodeclub.com/


Specifically "Automate the Boring Stuff with Python" is my favourite Al Sweigart book.


I would also recommend "Automate the Boring Stuff with Python" [1], as you are learning hands on with some practical stuff: from generating Excel-files to PDFs, from sending e-mails to work with files and folders. At the end you will have some tools to automate some of your daily tasks for real. Oh, and it's free to read as well.

[1] https://automatetheboringstuff.com/


I'm not much of a Python guy, but concur with this; I enjoyed this book and did get something out of it.


Best explanation of Regex that I have ever seen


> - A few python books from No Starch Press (notably those authored by Al Sweigart)

Yes for example https://nostarch.com/inventwithpython and https://nostarch.com/big-book-small-python-projects


I learnt ruby with Zed Shaw’s Learn Ruby the Hard Way. Was a really great experience!


Is Shaw's first Python book any good?


Shaw has had some strong opinions that have gone significantly against the mainstream viewpoint in Python. Whether he's right or not doesn't really matter - as an educator that is targeting the mainstream it's fairly important to stay on that and not introduce personal bias around these things. Unfortunately his criticism was often not very constructive.


despite my other comment here I do agree with you on this, especially remembering his comments on test tools, nose for example


Yeah, he pushed back hard against the Python 3 migration, by picking on a small number of trade-offs that he personally didn't like and using that to conclude that the entire endeavour was doomed. The Python 3 migration wasn't flawless by any means, but it was better than he made out.

I know his "criticism" also held back many from moving their libraries to Python 3 by sowing doubt in the community, and ultimately may have slowed down adoption overall.


I found his Learn Python3 The Hard Way to be a great series of exercises if you're starting out or starting again. You won't find -everything- on any topic, but the exercises are complete enough to get you rolling and seed the sort of patterns that will make you successful in looking for more material.

I had a little bit of Python(2) under my belt from general curiosity, and I've done some C++ in high school so I have some "CS Theory"

There is a "more" python version out now https://learncodethehardway.org/more-python-book/

Amazon ( the "newer" version proposed is not, it's his python2 book ) https://www.amazon.com/Learn-More-Python-Hard-Way/dp/0134123...


If you’re a pure beginner with zero programming experience, yes. If you’ve programmed a few scripts and have done a flask web app, his first book might be too easy.


If you ignore his strong opinions, it can be good. Although he was (is?) very much hated back in the day (when Python 2 was still mainstream), many many noobs did benefitted from his book. So I'd say give it a try.


> and from reading open source code.

Do you just search for projects in the language your using on github?


Yes, and I would typically search for simple projects using keywords such as “micro”, “small”, “tiny”, or “pico”.

I would then try to re-implement the “getting started” code in the readme from scratch, like a little programming puzzle. If I can’t figure it out, I‘ll add in some debugger breakpoints, inspect the stack trace to understand how it works, then code the needed methods / classes as I go.

If you’re a ruby programmer, soveran’s work in github can be read in a day or two. I specifically like cuba (micro webframework) and mote (microtemplate).


My favourite is "Practical Common Lisp" by Peter Seibel (https://gigamonkeys.com/book/)

Not only is the book free to read (although I would suggest to pay for it if you like it!) The code to parse binary files actually "inspired" my design of an actual production application which was very flexible, succinct and, most importantly, so fast I had to spend a lot of effort convincing people the numbers are actually true.

It taught me some important lessons about how you can achieve performance with Lisp languages and the real reasons for the power of macros. Not too shabby for the first book on Lisp I red!


Peter Seibel is also the author of "Coders at Work", which is a series of interviews to prominent figures in the world of computer science and programming.


I've been learning lisp this past week. I think I get the main idea of "code is data and data is code", but I struggle to understand how it's more powerful than, say, making a function factory in Python.


I'm also learning lisp, mainly as a part of learning emacs, so I may not be super accurate here. In python, when you have a reference to a function, its a bit opaque, you can tell the thing is a function, but I don't think you can really go into the function object, and alter it lets say. You may be able to using the AST or something, but its not a "first-class" thing you can do.

In lisp (and code is data, data is code), the function is also a list, so you would be able to use all the normal programming tools to iterate over the list, add new items to the list, etc, which can change how the function runs.


This is not what "code is data" is supposed to mean. It means "source code is data": the source code of Lisp is a data structure.

You shouldn't do it in any Lisp production code. E.g. in ANSI Lisp, self-modifying code is undefined behavior. Even if you get some expected results, it may not work portably, and won't work if the code is compiled. Compiled Lisp code doesn't have a list representation any more.

Code-is-data lets us have a transformation pass on the code with application-defined rules, before it is interpreted or compiled. This is a recursive step that returns a new version of the code based on the old


Such a concept could use an example to solidify that point.

If I have a function Foo that adds two numbers together. How is that represented in lisp (as a list you say?)? How would one alter that function/lisp-list: to multiply numbers instead?


> How is that represented in lisp (as a list you say?)

I'm only a beginner in lisp too, but it as simple as

    (defun add-numbers (a b) (+ a b))
if you look at it as "everything between () is a list" then you'll find the above code is actually:

    [word word [word word] [word word word]]
to get it to multiply numbers instead, you'd just get the last item of the list `(+ a b)` -- replace the first item `+` with `*` (using other list functions, etc..) and then re-evaluate the entire list again,

So now your function will multiply values instead of adding them..

The "power" aspect comes from the fact that we use "other list functions" to change the code, ie: code is data that we can manipulate.

note, probable errors, like I said, I'm new


I've not really encountered any situations where I've needed to do anything like this yet (still learning), but, I found this example, where there's an existing function, and someone alters the body of the function to create a new function. My guess is that there's various ways of doing this type of stuff: https://stackoverflow.com/a/1220198

Edit: a macro example, which I think may be the more common route of doing this type of stuff? https://lisp-journey.gitlab.io/blog/common-lisp-macros-by-ex...


I used to have the same issue understanding the benefit. One simple example that helped it clicked for me was considering the `when` or `unless` macro.

They're just very simple macros based around the `if` special form. Because they're macros, they can just treat the body as data, i.e. it's not executed as part of argument resolution.

If you wanted to make a `when` function in Python, the "body" would have to be a callable like a lambda or named function.

I know this probably isn't the most compelling use case but I found it to be a really simple way to understand some of the benefits of macros and how they could be used elsewhere.


So let's say i have a lisp macro along the lines of

(analyze 1 2 expensiveComputation)

In python, to prevent evaluating all arguments when running analyze, I'd have to pass expensiveComputation as a callable or a function partial and remember to call it if I need it.

Whereas in lisp, I can pass whatever expensive variable I want into the macro because it will only get evaluated when using (expensiveComputation ...) and that's baked into the language.


maybe a function factory is just an OO pattern for return closures, it's difficult to not perceive things from 'now', but i'll be frank i 1) never liked DP 2) couldn't spend more than 5 minutes reading about them as it seemed more verbose and redundant


Not sure what you mean by "function factory", could you elaborate? Isn't it metaclasses and decorators that are used for metaprogramming in Python?

In my opinion the 'everything is an expression' is the really tasty part of the lisps, which goes well with quoting.


My naive interpretation of `defmacro` is passing data into a function to return another function. From my python POV that would be the same as returning a callable from a function (decorators being one example).

I think top comment does a good job explaining that while I'd get the same functional result, Python objects have tons of abstraction behind them that make them harder to work with than lisp combinations.


Macros don't (necessarily) return functions. They take a set of values and then produce an s-expression, which in turn is read by the reader and evaluated. For instance a user-created `when` macro would be something like this (not tested):

  (defmacro when (condition &body body)
    `(if ,condition
        (progn ,@body)))
That's not a new function that's been returned, just a new expression which can then be read (and macro expansion can be a repeated process as its read so you can use nested macros in macros in macros, even recursive macros but take care there).

You can use macros as you describe, in a manner similar to a Python decorator, but that's only one of many possible uses.


There is a number of reasons that make Lisp macros so much more powerful than functions in any other language.

Consider you want to implement printf that is compatible with C printf.

As the function implementor, you want something like printf("%d", 5+2, anExpensiveFunctionThatProducesAString()) do the right thing and print "7" on the terminal, but you get many more options and mechanisms you can use when implementing it in Lisp vs other languages.

Every other language:

* every time printf is called, all of the arguments have already been evaluated. There is no way to avoid calling the expensive function when the format indicates the result is not needed.

* every time the function runs you have to parse the format string. You could try and be smart and cache parsing results but this will quickly make it very expensive and complex and might cause problems when format strings are generated dynamically.

* your function cannot make use of the fact that both the format string and the argument never change

Lisp macro:

* you can decide to only evaluate arguments when they are needed,

* you can notice that the format string is static and output code IN PLACE of the macro based on this information. This means you have the option to make parsing happen only at compile time if it is possible.

* you can analyse the arguments further and decide to output code that does princ('7') IN PLACE of the macro. The resulting code will have no operations to parse or analyse anything and will always execute quickly and efficiently.

In general this is the way I think about Lisp macros vs functions in other languages:

"Lisp macros allow you to run logic at compile time that can create code dynamically that does exactly what you need it to do, no more, no less, based on macro arguments and/or unevaluated macro arguments and/or the environment."

Lisp macros are ultimate in building abstractions. Where in other languages you have to contend with the language always "sticking out" of your abstractions -- there is only so much you can do to hide the underlying language, in Common Lisp you can always hide the language completely. Implementing your abstraction is taking a data structure (can be for example an XML file) and running an arbitrary logic to generate another data structure (a function) that is then outputted in place of the macro. If the XML describes your binary file structure, the macro can take those descriptions and generate perfect parsing code that does exactly what is needed without any extra stack frames, conditionals, syntax artifacts, etc.


I was going to suggest this. It's cool that you build a file based database (IIRC) and query language in the third chapter!


Also with so little actual code. This cemented my interest for Common Lisp at the time I was reading it.


Not a book, but check [Build your own X](https://github.com/codecrafters-io/build-your-own-x), a compilation of well-written, step-by-step guides for re-creating our favorite technologies from scratch.


Excellent resource. Never seen that before.

In a similar vein, there is The Architecture of Open Source Applications which is great:

https://aosabook.org/en/index.html


It was better when Daniel maintained it.


Can't believe he sold out..


What happened?


"Hands on Rust" teaches Rust by building a rogue like game step by step. Before that there's a chapter where you rebuild Flappy Bird from scratch that teaches the "basics" before diving into more advanced concepts in the rogue like. I liked the approach and recommend the book but it's fast paced and expects quite a bit from the reader (it's excellent if you have some programming experience already but probably daunting as a true first book imo).


I second this one. This was a great book.

There are some follow ups to the final project I like

Compile to WASM so you can run on the web: <https://hands-on-rust.com/2021/11/06/run-your-rust-games-in-...>

Port to the Bevy ECS: <https://saveriomiroddi.github.io/learn_bevy_ecs_by_ripping_o...>


Oh cool I wasn't aware of these. Thanks for sharing, both look very interesting. I like the idea of reusing projects to teach different tech :)


Not a book but The Coding Train on Youtube is probably one of the best introduction to programming. It's fun to watch, Daniel Shiffman is a fantastic teacher and he doesn't take himself too seriously.

But what sets this course apart from any other are the coding challenges. Following the thought process of a programmer in real time, watching him making mistakes and hunting for bugs is invaluable.

He uses p5js, a javascript library for graphics. The lessons are geared towards generative art but cover a broad range of topics including machine learning.

https://www.youtube.com/@TheCodingTrain


Coding Train is soooo good, it is like if Bob Ross had a baby with Donald Knuth.


For Swift:

https://www.apple.com/swift/playgrounds/ (I've had more success introducing programming with this than with any of the links below; it's a very compelling intro for those who already own an iPad/Mac, and the core concepts are generalisable to other languages/environments even if it's specific to Apple's APIs and hardware.)

~~~

For Python:

https://automatetheboringstuff.com

https://nostarch.com/big-book-small-python-projects

~~~

For JS:

https://eloquentjavascript.net (project-based and for beginners)

https://javascript30.com (not for total beginners or self-study, would need a friend/tutor)


I beg to differ: for all its qualities, Eloquent JavaScript is not a very beginner-friendly book. It goes quite deep into many JS intricaties and contains a lot of challenging tasks for people just discovering programming.

More beginner-focused alternatives are https://www.freecodecamp.org and https://thejsway.net.

Disclaimer: I've been teaching programming professionally for 15+ years and wrote the latter.


I have recommended to beginners before and most of them thanked me. I skimmed the page for your book but did not see the link to the free version. I am on mobile so maybe just missed it. Says read free here, but here is not a link. Clicking the book takes you to Amazon.


Never-mind the website is the book lol


I second eloquent JavaScript. Been doing this book since v1 and recommend to just about anyone that asks for recommendations. I use typescript daily and have been hoping that this book gets updated for TS although it would be hard since it uses lots of JS tricks that may or may not be best practices in TS. Technically just renaming the files from .js to .TS would work the linter would go crazy


My biggest gripe with all the project tutorials I’ve seen is that really quickly you get into a “ok I get what we’re doing” and then just copy the code they provide. At the end of the day you did zero mental workout because you didn’t have to figure out the code. I hope to find one of these that guides you but doesn’t give you the code immediately, but has a code answer key at the end or something. I get it that it’s not easy to do, but there must be one out there that doesn’t spoon-feed you everything.


One thing that helps me a lot when learning new languages is to NOT copy and paste but actually re-type the code.

You will be forced to read more carefully and, more importantly, you will make typing mistakes. Hunting down your own mistake will teach you the subtleties of the syntax as well as further increase your understanding of the code.

For more advanced programmers, there is also the challenge of translating the code into another language entirely, which requires a actual semantic understanding of the code.

Also once the project is done, adding small additional bonus features will further deepen your understanding.


i once sent an online book author a bug report that the font used in the code samples contained ligatures, so i couldn't just copy and paste them in. he replied that it was a feature :)


I re type it but I don’t necessarily learn how to come up with that code when I’m off the leash. It’s useful when learning new syntax for sure though.


It’s a stepping stone. Doing that will make you a little bit less uncomforable when you get out of your depth, that until you hit another stepping stone and feel even more comforable.


You can try to retype it from memory too. Or write down a list of the crux functions (like a word bank) and then figure it out again.


That’s why I like The Ray Tracer Challenge. He gives you test scenarios and a little bit of pseudo code (sometimes). The actual implementation has to be done by the reader.

http://raytracerchallenge.com/


+1 This is one of my favorite programming books. It's a very rewarding-feeling experience to build something so capable so quickly.


That's really cool, probably deserves its own submission for discussion!


To force myself “to figure out the code,” I typically do the tutorial in a different language. I wanted to get familiar with Java last year, but all the books/tutorials were boring to me. What I ended up doing was going through a book that showed how to write a backend in Go (which was also unfamiliar to me at the time) while simultaneously porting it to Java (using Vert.x). Probably sounds inefficient tackling two languages at once, but it was the only way I was able to stay engaged with the material. Of course I ended up with something unidiomatic in terms of Java, but the project works and I now have motivation for a proper refactor to keep the momentum going.


I have done the same thing! Read Crafting Interpreters but wrote the first half in Clojure instead of Java.

I think it's a good method for experienced programmers, who are self-taught (like me) or just want to brush up some skills and knowledge.

Yes, you stay engaged, but there is also something to be said about porting code between different languages. The differences, strengths, weaknesses etc. stand out more, similarities become more clear and things that seem different, but are analogous emerge.


I was looking for golang in this thread and this is the only reference I found. Would you mind linking the Go book you reference? Thanks


Sure thing:

https://lets-go-further.alexedwards.net

That book is a follow-up to an easier book [1] that I also bought, but ended up skipping since I was only interested in writing JSON APIs.

[1] https://lets-go.alexedwards.net


Thanks!


For this reason you need to find _your own_ projects, solve your own problems (which are actually pretty common, but you have to search or figure out a solution)

That's what I tell everyone


The issue I’ve found with that in my students is they then have to play the role of product manager in addition to software engineer. Those choices add a lot of mental overhead. There’s a balance between motivation and pressure for most students.

I think cloning is more the way to go. Pick some existing project/product and copy the essential components. Less choices, doesn’t have to end up getting used.


Tips that have helped me:

1. Typing out the code.

2. Going off route. Change things. Personalize examples. Break things and fix them.

3. Look up the docs for the language/framework/library and see how you can extend the project after each chapter.


Thinking of building something along those lines i.e. you can peek ahead if you really get stuck.

Proj-based learning is really fun to both create and consume imo.


If it helps you in any way, what I try to do is to use a tutorial book to build my own app. For example a Flask tutorial that shows how to build a blog app, but I’m building a library. I still learn about the Flask way and I learn some building blocks but I have to figure out the equivalent for what I want to do. I often get stuck though.

So maybe showing the building blocks and letting you use them for something. You could perhaps show 2 or 3 suggested projects that are built with the building blocks. You show the generic version of the blocks, and then you figure out how to tweak them to make one of the 2 or 3 suggested projects.

Sort of buying the legos and then showing what you could do with them. But building it is up to you.


Good idea, originally I would just build something that already exists from scratch e.g. a UNIX-like OS complete with 99 footguns.

Now I've learned better I try to channel my learning energies into extending my portable, reusable library that solves common problems I can iterate, improve and port into future projects.


Datacamp does what you want


There is this excellent Github repo for this: https://github.com/codecrafters-io/build-your-own-x

It has a collection of blogs for building various small projects to learn different languages.



Software Foundations is a series of interactive books where you work through proofs in Coq, gradually increasing in complexity: https://softwarefoundations.cis.upenn.edu/

This is a bit on the edge of the domain that you're asking about (not really for beginners, and proofs are perhaps a somewhat niche type of programming) but I learned a lot from this and many people don't seem to know it, so I think it belongs in the list.


HTDPv2 https://htdp.org/ - it's about learning to program rather than teaching a specific language.

I thought the little projects you build along the way struck a good balance of interest, e.g. you're building a snake game by section 2 (but crucially you've already been exposed to how to think about data so you're not just dropped into the deep end with some boilerplate to fiddle with).

Anyway, i could write tons of praise for this book but it's convinced me to ditch python for teaching newbies and i LOVED python for getting newbies started real quick with projects for years.


That sound like an interesting approach and I'd love to hear more about it!

One striking difference compared to most "beginner languages" is the Lisp-like syntax. I think focusing on problem solving rather than learning syntax is a great goal, but does this particular choice of a language make it harder for your "students" to continue learning in another language?

I'm assuming they would switch to a more popular language at some point (with syntax that resembles C), so I'm curious what that transition is like for beginners.


Interesting, I rarely see it mentioned. How do people react to the mindset it teaches ? I really like that it's near language-less programming book, really more about and/or :)


I wouldn't mind if you write some more about the book.


Shameless plug if allowed: “The Road to React” goes through one large project to teach React.js from beginner to intermediate. I learned that going through one project it allows the teacher to go through a series of foundational aspects of the topic before implementing more advanced domain specific features which make use of the earlier learned building blocks for the real world project. Does it make sense?

https://www.amazon.com/Road-learn-React-pragmatic-React-js/d...



This book is still in progress but I've gone through some of the chapters and have enjoyed it. Rust from the Ground Up: https://leanpub.com/rust-from-the-ground-up

I was looking for a book that had offline projects I can work on while on flights, and this book focuses on rebuilding linux utilities using rust. The other nice part is that you get a better understanding of linux internals.

I believe the author is also responsive on the rust subreddit.


Thanks for the kind words! I'm desperately polishing the next chapter for publication...


great to see you on HN as well! I haven't revisited the book in a while but I really liked the chapters I did work on. I have another flight coming up soon so maybe I'll try another chapter :)


For beginners, Daniel Holden's Build Your Own Lisp[1] is excellent material for learning C. It's a very succinct book.

For intermediate programmers, Build Your Own Redis[2] is a WIP book I am currently writing.

[1] https://buildyourownlisp.com/

[2] https://build-your-own.org/


Build your own redis sounds like a good idea, but I found the title confusing as C and C++ are different languages and you're using the old "C/C++" phrasing. I immediately wondered, "well, which is it?"

So I dug into it a bit, and from the introduction I see it's "mostly C with some C++ features". But if you're going to require C++ features/libraries and a C++ compiler, then it's not C. So why not just say it's C++? I guess another way to ask is: what makes it "mostly C"? Is it a market capture decision? Is there some interesting language tradeoff involved?


Not a book and webdev focused, but I've been doing https://fullstackopen.com/en/ and it's been great.

The chapters are structured so you are building 2 projects at once. One where you follow along with the chapter material with example code and explanations. And a second in the exercises.

I really like it because it introduces the concepts in the context of a project, but you can't get stuck because the code is there too. Then you need to really apply it in the exercises on your own project, without the example code.


Its a great resource, but not for total beginners, however if you know basics of html, css and javascript this is hands-down one of the best resources out there.


I mentioned The Ray Tracer Challenge in a comment below, and it seems quite popular so I’ll submit it here as well.

http://raytracerchallenge.com/

It’s not really for beginners though, but maybe possible to start it together with a beginners book in a language of choice. It starts with points, vectors and matrixes, but gets more advanced later on. It’s around 250 pages and there’s basically no code provided, just test scenarios and a bit of pseudo code.


This is my favorite programming book. It provides the test cases for the whole ray tracer, and making them pass was really addictive. I was obsessed with it for the month or so it took to finish.

He's also written another book on mazes, but I haven't had the chance to read it. I wish there were a similar book on 2D graphics, which are plenty complex themselves.



MUD Game Programming. Not sure how easy obtaining a copy would be in 2023 but it has two projects which I recall being a lot of fun. I never did build a successful MUD but did learn a fair amount about network programming.

https://www.goodreads.com/en/book/show/927128.Mud_Game_Progr...


I build MUDs whenever I learn a new language! Didn't know there was a BOOK for it! Wow. Very cool!


No joke, "C for Dummies" - it's more teaching you CS101 concepts, less about "C". Tons of examples to go through and the attitude of the author is very helpful compared to a lot of other styles out there.

I was failing my computer science classes first semester. Towards the end of the semester I sat down in the library for a few days and just went page by page typing every example and compiling it. Aced every IT class I had the next few years. I attribute that book to making everything "click" for me.

Once you understand the beginner concepts that book shows, then you as an individual would know where to look to gain improvement.


Common Lisp: A Gentle Introduction to Symbolic Computation(https://www.cs.cmu.edu/~dst/LispBook/) has you build a number of small applications, like a substitution decipher application, a plotting function, and more, which it calls "keyboard exercises".


Peter norvig’s paradigms of artificial intelligence programming, despite its age, is a delight.

https://norvig.github.io/paip-lisp/#/


But is that suitable for a beginner?


It depends on what you mean by beginner, but I would say for someone who has been futzing with a couple of js boot camps or building some php websites, it’s what takes you from hacking to software development. Completely new to programming, maybe, if someone has a background in maths or physics and has a sense of “rigor” in thinking.

But, of all the books I worked through, this is the one I remember just having tons of fun because the examples are so cool and the code so… clear. I think norvigs programming course in python (which I only skimmed) could be a great modern equivalent.


Yes, it is. It’s not about machine learning, neural networks but the more approachable AI of the 80s.


Haven't tried his, but can GPT3 write code that results in 1980s style AI?


Why not go ask it?


I don't know why jtimiclat's comment recommending Al Sweigart's books got downvoted and faded out, they are indeed quite good for beginners wanting to get their hands dirty with programming instead of cramming it in an academic way.

Not to mention they're all freely available and give excellent value for both time and money: https://inventwithpython.com/


http://landoflisp.com/

Was a really fun read.


A similar great book is Realm of Racket.


Sort of like that, I've been slowly working on a rosetta code for implementations of small problems. Rosettacode.org allows you to use standard library functions so many (but not all) of their examples are useless when you actually want to see how to code something from hand in the language.

So my rosetta code only allows you to implement the main part of the thing yourself. But it's not appropriate for beginners. It's more appropriate for teaching a new language to someone who is already an intermediate programmer.

https://tinyprograms.org/


God, I hope you just found Rosetta.code off limits. That's a fantastic name


For intermediate programmer, that's what we do in the Classic Computer Science Problems series (https://classicproblems.com). We combine learning programming with learning computer science problem solving techniques.


My Cloud Resume Challenge project [0] and book [1] uses a set of small, stackable mini-projects to introduce beginners to many of the pragmatic skills used in cloud software engineering.

[0] https://cloudresumechallenge.dev/docs/the-challenge/ [1] https://cloudresumechallenge.dev/book/


Per Brinch Handsen, Programming a Personal Computer. Book is online. Interpreter, editor and OS in about 10 KLOC. http://pascal.hansotten.com/per-brinch-hansen/ Also https://news.ycombinator.com/item?id=24913959


If we're talking a complete beginner with maybe only "hello world" level skills I recommend the Lego BOOST set: https://www.lego.com/en-fi/product/boost-creative-toolbox-17...

It teaches you step by step the basics of programming (loops, function calls etc) using a scratch-like programming language.


Any alternative to this? I think lego stopped making it.


the Mindstorms Robot Inventor is a bit more advanced (Scratch-like vs Scratch Jr on the Boost) and twice as expensive: https://www.lego.com/en-us/product/robot-inventor-51515


Shameless plug:

FREE https://leanpub.com/rubyisforfun - Ruby Is For Fun, I made the book so you do a lot of exercise. There is around 80 exercises in total.

Rewritten as a course:

https://www.educative.io/courses/handbook-ruby-developers


The famous Structure and Interpretation of Computer Programs (SICP) does this, in the Scheme language. The whole book is online here, with the table of contents right at the front:

https://web.mit.edu/6.001/6.037/sicp.pdf


There’s a JS edition too


And a 'comparison' edition

https://sicp.sourceacademy.org/



I found Al Sweigart's books nice for beginners.

Highlights https://automatetheboringstuff.com https://inventwithpython.com/bigbookpython


Python Programming for the Absolute Beginner (https://smile.amazon.com/Python-Programming-Absolute-Beginne...) has you make a game at the end of every chapter with the concepts you've learned so far. I've bought this book for a number of people, though perhaps Automate the Boring Stuff with Python: Practical Programming for Total Beginners (https://smile.amazon.com/gp/product/1593275994/) is better if you don't want to make games.


Codecademy has projects page: https://www.codecademy.com/projects


The 'Arduino Projects Book' does a brilliant job if taking someone who knowing nothing about coding or electronics and setting out lessons and projects that take you from zero to somewhere fun.

I still can't really code, but I can have a lot of fun tinkering because of that book.


The New Turing Omnibus is a nice collection of small domain problems that can be solved with computation.

https://oke.cx/mseih

In the domain of theoretical physics, I highly recommend, "From Newton to Mandlebrot".


> It is common knowledge that when first learning programming, one should start with small projects to build something real rather than learning rules and syntax of the language only.

I would start by examining that assumption: it varies from one person to the next. If you like the project approach then great, go for it, but for other people it can be better to exercise individual features of the language in isolation until they are well understood, rather than trying to put a lot of half-understood features together into a more complex program. I have gotten into trouble over this myself a few times, and now definitely prefer the piecewise approach to the project approach.


I would suggest Practical Common Lisp

https://gigamonkeys.com/book/

You will create a MP3 database, a web server, a spam filter, a HTML generator. Really practical!


check this

https://news.ycombinator.com/item?id=22299180 Ask HN: What are some books where the reader learns by building projects?


I like “The Elements of Computing Systems: Building a Modern Computer from First Principles”.

You build a whole computer from scratch through small projects.

Sure, you want learn a specific language, but you’ll grock programming in general.


I highly recommend this, it made the whole topic of "how does a computer actually work" approachable for me. On their website there's a projects section where they highlight things their students did and there's a project that re-creates the built computer in an FPGA (I belive some ice40) I also recommend this as a follow up.


https://beautifulracket.com/ by Matthew Butterick - “An Introduction to Language-Oriented Programming Using Racket”


I recommend the Deitel[0] series for Python and C family languages like Java, C# etc. With hundreds of complete examples to follow (not code snippets) and exercises to challenge you, you will do better with these books as a beginner.

My strategy is to get to the 10th chapter of the book skipping the exercises, then go back and try them with a better overall understanding of the language and its nuances.

Great series.

[0] https://deitel.com/


This one is nothing short of brilliant:

https://www.manning.com/books/haskell-in-depth


"Software Tools" by Kernighan & Plauger, perhaps.

The original was in Ratfor, which is a Fortran dialect. That being similar syntax but more limited than C is not a bad intro language.


There's a later edition Software Tools in Pascal which had some improvements. (According to the preface iirc. I didn't read that one since I found the earlier book first.)


Not a book, but CS50x is a freely available course with high quality videos and lecture notes. The lecture exercises are programming projects of sorts. It teaches programming from scratch with C and then Python. Plus, since a lot of students take it, there are lots of online resources with tips, like the CS50 subreddit.

https://cs50.harvard.edu/x/2023/


CS50x and CS50web are fantastic. web is a bit outdated but it doesn't matter because the projects are so good.


Learning Rust, I use these 2: 1. Command-Line Rust: A Project-Based Primer for Writing Rust CLIs 2. Zero To Production In Rust (it's actually one project)


I can recommend "Programming: Principles and Practice Using C++", although the fact that it uses C++ as a first language can be a downside to some.


- Pick a language

- Find a recent book (< 2 yrs old) on LibGen.is

- OR, a Udemy.com video series (note: never pay more than $12 or so-- the promo rate. If you see a higher price, just create a new email & user account (or reset cookies?) and you'll see the promo price again)

- Visit: Roadmap.sh to get a sense of a learning roadmap what knowledge to build.

- Use a search engine to answer questions, such as "free learning resource for learning <XYZ thing>"


It's not quite the same as what you are looking for, but I've known multiple people who were stuck in their attemp to learn to code before using railstutorial, I view it and the book "sql: visual quickstart guide" as two very well designed intros that manage to avoid having sections with random jumps in difficulty and terminology usage that can leave true beginners behind.


Parenthesis: keep in mind that while learning by doing might be a good way to begin, even if I wouldn't be so sure as wether one "should" or "could" start along such a path, at some point you'll be stuck without studying the "boring" stuff you've delayed. True programming is realising the boring stuff weren't so boring in the first place


This is the best programming book I have ever picked https://www.amazon.com/-/es/Noam-Nisan/dp/0262539802/ref=sr_...


I'm very much a fan of a project-based approach. However, I wouldn't recommend any book for that. I'd ask the apprentice what they'd like to achieve, and try to reduce scope as much as possible.

There's a world of difference in motivation when building something you want to exist, versus building a project because a book told you so.


Check out my blog series, "Challenging projects every programmer should try". Who knows, maybe I will turn it into a book that shows how to implement each project :)

https://austinhenley.com/blog/challengingprojects.html


I like your list. Maybe you could break the projects down into smaller subproblems (you sort of do that already) but I personally don't like seeing the implementation. It gives you a false sense of understanding imo.


Hi! I would like to shamelessly plug my own book "Practical Python Projects". It follows project based approach. It is completely free to read online and has a paid EBook option if that is what you prefer.

https://practicalpython.yasoob.me/


How to Design Programs: https://htdp.org/2022-8-7/Book/index.html

It's lots of small problems that seem like projects and I've found it fun to expand on the examples on your own beyond what the book asks.


I failed to learn for the past 10 years and I am complicit. But partially as a self-taught, you have no clue which resources are good and which are not.

Recently all mainstream "learn to code" sources realised just making you memorise concepts doesn't work and started changing curriculum, but before that happens...

The best 2 resources I found are: - https://learnprogramming.online/ - https://scrimba.com

Both are project driven and won't hand-hold you if you want to continue, you need to proceed based on a mastery learning method.



When I was young, I went about it the opposite way. I thought of some small project and researched how to implement it, then moved on to something bigger. Everybody is different of course, but I felt like I learned more having to figure out how to go about implementing each myself.


It's common approach because building something that you want is good motivation.

I don't think that works as well when it is some random project from the book. Like, sure, better than dry code, but I'm far more motivated to learn when I also make something for me.


The challenge I, and I think many others, run into with this is that there's almost never anything I "want". I spend so much time racking my brain for what to build I never start.

Having a nice curated problem put in front of me sets me off and it's easy from there.


I agree in regards to complete beginners.

But I think for more intermediate or advanced programmers it is very beneficial to go about a project in a more self-driven, free form way. Software design, exploration, research, reading specs and so on are half of the work (or more) in programming.

What I would have loved to realize when I was younger is that there's nothing you can't write. It might be a drastically simplified version compared of the real thing, but you can absolutely do it.

An operating system, a browser, a web server ("from scratch") a programming language, a video game (with a custom engine)... It's all possible with enough effort. And even if you don't want to do the up-front work yourself, it is easier to find cool, guided projects out there if you already know what you want.


Not quite a beginner book, but you should check out https://www.amazon.com/Mazes-Programmers-Twisty-Little-Passa....


The Symfony Fast Track book takes this approach: https://symfony.com/doc/6.2/the-fast-track/en/index.html


Thought the question was regarding specific books that teach programming via small projects it's worth mentioning a related topic here.

A Common Sense Guide to Data Structures and Algorithms by Jay Wengrow * 2nd Edition * not only covers the theory really well but goes on to provide code examples in popular high level languages explaining when and how best to use them usefully. At the end of each section are prompts where you extend the lesson into a small project and each chapter builds on the last. The author has a github repo so you can compare your project solution to his. It made a rather dry topic extremely fun and approachable.


Most udemy/MOOC courses are structured this way. I tend to just look for the highest rated ones on whatever language I'm interested in and make sure it says build projects or something similar.


Write yourself a scheme in 48 hours by Johnothan Tang is a fantastic book, there's also the structure and interpretation of computer programs.

https://upload.wikimedia.org/wikipedia/commons/a/aa/Write_Yo...

https://web.mit.edu/6.001/6.037/sicp.pdf


I recently finished the book that teaches programming by developing games using DragonRubyGameToolkit. Really loved this book.

_____

Python Crash Course by Eric Matthes has a section dedicated to projects.

I really liked this book.

This is what taught me Python.

I knew C before.


>> one should start with small projects to build something real rather than learning rules and syntax of the language only.

Yes, but don't overlook the great learning that is gained, at the beginning of any learning, by studying from many different sources (aka good books). It seems that something magical happens when you do this: the confrontation of ideas from different sources can make you better absorb ideas and resolve any doubts that you didn't understand before.


The Advanced Beginner blog post series by Robert Heaton is great.



In the same vein I can also suggest ; https://hackattic.com

and http://newcoder.io Both take the student through the process of building one fully-functional application.


https://eloquentjavascript.net/ is nice and project based, it builds up from 0


https://shop.jcoglan.com/building-git/

This is an excellent resource.


While on the topic, how about any books or courses that teach building a 3D game engine from scratch? I'm language agnostic, so any language is fine.


I think pikuma.com has a course about implementing a 3D rasterizer from scratch in C.


The best!!!


If they don't exist, this is a good idea for anybody looking for a project to write a programming book


There are many, but the field is still wide open. Anyone with a particular domain experience should find a market.

There are lots of starting from scratch guides, and few focused guides.

for subject in ["Finance", "Contact Management", "Service Desk Automation", "Web Apps from scratch", "Web Apps on someone else's API", "Baseball Metrics"]: for language in ["R", "Go", "Python3", "Rust", "Lisp"]: print(f"Examples for {subject} in {language} would make a good book.")

edit: no idea how to smash indent-formatting into MD-for-HN


Prefix each line with two spaces, per the formatdoc page [0]

[0] https://news.ycombinator.com/formatdoc

  for subject in [
   "Finance",
   "Contact Management",
   "Service Desk Automation",
   "Web Apps from scratch",
   "Web Apps on someone else's API",
   "Baseball Metrics"
  ] : for language in [
   "R",
   "Go",
   "Python3",
   "Rust",
   "Lisp"
  ] : print(f"Examples for {subject} in {language} would make a good book.")


Thanks!


Not quite programming but certainly covers the "small projects" part. This is what taught me the basics of Unreal Engine: https://www.youtube.com/watch?v=k-zMkzmduqI


I have done courses on udemy like this before for learning new languages and tech stacks. There are plenty of courses on there that you can usually get for $20 that will teach you by building a bunch of small apps or services that build up in complexity.


This was just released, I haven't picked it up yet but it's definitely on my wish list

https://www.manning.com/books/tiny-c-projects


Learn Swift in 100 days. It start with the basics using Swift Playgrounds. But as soon as possible, it starts with building apps.

https://www.hackingwithswift.com/100


Came to say the same thing - plus, there's a great 100 Days of SwiftUI as well, which gets nontrivial apps running pretty quickly.


Same question, but not for beginners but for experienced programmers:

Which book would you recommend to improve architectural design decisions, developing complex systems, etc? But on actual examples, e.g. by building a series of projects, or parts of it?


Manning.com also has LiveProjects which are good for Machine Learning projects



Pretty much all of the books at newline do this: https://www.newline.co/


Actually, Advent of Code is pretty good. The problems are challenging but you have a defined end condition and lots of help out on the internet.


C Programming: A Modern Approach by K. N. King. I’ve never seen another book that contains as many exercises and projects as Kings book does.


Practical Common Lisp by Peter Seibel


The Rust Programming Language by Steve Klabnik and Carol Nichols. I don’t think it’s a language for beginners though.


I'd love suggestions for PHP.



Automate the boring stuff with Python


I'd like the equivalent for electronics if anyone has any suggestions.


“Programming BASIC Adventure Games for the TRS-80”

“Assembly Language, Step by Step”

Check those out.


All Swift by Sundell series are pretty good.


checkio.com for increasing challenges in Python or JS.

But also pretty much every book does that.


raytracing weekend


ChatGPT is probably much better at doing that for you. You can start with anything you want and explore as deep as you want.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: