Rust beginner notes & questions

This is what I imagine the story to be behind a lot of things that were stripped pre-1.0 like std::num::Zero.

Stabilization affects the language

At some point in time, the feature existed. However, there were things about it that were simply not as nice as it could be:

  • perhaps the best design was still unclear; it needed further experimentation and design iteration.
  • perhaps rust was missing critical language features to make it ergonomic (or these features existed and were buggy/unreliable), like const functions or higher ranked types. Zero appears to have been such a trait; its unstable feature message used to read:

    Unstable: unsure of placement, wants to use associated constants

  • if something was underutilized there could be unknown unknowns; poor design decisions lurking just beneath the surface that would only be discovered after stabilization. (and even with the team practicing their discretion, some of these still managed to slip through, like std::error::Error)

In the rush to 1.0, a decision had to be made:

Are we ready to support this thing in its current form, without breaking changes, for all of eternity? Or should we wait until it is possible to do better?

Some things (like the f64::consts modules) were simply so fundamentally important that something had to be stabilized even if it was a terrible hack! But many things were hidden behind feature flags on the notion that we can have something better.

For a while after the 1.0 release, you couldn’t even sum an iterator on stable!! Things such as this were slowly added back based on how desparately they were needed. There wasn’t a single person using rust who was not losing hair over the inability to sum an iterator, so std::iter::Sum eventually had to be added even despite being a terrible hack.

So that’s my idea of how these features got removed. However, there is also a second chapter to this story.

The language affects the users

After the removal of something from the standard library, a paradigm shift can occur. People can go from thinking

this is basic functionality and it is appalling that I need to use a third-party crate

to beginning to think

that problem is so complicated that it doesn’t even belong in the standard library. There is no design that is good enough to be worthwhile.

Maybe sometimes this really is true, but other times this view may simply by colored by the status quo. In a way, it’s the blub effect, and I believe we are all susceptible to this.

I know I’m going to receive flak for saying this, but:

We are all at risk of adopting an apologist viewpoint on missing features.

…and it is at this point that the absence of something in the standard library may become self-sustaining.

How can this be prevented? I don’t know. Identifying and challenging one’s own cognitive biases is not easy. Sometimes somebody motivated appears and smacks whole the rust community with a harisen, writing an epic blog post to remind us all that yes, there is still hope for having such a feature in the standard library. But in general?

…hm, there I go again. Always seeing the problem, but never the solution…

I had an example of a possible personal case of this phenomenon, but it has gotten really long for this post. Maybe I’ll make a separate thread…


I applaud the poster and responders here. I see this as healthy critical discussion. I don’t interpret Peter bertoks comments as “pissed”; I see it more as intense, which I think is good that a program language should evoke intense feelings.
As someone who took to rust a few years ago, lost traction, and am now coming back to evaluate I very much appreciate discussions like these. When I evaluate a tech for adoption, which has impacts on the success of my business and my livelihood, I want to know what the warts are; downsides, issues; limitations of a language are far more important than features IMO.

Rust, unfortunately it seems, is now stuck with the “difficult” moniker that plagues Haskell; a sad psychology that creates learning anxiety in people before they even start. Studies on math anxiety have shown this is a real and lasting effect, causing measurable stress. Props to the rust community for taking “usability” head on.

As someone new to the community (and from the luxury of my vagabond status) I can report that I have had conversations with colleagues where they shared the sentiment that if both rust and c++ demand a high cognitive tax they’ll just stick with c++. I find this unfortunate but both realistic and pragmatic. And by high cognitive tax I mean things commonly brought up about rust like fighting the borrow checker, type system, etc… , and things like inconsistent APIs (though I’ve got no real examples so maybe there is a large amount of FUD here…?).

I’m curious what are the pragmatic views/uses of rust? Id love to see examples a non-trivial AND pragmatic rust programs side by side with go and c++. Perhaps they are out there and I just need to look. I’d love to see rust advertised as a pragmatic solution to a class of problems. In my experience it would be a great balance to the well-known complexity. People who have never written or seen rust know it’s complex and I’d like to pull out a pragmatic example and show them it’s no worse than nodejs, go, etc… IMO pragmatism trumps other inneficiencies and fringe quirks.

I’m still playing with rust and dedicated to learn as much as I can and I hope to find that it is the right tool to build my next project (fintech payment collections service using optical character recognition reading receipts and account summaries). To be frank, one reason for picking rust ( over go or c++) is the combination of generics, better guarantees for data races, memory, etc…, and a cleaner API and ecosystem (not really an issue with go).
I have a high tolerance for learning new things and am not afraid to pay people to do the same, if it means landing on superior tech. Part of superior tech is productivity, which I define relative to project and cost of failure. I’d rather spend an extra month(s) building something if that means it will require less maintenance, bugs, and errors over the course of time. I see rust as being able to provide that kind of productivity (versus deliver fast and spend months debugging). But I get concerned when people I know, who are polyglots and not averse to new things, eliminate rust due to complexity… And I can’t help but wonder if that complexity is related to Peter bertoks general issues.

