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…
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?
Ask HN: Books that teach programming by building a series of small projects?
131–140 of 204 posts
Re: Ask HN: Books that teach programming by building a series of small projects?
#132Earlier 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…
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?
Re: Ask HN: Books that teach programming by building a series of small projects?
#133Earlier quoted context omitted.
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 th…
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.
Re: Ask HN: Books that teach programming by building a series of small projects?
#134My 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…
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.
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.
Re: Ask HN: Books that teach programming by building a series of small projects?
#135There’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…
Is Shaw's first Python book any good?
Re: Ask HN: Books that teach programming by building a series of small projects?
#136Earlier 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?
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...
Re: Ask HN: Books that teach programming by building a series of small projects?
#137"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.
Re: Ask HN: Books that teach programming by building a series of small projects?
#138“Assembly Language, Step by Step”
Check those out.
Re: Ask HN: Books that teach programming by building a series of small projects?
#139I 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.
Re: Ask HN: Books that teach programming by building a series of small projects?
#140Learn 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