Using Rust at a startup: A cautionary tale
Rust has an undeniably steep learning curve which can cause a productivity penalty for beginners. However, there are some statements in this article I simply can&#x27;t agree with based on personal experience. I&#x27;m using Rust to develop a few projects. At this stage, I would go for Rust for general development, irrespective of how useful manual garbage collection is. To put it in context, my other favourite language is Python.<p>&gt; Rust, though, one needs to learn entirely new ideas — things like lifetimes, ownership, and the borrow checker. These are not familiar concepts to most people working in other common languages, and there is a pretty steep learning curve, even for experienced programmers.<p>Rust&#x27;s borrow checker system doesn&#x27;t exist in isolation. It&#x27;s designed to avoid problems that can occur with computing and memory model of programming - things like call stack frames (esp constant size), heap memory and other resource management, concurrency paradigms, etc. These are just the tip of low level computing models. There are things like cache coherence that Rust doesn&#x27;t address directly. These are concepts that programmers must know if they want to do: a) Low level programming b) High performance programming. The problem raised by author may partially belong to the second category. Even if it is not, programmers should probably learn these, because they are likely to face such problems at some point and may gain from that knowledge.<p>There are two ways to learn the borrow checker rules. The first is to start with the rules itself. It&#x27;s going to appear rather convoluted. The other approach is to understand the machine&#x2F;memory model that I mentioned above first. Once you do, the rules are going to make much more sense - especially in the context of specific error messages during coding. These days, I&#x27;m able to connect every single error message that I see to some potential memory or concurrency problem, even though they are the result of some seemingly convoluted but simple borrow checker rule.<p>&gt; Despite being some of the smartest and most experienced developers I had worked with, many people on the team (myself included) struggled to understand the canonical ways to do certain things in Rust, how to grok the often arcane error messages from the compiler, or how to understand how key libraries worked (more on this below).<p>There were dozens of errors that I made today that were easily understood just by a glance at Rust&#x27;s error messages. The help messages that accompany these error messages are often the solution that I needed. Even otherwise, the error messages point out potential low-level bugs as I mentioned above - allowing me to make proper corrections. This may just be anecdotal. What is not anecdotal is that the Rust team reworked the error messaging early in the project&#x27;s life to make it that way. It&#x27;s generally accepted that Rust&#x27;s error messaging is top-notch. I find it disrespectful to all those early endeavors to call it arcane. Perhaps it&#x27;s a good idea to try to learn those error messages. There is an entire index of errors with detailed explanations [1].<p>&gt; We started having weekly “learn Rust” sessions for the team to help share knowledge and expertise. This was all a significant drain on the team’s productivity and morale as everyone felt the slow rate of development.<p>Perhaps this is the wrong way to approach the problem. The thing that may need learning is type theory. Type theory is often too esoteric with a theoretical mathematical approach. Perhaps we need an introduction to it that encourages people to see a bunch of bits as a storage for data with a particular meaning (the type). Next step would be to how to track types using software (type system) and then extend the idea all the way to include constant-size stack frames, generics, polymorphism and lifetime tracking.<p>&gt; Libraries and documentation are immature<p>Library ecosystem is still growing - especially async programming. But documentation support is a first-class feature of Rust&#x27;s language ecosystem. I find myself writing documentation much more often in Rust than with other languages. It&#x27;s also equally easy to browse the documentation of the language, stdlib and other libraries. Sections are marked out clearly and navigation is well thought-out. Every search of a feature or API takes me through half a dozen links to the final target in a matter of minutes, if not less. It&#x27;s a good investment to learn browsing technique for documentation in any language.<p>&gt; Rust makes roughing out new features very hard<p>Somehow, my experience doesn&#x27;t match here either. I use the same technique for trying out new features in both Python and Rust. Create a scratch project for each experiment. A single project may take up to a dozen such scratch projects. It&#x27;s marginally easier in Rust than in Python, mainly because project management is another first-class feature of Rust tooling.<p>But what&#x27;s really remarkable about Rust compared to most other languages I&#x27;ve encountered is that Rust&#x27;s discipline gently nudges the scratch project to a proper design. By the end of the scratch project, the experimental code is often in a good enough state to be directly integrated into the main project. It&#x27;s amazingly friction-less to integrate integrate external code into the main project.<p>I wouldn&#x27;t blame the author for having a very different experience as mine. But I sure would like to know what makes Rust &#x27;click&#x27; for some, but remain a tough nut to crack for others.<p>[1] <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;error_codes&#x2F;error-index.html" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;error_codes&#x2F;error-index.html</a>