logoalt Hacker News

lionkorlast Wednesday at 8:48 AM2 repliesview on HN

I do write a lot of Rust. Without cargo, it can be a pain in the ass, because nobody designed it to be used without cargo.

Generate a random number.


Replies

umanwizardlast Wednesday at 5:42 PM

How is it any harder than using C? Sure, the C standard library gives you random numbers, but it doesn't, for example, give you any containers (hash maps, vectors etc.) which are needed even more often.

> Generate a random number.

Well, obviously, I would use cargo and pull in the `rand` package, because I'm not an anti-dependencies ideologue. Cargo makes it easier to depend on third-party code; that's the whole point. But the OP explicitly doesn't want that, so presumably he'd write his own RNG from scratch, or download a tarball of the `rand` package and build it manually without cargo. None of this is any harder in Rust than it would be in C or C++.

JoshTriplettlast Wednesday at 8:06 PM

> Generate a random number.

Working on adding that to the standard library, along with a handful of other "you should be able to do this without a dependency" things. We're being very cautious to not fall into the trap of "the standard library is where code goes to die", which is the problem some languages' standard libraries have had. But there are more things we should add, nonetheless.

show 1 reply