Hacker News new | past | comments | ask | show | jobs | submit login

That's totally fair, but that may have something to do with how well you know Rust. I obviously don't know your familiarity level, but once your mental models "snap" out of thinking about moving data around, and start thinking about operations upon the data, it gets really intuitive.



I've seen Rust written in imperative style, and it was clear to me in most of the cases. I think it's more the difference between imperative and functional styles that's throwing people for a loop.


> I think it's more the difference between imperative and functional styles that's throwing people for a loop.

Pun intended? If so, nicely done.


Yeah this is clearly someone who's into FP. If you rewrite this code to replace the map/sum with a for loop it's basically identical in length, while being completely idiomatic.


It took me some tome to embrace this style in Rust, but now o love it. It cuts down on boiler plate code.


I am familiar enough with functional programming patterns. I could probably understand this if I had some more experience with Rust. But I think I would be able to understand the snippet in most imperative and functional languages.

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.


> I am familiar enough with functional programming patterns.

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 clear


  > 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?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: