All these new languages are unreadable relative to C. If, like me, you like explicit stuff like for (size_t i = 0; i <= n; i++) total += a[i]; all these new languages won't do it.
Funnily, Zig does allow doing it explicitly like that, just need use while rather for:
var i: usize = 0;
while (i <= n) : (i += 1) {
total += a[i];
}
That said, perhaps Odin, for which simplicity and readability is guiding principle in its design, is more up your alley. In Odin, can be read: for i := 0; i <= n; i += 1 {
total += a[i]
}
Exactly same style can be used in Go & V (which is/was? quite infamous here in HN). But in all languages, for this example at least, a foreach-like iteration, i.e. for x in a {
total += x
}
would be preferred.I honestly don't think total = a.sum() is any less explicit than for (size_t i = 0; i <= n; i++) total += a[i]. If anything, a.sum() is more explicit as at least it expresses the programmer's intention explicitly. The loop is one more layer between the reader and the writer's intention, without faithfully reflecting what happens on the bare metal. So it's the worst of both worlds.
I don't like this explicitness, because very often it's a lie. In the times of PDP-11 that would compile into a literal counter and literal ADD, DEC, and BNE instructions. Now it will most often compile into some vectorized semi-unrolled form with seven-letter instructions like VPHADDD which add many integers at once, etc.
If I want specific instructions to be run in a specific order, like touching hardware registers, I reach for intrinsics or assembly. If I want an array summed, I prefer to express the intent: total = the_array.sum(); I leave the implementation to the compiler / stdlib.