How to Control Your Children

One rather entertaining use for a child process is to convince the human user that something productive is happening during a long calculation. When generating large Fibonacci numbers using our old inefficient recursive function, it might be comforting to see a little spinning bar at the text cursor position until the answer comes back.

Mind you, our “progress spinner” isn't a real indication of progress. It's just eye candy, a little psychological trick. If the calculation somehow got stuck in an infinite loop, the spinner would keep spinning, giving false assurance that all was right with the world. (Think of it like the animation Windows shows when copying files on the desktop, or like that infamous “your call ...

Get Sams Teach Yourself Ruby in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.