implementation of Bali written by C++