Hacker News new | ask | show | jobs
by deathanatos 2300 days ago
> It can feel a bit verbose at times

Certainly can, especially compared to JavaScript. The way I've come to view this (and across more languages than just Rust) is that it's a trade-off between providing more information to the compiler which it can use to catch errors, and verbosity. You can't provide the information without some input, though things like type inference can help cut down on this. IMO, it's worth it: my Rust code, once it compiles, I feel has less bugs than my equivalent Python; I'd rather fight with the compiler than with runtime exceptions.

As I've learned Rust, I also find that sometimes you can elide some parts of things. E.g., in collect() calls, you can say Vec<_>, eliding the item in the Vec, because the iterator you're collecting it from already knows it, and it can be inferred from that.

Of course, sometimes, I think it's nice to provide the type anyways, as I find the compiler is better at inferring than I am. I've definitely spent a fair amount of time in Python looking at a variable and wondering what type IS this?