Live data from Hacker News

Show HN: Algorithm Cookbook in Rust

github.com

31–40 of 73 posts

Re: Show HN: Algorithm Cookbook in Rust

#31

Earlier quoted context omitted.

Data structures and algorithms are possibly the hardest part of Rust to dive into unless you have a really good reason. The best advice for newbies is to learn with other stuff and use existing algorithms. Of course, if you are trying to implement stuff for a class or something similar then you might be out of luck, and might consider trying the Rust IRC and such to work through the errors as they come up.

So what is the point of a language in which things are hard to implement?

Efficiency, predictability, increased security.

Re: Show HN: Algorithm Cookbook in Rust

#32
post #12

"My other goal is to show developers that C++ and Java kinda suck" -- really?!

It's a worthy cause. At HN we might all be aware that Java and C++ suck, but others might not know. Assuming others know what you do is a common cognitive bias. To us, this might be a slightly childish thing to have as a goal, but it might be a revelation to some readers.

Re: Show HN: Algorithm Cookbook in Rust

#34
post #5

A graph with the members first, next, and endpoints is not exactly self explanatory, something better than a "A compact graph representation" comment would be nice. Especially since the ownership model of rust makes the classic graph representation of edges owning nodes impossible.

It is only impossible​ using safe Rust. Unsafe code blocks should allow to represent this behind safe API.

Re: Show HN: Algorithm Cookbook in Rust

#35

Earlier quoted context omitted.

Data structures and algorithms are possibly the hardest part of Rust to dive into unless you have a really good reason. The best advice for newbies is to learn with other stuff and use existing algorithms. Of course, if you are trying to implement stuff for a class or something similar then you might be out of luck, and might consider trying the Rust IRC and such to work through the errors as they come up.

So what is the point of a language in which things are hard to implement?

Algorithms and data structures are inherently hard to implement correctly and safely given low-overhead, bare-metal designs.

Rust tries to guarantee that you've implemented things correctly and safely, and therefore makes all the formal verification of such into a requirement.

Other low-overhead-bare-metal languages, meanwhile, trust you to have done the formal verification yourself using non-compiler-toolchain tools like linters and static analyzers.

The people who use these other languages who do ensure correctness+safety, will have done all the same work they do in Rust—just using third-party tools instead.

The people who use these other languages but who do not ensure correctness+safety, might seem to have an "easier time", but they will almost always end up with algorithms/data structures that—while seeming to work in most cases—have fatal flaws or vulnerabilities.

To use Rust is simply to sign up for "doing the work" of formally verifying your code up-front, rather than brushing it off as something to think about in some vague, undefined "later."

Re: Show HN: Algorithm Cookbook in Rust

#36
post #11

To add to the list, here's my rust-noob implementation of the Kalman filter. https://github.com/rbagd/rust-linearkalman

GPL3 means it's not very reusable in any projects that aren't GPL3. Have you considered a BSD or MIT license? or CC0 if you want to get code reuse? Or at the very least LGPL2

Maybe that's what they want. Personally I use GPLv3 for any project I can, because my priority is user freedom and not code reuse.

Re: Show HN: Algorithm Cookbook in Rust

#38
post #4

This is great. I am curious if anyone else knows of a similar cookbook for Golang.

I have implemented quite a few algorithms and data structures for fun here [1]. It's not authoritarive by any means, and not everything is in Go (there's also some Rust, Swift, TS and JS), but maybe a few things could turn up useful. [1] https://github.com/peferron/algo

Awesome. Thanks for the links.

Re: Show HN: Algorithm Cookbook in Rust

#39
post #11

To add to the list, here's my rust-noob implementation of the Kalman filter. https://github.com/rbagd/rust-linearkalman

GPL3 means it's not very reusable in any projects that aren't GPL3. Have you considered a BSD or MIT license? or CC0 if you want to get code reuse? Or at the very least LGPL2

Thanks, that's a fair point. I do value user freedom and also come from the R language where GPL rules among packages. It's true though that Rust crate culture leans much more to MIT.

I think GPL3/MIT as a dual license should be a decent compromise.

Re: Show HN: Algorithm Cookbook in Rust

#40

Earlier quoted context omitted.

So what is the point of a language in which things are hard to implement?

It's not any harder to correctly implement a data structure, even an "advanced" one, in Rust-with-unsafe than it is in C++-with-exceptions. I don't know where this meme comes from.

Some of it is probably that you're not able to not-handle some categories of flaws, and the compiler yells at you for them instead of pushing it off to a runtime error you may never see. Instant pain on the ignorant implementer rather than "works on my machine™".
Post reply on HN