Pun intended? If so, nicely done.
My point is not that the snippet is bad, just that Rust feels, looks, and probably is, quite complex. As opposed to, for example, Haskell, which also introduced a bunch of nice, new, ideas.
> Rust feels, looks, and probably is, quite complex. As opposed to, for example, Haskell
Do you really think that Haskell is less complex than Rust, or am I just reading your comment wrong?Really? I've never used rust but the code was pretty clear to me except for the >> shift part.
> But I think I would be able to understand the snippet in most imperative and functional languages.
In Python (ignoring the shift thingy) I'd write
prediction = sum(map(lambda c, s: c*s, zip(coefficients, buffer[i-12: i])))
To me, both are equally clearI know, I know, the C code you write never has buffer overruns, just like the C code I write never does, well, except that one time, but then I caught it in the debugger during testing and it was easy to fix. Oh, and then that other time, but I caught that one too, and then.....
Nah, I did that on purpose because I remember the time I accidentally swapped the 'value' and 'size' parameters of memset, trashing the stack, and so now I go the 'safer' option to just leave things uninitialised. Not to mention the performance increase I get from avoiding a memset that isn't necessary, so long as I'm really, really careful and never make a mistake, which I almost never do.
And I cannot tell if you are serious, trolling or sarcastic, because I know people who think this way, think this way is a joke and think this way is the bane of their professional lives.
No it's not. In this line:
.zip(&buffer[i - 12..i])
you can just put any indices and it will compile.