Live data from Hacker News

Ask HN: Books that teach programming by building a series of small projects?

news.ycombinator.com

181–190 of 204 posts

Re: Ask HN: Books that teach programming by building a series of small projects?

#181

Earlier quoted context omitted.

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 co…

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

Re: Ask HN: Books that teach programming by building a series of small projects?

#182

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 tru…

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.

Re: Ask HN: Books that teach programming by building a series of small projects?

#184

Earlier quoted context omitted.

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?

Re: Ask HN: Books that teach programming by building a series of small projects?

#185
post #19

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

Link: https://robertheaton.com/2018/12/08/programming-projects-for...

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.

Re: Ask HN: Books that teach programming by building a series of small projects?

#186

Earlier quoted context omitted.

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.

Re: Ask HN: Books that teach programming by building a series of small projects?

#187

Earlier quoted context omitted.

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 o…

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

Re: Ask HN: Books that teach programming by building a series of small projects?

#188
post #125

Earlier quoted context omitted.

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.

Re: Ask HN: Books that teach programming by building a series of small projects?

#189

Earlier quoted context omitted.

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 co…

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

Re: Ask HN: Books that teach programming by building a series of small projects?

#190

Earlier quoted context omitted.

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 o…

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.
Post reply on HN