Thanks for all the work you do. I hope I’m not coming off too negative or as trying to create unnecessary anxiety or as telling experts how to do their job.


I’m not sure if this counts as a “pragmatic” program, but one of the things that won me over to total Rust fanboy status was when, only a few weeks after reading The Book for the first time, I looked at the implementation of std::arc::Arcand I could understand it. Easily.

This is in contrast to my complete inability to read just about anything in a typical C++ std implementation, despite multiple years of experience being paid to write C++ code and reading plenty of books on C++ obscurities. I know by heart how a typical std::shared_ptr is laid out in memory, but the actual code of any non-toy implementation remains total gibberish.

This is unfortunate. However, the good news is that it’s not a universal view. There are also plenty of anecdotes from people with a background in scripting languages that found Rust “made systems programming accessible” for them.

You may have seen the quote (does it qualify as a meme yet?) that “Rust is difficult because writing correct code is difficult”. I don’t like to say it too often because it risks coming off as shutting down legitimate critical discussion, but there’s also a lot of truth to it. Most of the things that are hard in both Rust and C++ are part of the essential complexity of systems programming, like understanding ownership, stack vs heap memory, race conditions (as opposed to data races), etc. So “the sentiment that if both rust and c++ demand a high cognitive tax” is technically correct… but it also ignores the many, MANY sources of accidental complexity that C++ mostly inadvertently created and Rust, with the benefit of hindsight, successfully avoids or actively defends against.


I stepped into Rust by starting to rewrite a command line app which I had written previously in Perl.

Although the Rust learning cure is pretty steep (but manageable for my background) I’m very pleased with

  • the expressibility the language offers (comparing here to e.g. Go is an insult to Rust)
  • the speed programs run (especialy in comparison to many other languages)
  • the Rust Programming Language Forum here which is extremely helpful (quick and high quality answers)
  • the documentation which is very good (only to mention the Rust book)
  • the compiler which is very helpful in preventing me to do stupid things on the one hand and to suggest viable solutions on the other hand
  • the availability of Rust books (the good point is: if anybody is short on money there is the very good Rust book), to name a few: S. Klabnik’s new book, J. Blandy & J. Orendorff’s book
  • the availability of blogs aso which are really good (ok, one has to check how old they are… as the language has evolved over time)

Of course, it doesn’t mean that there are no situations where I’m struggling to understand things but in the end I’m confused on a higher level of consciousness (which is not bad for my understanding of life. and progress…). :slight_smile:


haha, totally agree.

to me, this is what peter_bertok is trying get at, and that in his view rust is already starting to slip into some bad habits that led to complicated c++, the latter of which has had many years to accumulate such cruft. Perhaps that just the nature of an aging programming language that has to evolve with other advances (we don’t really know since this is all pretty new to us as humans, maybe it’ll be normal in a few hundred years that programming languages just need to die :woman_shrugging: )

I tend to think about things in terms of “sophistication == active refining simplicity” and “complication == active emerging conflict”… and “simplicity” as “achieving a goal with least resistance”. I think here the goal is for Rust to be sophisticated without being complicated. writing code is really a struggle between sophistication and complication, and its never ending.


My point is that these bad design decisions were entirely predictable, and could have been avoided with a tiny bit of experience and foresight. It’s just a matter of inspecting the history of other languages.

In my experience, most popular languages go through a life-cycle that goes something like:

  1. No templates, trivial APIs. Everybody is impressed at how lightweight and simple everything is. There are many convenience wrappers around OS concepts such as the POSIX or Win32 file descriptors wrapped in a convenient Stream class, hiding some of the 1960s legacy behind a thin facade. A half-arsed attempt at i18n is grudgingly included, but there is clearly an anglo-centric feel to the language. That’s okay, all the initial developers are in the western world, so you can get away with this. This is 1990s C++, C# 1.0, Java 1.0, and Go currently.
  2. That template itch just won’t go away, so it is hacked into the language. A lot of APIs are duplicated, such as IEnumerable vs IEnumerable<T> in C#. Legacy APIs like Stream are left byte-only, because it’s just too hard to fix it now. This is C# 2.0, Java SE5, early 2000s C++, etc…
  3. There’s a grudging acceptance that the rest of the world will refuse to learn English, so the i18n APIs are aggressively expanded. Now there’s two versions of the String APIs, one with the old defaults and one with the new comparison options. There’s usually several of each of of the date, time, and calendar types now, because the real world is complicated. Sometimes things just get shredded because an intermediate library hasn’t been updated to handle DateTimeOffset or whatever. Bad luck!
  4. Turns out templates are hard! They need all sorts of restrictions such as being constrained to value (copy) types, types that implement a particular API, and so forth. The C++ guys are still trying to work this out. Rust has had this since before v1.0 via Traits. <- You are here
  5. At some point someone realises that with the advances made in step #4, a lot of APIs can be rewritten to be vastly more elegant. “Obviously”, making things like Stream a lightweight synchronous wrapper around a byte-only file descriptor was a mistake, so now the entire language is slowly reinvented piece by piece, leaving an absolute mess of incompatible APIs next to a bunch of legacy garbage. Modern C++, dotnet core 2.x, and Java 10 are here now.

