Asynchronous Methods

Taking a cue from functional languages like Erlang and Fortress, Sapphire will add implement certain list handling methods in an asynchronous fashion.

Use Case

There are instances where a programmer wants to perform some operation on every element, but does not care about the order. Currently Ruby (among other languages) processes the list sequentially. This is fine for small lists, but becomes problematic when dealing with large lists, where performance can start to become a problem.

Map and Select

The two most common use cases for asynchronous methods are Enumerable#map and Enumerable#select. Programmers typically do not care about ordering for these methods, and are thus prime candidates for asynchronization.

Separate Methods

In order to distinguish asynchronous from synchronous methods, the "a_" method name prefix will be used. Thus, Enumerable#a_map and Enumerable#a_select are the asynchronous versions of Enumerable#map and Enumerable#select, respectively.

Who won't benefit?

For lists with relatively small numbers of elements, asynchronous methods will be of little or no benefit. In fact, they may actually show worse performance. Use appropriately.

Also available in: HTML TXT