Compiler optimizations

The compiler can be smart enough to optimize semantically related operators into significantly more efficient specific implementations, considering the information it has about them. For example, in the aforementioned implementation for moving_avg, instead of writing:

 (moving_avg, block_average_priсe)) => 
moving_avg + block_average_priсe / block_window_len)

The compiler allows us to write more concisely and expressively:

.map(block_average_priсe => 
block_average_priсe / block_window_len)

Although the user logically expressed multiple operators, the compiler can make assumptions based on properties such as commutativity. For example, if the compiler determines that addition is commutative, it can generate a differential operator that takes advantage of this fact, avoiding the need for iteration. On the other hand, the compiler cannot make the same assumption about the commutativity of the fold function.

Last updated