First, please read this article because it spectacularly illustrates my point: Pipelines - a guided tour of the new IO API in .NET

The dotnet core guys came up with this, and it’s great, but now 99% of the code out there is based on the old stuff, so this won’t be used much. Third-party libraries and large enterprise systems will continue to use Stream, directly or indirectly. For example, XmlReader will probably never get properly rewritten in terms of the Pipe API, because it would be a breaking change to make proper use of the efficiencies, such as allowing consumers to use Span<char> instead of heap-allocated String instances. It’s too late. The language was built up incrementally, and you’d have to make a new – incompatible – version to really make use of the features. (Just look at Python 2 to 3 or Perl 5 to 6 to see how easy that is!)

We know what a stream API should look like in any language that’s gone past stage #4. My point is that Rust essentially started at stage #4, its developers had all of this history to reference, yet std:io::Read looks very much like the C# 1.0 Stream API that is finally getting replaced. It inherently makes copies, it is inherently byte-based, and it mixes in unrelated string APIs that prevent a backwards-compatible upgrade to a template-based version. Etc, etc…

In fact, as an API the Rust version is objectively worse, to the point that I can 100% guarantee you that it must be eventually thrown out and replaced by something better thought out.

For example, the Rust Read trait forces UTF-8 on you, so even if you just want to read UCS-16 out of a binary stream, then you… have to go down a completely different API path! Err… wat? Even C# 1.0, back in 2002, got this right! It has a separate TextReader classes to wrap byte streams in a specifiable encoding. The underlying Stream class makes no such i18n assumptions. Remember… not everybody speaks English and not everything is UTF-8, no matter how hard we want this to be true!

This is what disappoints me about Rust. It got a running start compared to other languages, it was developed with decades of history to reference, yet it seems to insist on repeating the same mistakes…

PS: I’m not the only one with this point of view:

PPS: I take it all back, I just had a play with the C# Pipelines API, and it turns out that it is not template based, its data stream is always made up of bytes. I was tricked by seeing SomeClass<byte> in code samples, but that’s just code reuse. The API itself does not generalise to other value types such as char or whatever. Sigh…


A more accurate moniker is “difficult for beginners”. Once you know the language, you are as fluid in it as any other (even more so in comparison with some like C++ where you have to stop and look over your shoulder every now and then).


Note that I consider this a far lower “cognitive tax” than having to run the borrow checker entirely in my own brain like I do in C++. As a result I’ll at least try borrowing things (and .clone() if it gets awkward) in Rust where in C++ I’d just copy-construct from the get-go since it’s so hard to be sure I didn’t break something.

It’s certainly true that designing in a way that best leverages the checks is something that needs to be learned, and that some things (certain kinds of graphs seem to be the usual example) just aren’t an elegant fit for the model.

I’d be great to hear exactly what they were from them. This thread has a ton of things in it, from tiny to philosophical, so I suspect their list would be somewhat different.

1 Like

Some things can’t be changed now, so there’s no point in distressing about them. Some other things can be fixed or added with a deprecation. So my suggestion is to write down a very long list of the things you don’t like, remove the ones you believe are impossible changes, and open a separate RFC for each of them for the Rust 2018 edition (or where possible even for Rust 2015). And then be humble when people tell you some practical problems. Most ideas will be closed or shot down, but if even very few see the light in Rust 2018 you will have a positive and multiplicative impact on future Rust users :slight_smile:


I’m curious if you’ve been able to get over your std::io::Read gripe and look at Rust some more, beyond your initial post in this thread.

I also think it’s incredibly unrealistic to expect a language and/or its stdlib to be flawless, regardless of how many have come before. Doubly so if you actually intend for people to use it rather than sit in someone’s imagination.


Perhaps you could start an RFC and we could all iterate on it to create a “proper” Stream API for Rust? I think you’ve pointed out a lot of really good ideas and points that should be addressed. I pretty much agree with your analysis, though, I would not currently have had the foresight to so succinctly categorize the issues.

