It makes a bad first impression.
The cover being so bland is actually a marketing problem on Amazon, because
it's spammed with 'programmer notebooks' that have similar covers. One of the
more obvious examples:
<https://www.amazon.com/Notebook-developers-based-popular-IDE/dp/B09RFY5HQY/>
Then, right on the first line of chapter 1, 'In this chapter we'll cover all
this stuff about the core language', and then Chapter 2 is on the next page
after none of that stuff has been covered. I imagine this was a late
reorganization, and a minor errata point of: "this chapter" should read "Part
I". What it initially looks like is that the book's missing the rest of the
chapter, which is helped by the blank page on the reverse side of the Chapter 1
page.
Then, still on the first page: `nimble install pixels` fails with `Error no
package found.`
Well, OK, the book also says that pixels is shipped with my Nim installation,
and I have the latest version of 1.6.6. But that's false: `Error: cannot open
file: pixels`
I then notice that nimble.directory _does_ have pixels. I try again with
--verbose:
Trying http://google.com
Trying http://google.com/404
Trying http://irclogs.nim-lang.org/packages.json
Trying http://nim-lang.org/nimble/packages.json
Run
That last file doesn't have pixels, and those first two URLs look pretty weird.
I'm troubleshooting Nim instead of using it _on the first page of a Nim book._
I try on a second machine:
$ nimble install pixels
Prompt: pixels not found in any local packages.json, check internet for
updated packages? [y/N]
Answer: y
Downloading Official package list
Success Package list downloaded.
Tip: 3 messages have been suppressed, use --verbose to show them.
Error: Package not found.
$ nimble install pixels --verbose
Reading official package list
Downloading https://github.com/Araq/pixels using git
Verifying dependencies for [email protected]
...
Run
That's two attempts, right after each other, with my doing nothing else in the
interim.
The first machine (homebrew-installed Nim on macOS) consistently fails. I can
no longer persuade the second machine (system-installed Nim on linux) to fail.
Solution for the first machine: `nimble install https://github.com/Araq/pixels`
After the first page, it comes off a lot better. Superficially, the attractive
red/blue coloring makes for a better impression. On the content, I think the
coverage is slightly confusing (why doesn't it mention `defer`? Is that on the
chopping block? Communicating between threads is out of scope? The book started
out talking about Nim's memory model, I thought it'd stay on that level of
detail), but reading it over the course of the day I noticed some subtle stuff
that I hadn't known before.
The copy on write section is confusing, because it's not true in --mm:refc, and
because moveMem doesn't create any problems in --mm:orc. From the prose it's
clear what the point of `prepareMutation` is, but I couldn't tell from the
example that it was really doing anything, as removing it doesn't break
anything.
var x = "abc"
var y = x
echo (cast[int](x[0].addr), cast[int](y[0].addr))
#prepareMutation(x)
echo (cast[int](x[0].addr), cast[int](y[0].addr))
x[0] = 'x'
echo (cast[int](x[0].addr), cast[int](y[0].addr))
assert y == "abc"
assert x == "xbc"
Run
With that you can see address changes, but slight variations on this code get
weird, fast, which is also why the code is so repetitive.
I appreciate having the physical book, as it's an excuse to not do _absolutely
everything_ at the computer, but I think it leaves tons of room still for
potential Nim books:
1. "do some interesting thing in Nim" (like all those Python and Go books)
2. "Nim Cookbook"
3. "100 Nim Mistakes and How to Avoid Them" (like
<https://github.com/teivah/100-go-mistakes> , it's a great format for a purpose
that's closer to a style guide or a Best Practices book)
4. "Nim Compiler Internals"