Www.rust-lang.org: Quick path to rust code samples

Created on 30 Nov 2018  路  5Comments  路  Source: rust-lang/www.rust-lang.org

Content Bug Report

Page(s) Affected

https://beta.rust-lang.org/

Maybe https://beta.rust-lang.org/learn, https://doc.rust-lang.org/stable/rust-by-example/

What needs to be fixed?

The first thing I always want to see about a programming language, a framework, etc. is a taste of the source code. The current page gives me this immediately. On the new page, I could not find that quickly.

Neither "Get Started" (See #437) nor "Learn" lead directly to samples of source code.

On "Learn", there is a hope inspiring link "Checkout Rust by Example". If I click on that, I still don't see source code. Admittedly, at least it is only one link away now.

Suggested Improvement

If you do not want to feature example code on the home page, then you might consider including at least an "examples" button.

Most helpful comment

Languages are marketed to programmers. You cannot market languages to CIOs, marketeers etc. It makes zero sense.

Removing the instantly runable code from the front page, and thus not allowing the user to play around with it -- which the thing that the page _got right above all things_ -- is a huge mistake. I'd even say that not putting it above the fold as on the current site would be a huge mistake.

Code doesn't scare programmers. Unrepresentative example (as @lbolla points out above could be the case) is still better than no example. Clicking through pages of fluff before seeing the first code example frustrates massively, on the other hand, and is a sure-fire way to display to an average programmer "if you pick our technology, brace yourself for a world of pain". As it's quite often that, when a library/framework/runtime/language lacks code examples or makes them hard to get by, other elements of it's design are inaccessible as well.

It's just "what Internet taught me", and I am sure, many others. Making code examples an effort just communicates inaccessibility which is diagonally contrasted with what Rust tries to be.

All 5 comments

https://golang.org/, https://www.haskell.org/, https://www.python.org/, etc. all feature a small snippet of code in the landing page. I understand that the Core team could not agree on what snippet best represents the language, but removing it altogether seems a "baby thrown out with the bath water" case.
Maybe a possible solution would be to show one of an array of possible snippets, randomly?

Languages are marketed to programmers. You cannot market languages to CIOs, marketeers etc. It makes zero sense.

Removing the instantly runable code from the front page, and thus not allowing the user to play around with it -- which the thing that the page _got right above all things_ -- is a huge mistake. I'd even say that not putting it above the fold as on the current site would be a huge mistake.

Code doesn't scare programmers. Unrepresentative example (as @lbolla points out above could be the case) is still better than no example. Clicking through pages of fluff before seeing the first code example frustrates massively, on the other hand, and is a sure-fire way to display to an average programmer "if you pick our technology, brace yourself for a world of pain". As it's quite often that, when a library/framework/runtime/language lacks code examples or makes them hard to get by, other elements of it's design are inaccessible as well.

It's just "what Internet taught me", and I am sure, many others. Making code examples an effort just communicates inaccessibility which is diagonally contrasted with what Rust tries to be.

Its probably worth noting that the tracking issue for the Landing Page (#235) has a work item that says we need to add call-to-actions (CTAs) for Rust Values that point directly to demonstrations of those values.

In many (or all?) cases I expect those demonstrations will take the form of Rust code examples.

I also do care about this issue.

I've seen @steveklabnik note several times on the reddit thread discussing the beta site that a reason there's no code snippet is that it was difficult to identify one that was "good enough."

In my opinion, our goal need not be not a piece of code whose meaning is obvious to newcomers. It just needs to showcase our values.

Here's my vote for something short that would be great on the home page: Niko's quicksort utilizing Rayon is beautiful, and leverages a number of Rust features: 3rd party crates, &mut borrows, slices, F-bounded generics, closures. And its just 8 lines!

fn parallel_quick_sort<T:PartialOrd+Send>(v: &mut [T]) {
    if v.len() > 1 {
        let mid = partition(v);
        let (lo, hi) = v.split_at_mut(mid);
        rayon::join(|| parallel_quick_sort(lo),
                    || parallel_quick_sort(hi));
    }
}

We are not interested in putting code examples on the landing page at this time, see also: https://github.com/rust-lang/beta.rust-lang.org/issues/436. For the moment, we don't have an examples page, and therefore aren't interested in an examples link. Closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zaechus picture Zaechus  路  5Comments

Manishearth picture Manishearth  路  6Comments

ashleygwilliams picture ashleygwilliams  路  5Comments

Veedrac picture Veedrac  路  5Comments

stevensonmt picture stevensonmt  路  4Comments