1 Like

Rust has many warts. Its feature-set does appear less cohesive and consistent when compared to some languages (C# comes to mind). There are countless other problems mainly due to its youth. Then there’s the borrow checker. So feeling negative emotions is almost a rite of passage for a Rust beginner. I don’t want to belittle your feelings, but in my experience once you get past this initial despair and when you get to coding for production instead of doing toy programs is when you come to appreciate what a life saver and how brilliant this language is. This is because Rust’s strengths which far outweigh its faults unfortunately become apparent only when you’ve done any real-world work in it. And that’ll perhaps forever be Rust’s curse.


C# is a very high bar, it’s one of the best designed languages out there (still, I think Rust is better for my usages).


I love Rust - let me preface with that.

Unfortunately, I think the tears at the seams (i.e. seeming incohesion/inconsistency) are visible at both the early/beginner stage and also at a later stage, although they’re for different reasons. I am very hopeful that, over time, they’ll be ironed out to a point where they’re barely noticeable.

That said, no language is perfect. Rust is doing something novel, certainly so for any language that can be called mainstream. I think it’s understandable that it’ll have some growing pains, both at the lang and stdlib levels. There’s just no way around it. I think the communities’ (and Rust core teams’) priorities align very well with mine (i.e. robustness, expressiveness, correctness to borderline pedantry, and performance).

Rust will definitely not be for everyone, just like no other language is universally praised or liked. The people that will like it are the ones holding the same core values as Rust and willing to put in the time to learn it, with all its quirks and idiosyncrasies.


Absolutely. I would the say the same about C#. That said, one thing that can be mentioned in Rust’s defense is that C# has GC which makes a lot of decisions easier. We only have to look at the state of the art prior to Rust when it comes to non-GC languages to appreciate that Rust is a huge improvement. That said (recursively), not all of Rust’s difficulty or unsightly parts stem from the memory-management challenge it’s set for it itself.


Yup. The rough edges don't really go away with experience. However, you kinda learn to live with them since you get so much in return.

I also happen to really like C#, and used to use it quite extensively. But, it’s also not perfect :slight_smile:. The bifurcation of reference vs value types is there, and there are some footguns with using value types. Some of you might remember how lambdas used to desugar in for loops, capturing the value only for the last iteration in some cases (that was fixed at some point). The .NET standard lib used to be extremely allocation happy and it was a challenge to write performant code. Although methods were sealed by default, classes weren’t which ought to have been the better default. C# made the same mistake as Java of having a volatile field keyword, which is completely backwards in today’s thinking - it’s not the field that’s volatile, but accesses to it (and each of those may have their own memory ordering requirements to boot). There was no good memory model for the language (not sure if there is one now, on par with say Java’s memory model). null is still present. Exceptions are unchecked, which is fine if you hate incorrect usage of Java style checked exceptions, but makes it incredibly difficult to write robust code. And so on.


It’s definitely not all, but it’s very close to it I think. Particularly if you generalize “memory management” to soundness. A lot of the difficulty is being a low level language trying to marry high level features while being sound at compile time. That’s a very hefty (and praiseworthy!) goal.


I think to call C# a really well-designed language is a bit of an overstatement. As far as I’m concerned (and I like both Java and C# for what they are) it is just Java with a little better support for value types. They frankly got it wrong with exceptions (as you mentioned). They got it wrong in how they handle “null” (as you mentioned). They got it wrong wrt to volatile (as you mentioned). It really is only a marginal, at best, improvement (and that is even debatable) over Java. I really can’t see much real advantage of C# over Java for most cases. Java tends to push as much as possible to libraries/JDK whereas C# tends to incorporate new language features more often, but, I really don’t see that one is necessarily that much better or worse than the other. I prefer Java exception handling over C# exception handling, but, I like the Rust way of error/alternative handling even better. I think Rust is getting A LOT Of things right, but, there is definitely room for improvement and the comments by the OP can help inform the discussion (even if they do, at first reading, come off a little snide or combative).


IMO, C# is a well-designed language. Is it perfect? No, as mentioned. But I don’t know any perfect language. I’ve not followed it too closely in the last few years, but I recall in the beginning there was nice consistency and “flow” to features added in version N and how they enabled something else in version N+1. There’s a lot right about C# if you don’t mind a GC/JIT/managed runtime.

To call C# “just Java with a little better support for value types” is … disingenuous at best :slight_smile:. I really don’t want to sidetrack this thread into Java vs C# (or Rust vs C#, for that matter), so I’ll stop here. But I’ve used C# and Java extensively, and their comparison ends right on the surface for me.