Hacker News new | ask | show | jobs
by linuss 3691 days ago
I agree that concurrency is a nearly essential skill nowadays, but would you have any concrete projects or implementations that use concurrency? There's quite a difference between writing a parallel merge-sort and say, a whatsapp back-end clone.
2 comments

Write an IRC bot with sockets. The program needs to listen to multiple networks inputs (the connections to different IRC servers) as well as respond to user input (or at least signaling). This is a great playground to try out different models such as thread per connection, your own busy waiting or sleeping event loop, and OS event loops such as poll.

If you want to do more parallelism rather than just concurrency, you could have some inputs make the bot start doing some work (like computing the billionth digit of pi) and queue the work up into a threadpool. If you really want to get into parallel programming, you could write a multiproducer-multiconsumer queue to allow the IO threads to communicate with the pi computing worker pool.

Hope this is a good concrete project! I did the first part (multiple connection IRC bot) a few years and it definitely helped me understand concurrency and network programming.

If you want a 'toy'/practice project, writing a multi-threaded work queue (multiple producers, multiple consumers) is a good _relatively_ simple one (the API is simple and self-contained, anyway), to get your feet wet with concurrency. In real production work, you'd probably use an existing implementation for your platform of choice, but that's true of many of your examples too (few of us write an OS or compiler for production work! Probably more of us have had to write a concurrent work queue compared to an OS, heh.)