Executing Code Concurrently Through Fibers
Although they’re hard to demonstrate usefully in a tiny example, you should know about Crystal’s fibers before going further. They may change the way you structure your programs. In this age of multicore CPUs and distributed computing, developers need their programming language(s) to provide excellent support for concurrency and parallel processing. Unfortunately, this is something Ruby has never been very good at.
In Ruby, you can create multiple threads of execution with Thread.new, but they work on the operating system level. You can have a few hundred of them at most. Moreover, in its C implementation, Ruby is limited by the GIL (the Global interpreter lock), which means that only one Ruby thread ...
Get Programming Crystal 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.