seadynamic8 (10) [Avatar] Offline
#1
Here is a list of suggestions of some fixes: (I'm not sure about all of them)

p.138 & p.171 - Suggestion: Use String.strip/1 instead of String.replace/2
p.146 - At bottom, the word Look is misspelled as "Looka" - (Sect 4.1.2)
p.151 - iex(7) - the right hand side should have %{a: 1, b: 2} , Notice the `%` sign missing from the map.
p.160 - Suggestion: Use HashDict.put_new instead of HashDict.put, to enforce it
being a new value. But the fact there is an `id` field should make it unique anyways.
p.167 - The "id" in "put_in" is wrong, it should be "3", to change the "Movies" to "Theater".
p.174 - integer_to_binary is now Integer.to_string (Code & Text)
p.198-200 - Need to use :random.seed, to seed the random generator, :random.uniform. Using
:random.seed(:erlang.now) would be the easiest.
p.205 - I think the value/2 function should be value/1 instead.
p.216-218 - iex : no longer prints internal BEAM info on startup. Anyone know
how to find this info another way? You can still set options to --erl flag,
using double quotes instead of single.
p.239 - Sect 6.1.12 - It should refer to figure 6.3, instead of figure 6.4
p.245 - TodoServer needs to renamed to Todo.Server
p.250 - GenServer (in code Line 5), shouldn't have a colon in front of it.
p.265 - (End of summary) - Missing an "s" at the end of the word "prcoesse" .
p.298 - "Sometimes", I think it should be "Sometime", without the "s" at the end.
p.304 - "error will be raise during", raise should be "raised"
p.306 - "Since database worker is not a process anymore", should be "database server"
p.312 - "make the to-do server resigters itself", should be "register"
sjuric (86) [Avatar] Offline
#2
Re: Some errata that I think could be fixed
Thank you very much for this! I'll check them and fix what's needed.

> p.216-218 - iex : no longer prints internal BEAM info
> on startup. Anyone know
> how to find this info another way?

What do you mean by this? For example, this is what I get on my dev machine:

$ iex

Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
seadynamic8 (10) [Avatar] Offline
#3
Re: Some errata that I think could be fixed
When I type iex, this is what I get:

>iex
Interactive Elixir (1.0.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>

I'm on a Windows 8.1 machine. I don't know if that makes any difference. I know on Windows a lot of the things in iex don't work as they do on Linux/Mac, like some of the commands just don't work.

So maybe that is it?
sjuric (86) [Avatar] Offline
#4
Re: Some errata that I think could be fixed
Yeah, it appears that on Windows even erl shell doesn't print this info.

You could use :erlang.system_info/1 (http://www.erlang.org/doc/man/erlang.html#system_info-1) to retrieve various settings.

For example, you might want to retrieve following:

:erlang.system_info(:schedulers)
:erlang.system_info(:thread_pool_size)

As far as I know, kernel poll will not work on Windows.
seadynamic8 (10) [Avatar] Offline
#5
Re: Some errata that I think could be fixed
Yea, I found the :erlang.system_info as well, but is annoying to having to find individual items like that.
Yep, kernel poll doesn't work on my system.

Here's another list of fixes, or just maybe observations:

p.333-334 - It should be "use Genserver", instead of "use GenServer.Behaviour"
- Use "Genserver.call" instead of ":gen_server.call"
- You updated this in the code examples, but not in the book.
Question: Does the fact that the genserver and the ets table use the same alias
conflict at all? Also, is this confusing or actually supposed to be the idomatic
way of doing things, since they are kind of the same thing in the larger context.
p.351-352 - When I use the --no-start option, it also doesn't start the logger.
I have to manually start the logger as well before the :hello_world application.
p.359 - Instead of "mix.compile", it should be "mix compile"
p.366 - Section 10.3.3 - "thise", should be "this"
p.370-371 - Plug.Conn.assign(conn, :response, "OK") vs Plug.Conn.assign(conn, :response, %{success: true}) , "OK" vs %{success: true}
p.371 - Using your parse_date function from the code_examples where it pattern
matches with binaries, when you go to do the curl request, on my system you need
to use double quotes (instead of single quotes) around the url.
- Also may want to mention you need to leave the http server running and open a different terminal for the curl request (kind of obvious, but I forgot.)
Sect 10.3.4 - Calls vs Casts - This is I think is the 3rd time you have mentioned
the tradeoffs between calls and cast and 2nd time that you can introduce a
middle-man process. I like that you applied it to the todo project, but it may be
unnecessary to say it again. But it never hurts, just in case you need to cut
pages for some reason.
p.379-380 - On my system, using the iex --erl options, you need the double quotes.
p.385 - The node name is atom, but without the quotes on my system.

By the way, really liking the book. Learning a lot of more in depth examples of how to use OTP and thinking about concurrency.
sjuric (86) [Avatar] Offline
#6
Re: Some errata that I think could be fixed
Thank you very much for your feedback! Your comments have been spot on, and I already started to address some of them yesterday.

> Yea, I found the :erlang.system_info as well, but is
> annoying to having to find individual items like
> that.

You could also try running :observer.start
This will start a GUI app where you should see various information.
For this, your Erlang must be built with wxWidgets. If you downloaded it from Erlang Solutions, it should work.


> Question: Does the fact that the genserver and the
> ets table use the same alias
> conflict at all? Also, is this confusing or actually
> supposed to be the idomatic
> way of doing things, since they are kind of the same
> thing in the larger context.

This is not a conflict, though I wouldn't call it idiomatic (or non-idiomatic). It definitely works, and I think it's appropriate in this case. Ultimately, it simply amounts to choosing a descriptive alias.


> Sect 10.3.4 - Calls vs Casts - This is I think is the
> 3rd time you have mentioned
> the tradeoffs between calls and cast and 2nd time
> that you can introduce a
> middle-man process. I like that you applied it to
> the todo project, but it may be
> unnecessary to say it again. But it never hurts,
> just in case you need to cut
> pages for some reason.

Yeah, I'm aware of the issue and I'm still considering what to do about it. I don't mind repeating things, but this is, as you say, the 3rd occurrence of the topic. I'm mostly inclined to drop the treatment of it in chapter 8.


> By the way, really liking the book. Learning a lot
> of more in depth examples of how to use OTP and
> thinking about concurrency.

Thank you! I'm really glad you like it, and I have found your comments really helpful!
seadynamic8 (10) [Avatar] Offline
#7
Re: Some errata that I think could be fixed
I'm glad my comments helped. Just wanted to help make the book better.

Just a request:
Sect 10.3.5 - (p373-374)
I found the code in todo_web_optimized folder to be a little complicated to understand. It would be great if you could maybe put some comments in the code to explain the strategy used in some of the function calls.

Like when you spawn a worker to do the writes (and handle the replies) and how you have a queue to store the writes. I basically understand it, but it took a little time to really understand it because I also had not used the mnesia database before, so I had to learn the mnesia syntax while understanding the overall concept of the code.

I understand that it may not be necessary to put any explanations in the book, but it would be nice to have some code comments to briefly explain what is going on.
sjuric (86) [Avatar] Offline
#8
Re: Some errata that I think could be fixed
Yes, this is already taken care of, but just didn't make it to the last MEAP release. The reason I didn't do it earlier is because I wasn't sure what will make it to the final release. Now that the original script is finished, and I've gotten some positive feedback, I'm more confident of the material, so I made an initial pass to comment the parts not explained in the book.

The new code should be included in the next MEAP release, but in case you're impatient, I've already hosted the code on the GitHub repo (https://github.com/sasa1977/elixir-in-action).

This repo is intended to be the official place for the accompanying code. I waited until I reach the end of the book, and the examples are more stable before pushing to GH.

If you feel like it, could you take a look at the optimized example and let me know if you find the comments satisfying?

Also a warning: in the GH repo, get_or_create is renamed to server_process. I didn't particularly like the original name, though I'm not quite convinced that server_process is also ideal. In any case, the next MEAP release text should also be updated to the new name. Other than that and some minor fixes/changes, the examples should be mostly identical to the current MEAP release.