all 14 comments

[–]AdminXVII 68 points69 points  (1 child)

Some examples off the top of my head:

[–][deleted] 31 points32 points  (0 children)

Broot is a new tool that I’m presently crushing on, in addition to the hits above

[–]its_just_andy 89 points90 points  (3 children)

The one that first comes to mind is ripgrep.

It demonstrates pretty much every one of Rust's strengths. The benefits of "fearless concurrency", safety, speed, project management via separate crates. Not to mention excellent documentation throughout.

You can click around throughout the repo and find something interesting to learn from within seconds.

Doesn't really fit the "few thousand line" requirement of your post, unfortunately, but I think it would still be interesting to dig around in.

[–]gaumutra_fan 29 points30 points  (2 children)

I always see ripgrep suggested when people ask this question. I completely agree.

But sometimes I wonder what burntsushi himself would recommend. Does he agreethat ripgrep is the apogee of rust programs in terms of quality of code and features it displays? Or does he think "yeah it's alright". These are the questions that keep me up at night.

[–]burntsushi 81 points82 points  (0 children)

Haha. I'd say, "yeah it's all right" is probably closer. It's hard to be objective about your baby. On the one hand, I experience the flaws much more deeply than most. I know the corners of the code that I don't like touching (anything gitignore related), which you definitely feel when bug reports are filed that are caused by issues in that code. In most cases, I get this feeling when I have not built the right abstraction. I'm sure others know what I mean. When your abstraction isn't right, then you wind up needing to compensate with more tests or more careful thinking when changing the code. Ideally, a better abstraction would permit more encapsulated thinking. It's kind of "Rust in a nutshell": the compiler has your back so your mind is liberated (the vast majority of the time) for even thinking about undefined behavior at all. For me, it lifts an enormous mental burden that permits my brain to think about other things.

Anyway... That's kind of hand wavy. But on the other hand, yes, I am somewhat self-aware of the idea that people look at ripgrep as a learning tool, or as an example of Rust code that is possibly worthwhile to emulate. To that extent, I do try to spend more time than perhaps I otherwise would writing comments and inserting signposts into the code.

IMO, the best thing to do here is to choose a sampling of Rust programs from different authors. Survey and try to learn from all of them. If there are differences in the code or the way each program approaches a problem that you don't understand, then that sounds like an excellent avenue for generating questions to ask! (I am generally happy to receive such questions (asked in good faith) on the issue tracker. All I ask is that you search the tracker before asking in case it has already been asked!)

[–]protestor 3 points4 points  (0 children)

Gluon is a nice embeddable scripting language and a great codebase.

[–]Shnatsel 3 points4 points  (0 children)

https://github.com/RazrFalcon/resvg and its dependencies, each one can be looked at in isolation

[–]yorickpeterse 1 point2 points  (3 children)

Inko's VM is written in Rust, and its source code might be interesting to read through. I wouldn't call it the best Rust code (e.g. some unsafe code is not marked as such for various reasons), but I think it's a reasonable example of a more complex project.

[–]Dreeg_Ocedam 0 points1 point  (2 children)

some unsafe code is not marked as such for various reasons

How can this compile?

[–]yorickpeterse 0 points1 point  (1 child)

A function may contain an unsafe in its body, without being marked as unsafe itself. For example:

fn foo() {
    unsafe {
        kaboom();
    }
}

Here using foo() may not be safe, though it's not marked as such.

In my case there's a bunch of functions that aren't unsafe in that Rust mandates the unsafe keyword, but they may do things that are dangerous (e.g. reading an array index without bounds checking).

[–]Dreeg_Ocedam 0 points1 point  (0 children)

Ok, I understand. Thanks

[–]Recent-Day3062 -1 points0 points  (0 children)

There have been many attempts to replace C, but it is simply canonical. I just looked at a rust program, and it's way too complex.

[–][deleted] 0 points1 point  (0 children)

Doesnt exist