433 points · by aturon · 9y ago · 122 comments
A post was recently on the frontpage of HN about using Haskell in production [1] that divided the common documentation experience between "hard" and "soft" docs. Far too often with Haskell you only get the 'hard' docs where you get descriptions of functionality and functions but it lacks why (and cohesively how) you would want to use the various functionality.
This makes a strong assumption you are already deeply familiar with the usecase and implementation concept.
This may apply to Rust as well. Rust will likely attract experienced developers, much like Haskell, where in most cases a decent level of code quality would be anticipated. But one of the hardest things to get right as an OSS developer is documentation. You're often so busy with the burden of maintenance that the explanatory side gets sidelined. Especially as a library and the underlying language evolves. So I hope this is a priority focus during their reviews.
There was actually a thread on /r/haskell a few months ago [0] in response to an HN comment. In that thread, a few libraries were mentioned as examples of having amazing docs.
For instance, Gabriel Gonzalez writes a Tutorial module for his libraries, which introduces the basics of the library and shows you the big picture. The tutorial walks you through different pieces of the library, how to use them, and how they come together.
It's hands down one of the most effective ways of documenting I've ever seen and I'd love to see other communities' take on it.
To point out a specific example, you should check out Turtle's tutorial [1].
[0]: https://www.reddit.com/r/haskell/comments/5khts3/on_haskell_...
[1]: https://hackage.haskell.org/package/turtle-1.3.3/docs/Turtle...
It feels like the real issue is that anyone who considers themselves a writer, as well as a programmer, tends to have a blog; and that people who have blogs are incentivized to write "soft docs" as tutorial blog posts for their blogs, instead of as encyclopedia-style or cookbook-style additions to the given library's docs.
I wonder if a programming language could adopt a Code of Conduct discouraging tutorial blog-posts in favor of soft-doc PRs...
There's only so much you can put in docs, and docs can only really encompass one way of learning things.
Blog posts help teach things in other ways, and having that diversity of approaches is great.
This is why, for example, I love Julia Evans' (http://jvns.ca/) work. Most of the blog posts don't really uncover undocumented stuff. They just explore the topic in a novel way, which some people may find more accessible.
Rust is open to importing blog posts into the docs; this has happened a few times (once to one of my own posts!). So I'm happy that there are blog posts out there.
That said, if you're writing a blog post, it's good to see if there are bits than can be put into the docs too.
Instead, they should work to change the incentives -- likely by paying more attention to them as an organization, talking about people who contribute them on the project's page and blog the same as they do for major technical work, and possibly even bringing on maintainers focused on (soft) docs.
Trading attention and prestige for content might work, shaming the people who produce content for not giving you the credit for free is unlikely to.
I don't think projects give soft docs the credit they deserve, so why are people so surprised that people develop that content elsewhere, where they're recognized for it?
I'll only start doing the tutorial doc and/or blog post if others have interest in the library. There's just not enough time :/
I don't think there's a dearth of people willing to write blog posts. There's just a dearth of people willing to do the equivalent job to what Wikipedia editors do for general-purpose articles: collating those "primary sources" into a single, coherent, up-to-date overview.
See for instance the "image" crate docs: https://docs.rs/image/0.13.0/image/
A simple API doc, I don't know where to start. But then if I go to the repo I find a nice intro with some example code: https://github.com/PistonDevelopers/image/blob/master/README...
It's language design the way it should be: incorporating the cutting edge ideas from academia while still striving to cater to beginners; drawing on the strengths of other languages communities to build out good library and solutions to package management; designing everything in the open, and constantly seeking feedback from their users.
It's a great blend of theoretical CS, HCI, computer systems, and application development, and it's always fun to hear about what they're up to.
Yeah, me as well. It's a perfect marriage of academic know how and pragmatism. Very exciting year for Rust.
Feedback welcome.
- "Yes"
- "No, I stopped using Rust"
- "No, I've never used Rust"
When making a survey the alternatives for the answers are very important. I feel that none of these alternatives apply to me. That's bad. Unfortunate because I would have liked to participate in the survey.
I've done a little bit of beginner programming in Rust in order to try and learn the language. However I haven't yet used it to implement anything actually useful so I wouldn't say "yes, I use Rust". It's been a while since last I did something in Rust but I wouldn't say "no, I stopped using Rust" because to me that implies that I have decided that Rust is not for me, which is not something that I feel, I want to use it, I just keep pushing it down on the list of things to do because other more immediate desires and problems keep popping up.
*"roll a die" for those who prefer more atavistic conventions - see research on Latin plurals rendered in English over time and with regard to frequency of use.
Clojure survey had something along these lines
This can be addressed in a language with sufficient annotation and good parser tools. In some future language, there should be a unification between the version control, the de-facto codesharing site, language/library versions, and syntax-driven tools to automatically rewrite code.
It should be possible to "publish" a language and its libraries such that any breaking changes will automatically be updated when you switch library versions. (This should also be applicable to Entity-Relation diagrams and Object-Relational mappings -- those can be treated as a versioned library.)
To avoid that, you need to standardize on a blessed set of versions to be tested together, much like assembling a release of a Linux distro.
People will still swap in alternate versions of libraries occasionally, but keeping things mostly standard and a few cherry-picks is still better than everyone choosing differently.
The point is not to let people hang out in whatever obscure snowflake version-set they want to. The point is to make migration going forward as painless as possible. However, that expectation is not so much about the tooling as it is about the developer/language community.
To avoid that, you need to standardize on a blessed set of versions to be tested together, much like assembling a release of a Linux distro.
Yes, there should be this! However, you will still have some stragglers and outliers -- this is what the historical reality shows us. The point of such tooling is precisely to minimize the pool of stragglers, not to maximize them!
That's pretty much the Stackage/LTS Haskell model. Seem to be working pretty well there.
You actually get a lot of that in Perl 6, which identified modules not only by name, but by version and authority (so you can choose to load author Bar's version of Widget instead of author Foo's version.
Is there a plan to make these things statically checkable by rustc/rustfmt/rust-tidy or some sort?
It's not about the crate being non checkable, it's about the check being something that needs a human to look at.
https://github.com/brson/rust-api-guidelines#interoperabilit...
Maybe the checklist should get a more prominent link or notice in the blog post. It took me a while to find it.
In short, the blog post makes very little mention of the role of the primary author(s) of the libraries in question, beyond "Every two weeks, hold a library team meeting [...] with the author in attendance." While I imagine the reality will be quite different, this sounds an awful lot like "oi, you, code review in my office now!"
One of the attractions of working on open source is that it offers more scope for autonomy and individual recognition than the typical commercial software job. It's slightly alarming that this doesn't seem to be recognised here.
As I say, I'm sure the reality will be fine (and I remain very keen to give Rust a serious try when time permits), but the rather collectivist presentation here is a tiny bit off-putting.
Nobody is forcing stuff on random crate authors; if they didn't want to participate, then that's 100% okay.
I still feel there's a slightly-unfortunate ambiguity in the linked announcement post, though.
Words are hard.
As a prospective crate author - and every programmer is a prospective crate author - i interpreted this as saying that if i publish a crate which people find useful, i might be getting an unexpected visit from the Rust Police.
Must say that I agree with you that the authors do not seem to take a very central role in the process as described. But I see that more as an easy fix in the announcement text.
It's not just this, either, a lot of the top-down communication in the Rust ecosystem has a feel like this. I'm not sure what to make of it, except that I think their attitude is probably too authoritative.
"Vec" currently needs unsafe code, because Rust doesn't have the expressive power to talk about a partially initialized array. Everything else with unsafe code is an optimization. Often a premature one. Maps should be built on "Vec", for example.
When you start looking through Rust libraries, "unsafe" turns up way too often.
> When you start looking through Rust libraries, "unsafe" turns up way too often.
You keep making this claim without substantiation. Yes, there is some level of unnecessary unsafe, but certainly not "way too often". I recall going through all the crates in my .cargo and finding very little unnecessary unsafe, and showing you the audit: https://news.ycombinator.com/item?id=13280347
Please stop throwing around this claim without substantiation.
You need unsafe code to invoke a syscall. Doing I/O is not an "optimization".
Rust tries to help you as much as possible but recognizes that it sometimes gets in the way and provides an escape hatch. The idea is to minimize and abstract the use of the escape hatch so its easily auditable.
I wish they hadn't named the escape hatch "unsafe". I think I heard the name came from PL theory but it makes it sound scarier than it is.
I remember hearing something about wanting to improve documentation around unsafe for how to best use it without running into problems.
http://doc.rust-lang.org/doc/stable/nomicon/ is the documentation for unsafe. I do plan on improving it heavily, but I'm very busy right now, and I'd like to wait for some of the unsafe semantics stuff to be pinned down so that I can go in full depth when I write this.
> I'd like to wait for some of the unsafe semantics stuff to be pinned down so that I can go in full depth when I write this.
Thats the work I was thinking of.
I believe the stdlib one could be refactored, but I'm not sure. There are a lot of optimizations in that one.
IMO "no unsafe code" is a stretch. "no unnecessary unsafe code" is what it should be.
It imports std::collections::hash_map, which has unsafe code, but only for RandomState, which does not. If RandomState were pulled out of hash_map and moved to a crate with no unsafe code, that dependency could be removed and it would be safe crates all the way down.
IMO "no unsafe code" is a stretch. "no unnecessary unsafe code" is what it should be.
The author of the code doesn't get to determine "unnecessary". That should require extensive and hard to get justification.
No, it is more specialized for certain kinds of loads.
> It imports std::collections::hash_map, which has unsafe code, but only for RandomState, which does not. If RandomState were pulled out of hash_map and moved to a crate with no unsafe code, that dependency could be removed and it would be safe crates all the way down.
That's a very vacuous distinction.
This is all in the same crate (std) anyway, it's just a different module.
> The author of the code doesn't get to determine "unnecessary".
The auditors (proposed in this blog post) do.
I've audited unsafe in the past to ensure our dependencies are fine, there are some pretty reasonable ways to define "unnecessary" here.
That unsafe code is filling a want or need, so otherwise people are going to use crates that haven't gone through the process, or even worse, roll it themselves.
> Everything else with unsafe code is an optimization. Often a premature one.
Rc, Arc and Box require unsafe code for the obvious reasons that are not premature optimisations. Any attempt to use a syscall (look at the nix crate which wraps libc with safe APIs) requires unsafe code.
Unsafe doesn't mean "this code is bad". It is true that unsafe code should be treated very carefully, but it's purpose is so that a sufficiently clever human can implement safe code that the insufficiently clever compiler cannot verify.
Really it should've been called trustme rather than unsafe. ;)
https://dlang.org/blog/2016/09/28/how-to-write-trusted-code-...
It is very unfortunately named.
The most recent CERT advisory reporting a buffer overflow exploit was April 17th, 2017.[1] About one per week is reported, year after year. Others not reported are probably being exploited. Rust can stop that, but one "unsafe" declaration can break Rust's safety.
Hash maps need to be 100% safe code. They're complicated, and involve elaborate calculations that output subscripts.
Can you share the ecosystem wide analysis that you did that led to this conclusion?
Coroutines are kinda more like a language feature that people have hacked libraries to do codegen for instead, so IMO it's pretty understandable that it needs nightly.
Many of these libraries are prototyping designs that will eventually be proposed as part of the language.
andy@xps ~> python3
>>> "Libz" == "libz"
False >>> title_case("Libz") == title_case("libz")
TrueWe detached this subthread from https://news.ycombinator.com/item?id=14275990 and marked it off-topic.