Some comments here on bedcov:
1.Your implementation of Klib.jl on the master branch, which
bencov relies on, is not identical to Crystal’s or Nim’s. See the function
it_overlap!. In Julia, it uses an empty vector as stack by popping and pushing elements. However in Crystal or Nim, it preallocates a fixed-size staticarray and use a integer to track top of the stack. I don’t know why you use two different approahes here, cause it’s also quite straightforward to translate Nim/Crystal to Julia.
2.Still the function
it_overlap!. In Julia, you push the result into an Vector b. But in Crystal/Nim, since they have a builtin-in
yield keyword, it doesn’t create a temporary array. In Julia, you need to import some packages to achieve
yield's function or manually use
Productivity:on these two tasks, Crystal and Nim are also expressive.
are not quite exact. Let’s take the function
it_index! for example. In Crystal:
def self.index(a : Array(Interval(SType, DType)))
last, last_i, i = 0, 1, 0
while i < a.size
last, last_i = a[i].en, i
a[i] = Interval.new(a[i].st, a[i].en, a[i].en, a[i].data)
i += 2
k = 1
What’s the type of
last? You first declare it as 0, which I guess it’s a Integer(I don’t know much about Crystal, only some Ruby). However it’s then be assigned as a[i].en, which is type of SType. In Julia, you correctly avoid this type-unstable by convert 0 to SType:
last::S = 0
You are lucky that you only use Integer in Crystal’s test. It you use float number then it will be either type-unstable or unable to pass type-checking.
Nim is powerful anyway, it can also declare type of
last as SType, however, it is tricky here: it doesn’t initialize
last as zero. To do these you either need to have some forms of “class methods” (methods defined on classes instead of objects) so you can write S.zero(), or use multiple dispatch. But problems still persists if you use class methods. You are not allowed to extend the methods of class once it gets defined. This is the common problems of OOP.Of course, Python and Ruby are quite flexible and the class es are open, but I don’t think that’s the case in Crystal and Nim.