Hacker News new | ask | show | jobs
by sedeki 1334 days ago
Can anyone recommend a good book/primer on "concurrency models" (is that a term?) for a self-taught programmer?

While I am self-taught, I'm used to (academic) books that strive for completeness. It is also what I prefer. Rather than something more pragmatic like a blog post.

It doesn't mean I want to read overly complicated prose on the subject, which I'm sure is possible.

3 comments

I don't have a book recommendation ready, but if you want to see how async can be used in a large codebase, have a look at the telethon [1] library. It's a python library for telegram and one of the few that actually implement MTProto. It's huge, generates a large chunk of its machinery automatically from the MTProto specs and is extremely (!) well structured.

This is much more useful than the typical "let's write a single-run example with async" blog post.

[1] https://github.com/LonamiWebs/Telethon

The book https://pragprog.com/titles/pb7con/seven-concurrency-models-... is actually pretty good, and much better than the title may suggest.
I think you should start by reading how "async" really works… that's call on a poll() (or epoll on linux) function, a loop, and a list of "call this function when this file descriptor can be written/read".

The whole async thing is there to abstract away and not have the program structured around the main loop… but in reality you have to keep in mind you are in a main loop that calls poll() and then all the registered functions.