TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

100 days with Rust: a series of brick walls

282 点作者 another大约 7 年前

32 条评论

seawlf大约 7 年前
As someone who has been programming in Rust for nearly a year, even for commercial purposes, this article is baffling to me. I've found the compiler messages to be succinct and helpful. The package system is wonderful. It's dead easy to get something off the ground quickly. All it took was learning how and when to borrow.
评论 #16660191 未加载
评论 #16660523 未加载
评论 #16660440 未加载
评论 #16663159 未加载
评论 #16660361 未加载
评论 #16663305 未加载
评论 #16661494 未加载
justinpombrio大约 7 年前
&gt; universally terrible documentation<p>Wait, what? Rust has what I consider the best documentation I&#x27;ve seen of any language. The docs explain things at a high-level, but concisely, and have numerous examples. The formatting is good, the keyboard navigation support is good, it&#x27;s well-linked, and it has convenient features like links to the source and the ability to collapse everything but method headers for easier browsing. And it&#x27;s extremely easy to add docs to your own project.<p>Maybe there are some dark corners filled with poorly documented unstable APIs that I haven&#x27;t seen?
评论 #16662171 未加载
评论 #16660721 未加载
dmix大约 7 年前
&gt; The wall is impassable until a point that you make a key discovery which lets you make your through. Often that discovery is a eureka moment – it felt impossible only hours before.<p>These moments are my favourite, or at least most memorable, parts of learning. Which is what attracts me to hard, important concepts because they tend to be the most rewarding once you begin to grasp it.<p>I&#x27;ll never forget when SICP&#x27;s connection between programming and abstraction started to really click, after much effort, and the way it blew my mind, despite having programmed for a couple years. Really grasping the fundamental concept took the whole experience of programming to the next level - and made learning other things easier like a rolling snowball.<p>The fact the author&#x27;s walls never got &quot;smaller&quot; is a real problem, that can be disheartening.<p>That said, brick walls aren&#x27;t always bad things. Although it&#x27;s often hard to tell whether it&#x27;s a reflection of a poor design&#x2F;structure of the thing you&#x27;re learning, or just the learning material, or the learner themselves. Then there is the question of &quot;necessary evils&quot; of steep learning curves which, who knows, might be required entry-fee for a truly great language or tool (see: Emacs&#x2F;Vim).<p>Haskell was much the same way for me. Each cliff I climbed had a new big cliff waiting. It got me into learning not just pure FP but also lambda calculus&#x2F;set&#x2F;category theory. It felt never ending. I ultimately never went &quot;all in&quot; with Haskell (maybe because of this) but what I did learn has been very useful in my non-Haskell programming elsewhere, so it&#x27;s not all for naught. But it was admittedly a hard and significant time investment which isn&#x27;t for everyone... nor necessary for being a productive programmer. But I don&#x27;t regret it.
SCdF大约 7 年前
I am currently learning Rust and I feel this intensely[1].<p>I really want to like Rust, but I feel like the way they cope with no GC (lifetimes, borrowing) fights me at every turn, and really simple situations in other languages[2] become these intensely painful situations. Every time you think you&#x27;ve worked out how to fix a problem you find while you&#x27;ve fixed that one you&#x27;ve actually created 2 more.<p>Want to have a data structure of variable size (eg a struct with an Vector in it)? You can&#x27;t do that, structs have to be fixed size. OK so I&#x27;ll make it a reference to a Vector. That&#x27;s great, but now you can&#x27;t have a factory function because the lifetime goes out of scope. OK so I&#x27;ll wrap my reference in a Box. OK that&#x27;s great but now your OTHER reference: a trait (because traits are also of unknown size) is complaining. OK I&#x27;ll wrap that in a Box as well. Sorry, you can&#x27;t wrap this trait in a box because before your trait requires implementors to implement copy because at one point you have to use the trait in more than one place and references break the lifetimes and--- <i></i>THROWS LAPTOP OUT WINDOW<i></i><p>I&#x27;m going to keep chipping away at it for a bit longer, but I can feel my interest waning.<p>[1] Except for the bad docs bit, I really like the docs, and the error messages are definitely earnest in their attempts to help you.<p>[2] that I&#x27;m familiar with, which are no languages that don&#x27;t auto-GC<p>-- EDIT --<p>To everyone taking the first line of my intentional rant paragraph and pointing out it works fine… you&#x27;re correct, I am mistaken! Let me paste the reply I made to the first person:<p>---<p>You&#x27;re absolutely right. What I really meant was that you can&#x27;t have Vec&lt;T&gt; where T is a trait without also wrapping that in a box, which for me in turn doesn&#x27;t work for a bunch of other reasons.<p>In any case, my point remains the same: it is very challenging-- at least for someone used to just creating data structures and letting GC handle it-- to build code that does what you want, and you spend large amounts of time &quot;fighting&quot; the compiler. I am OK if people wish to peg that on me being stupid or whatever, it doesn&#x27;t change the core point: it&#x27;s hard for new people to get into, and if you&#x27;re wanting there to be less Electron apps and more native apps things like Rust being easy to use seems important for that.
评论 #16660571 未加载
评论 #16660564 未加载
评论 #16660549 未加载
评论 #16660452 未加载
评论 #16661781 未加载
评论 #16660380 未加载
评论 #16660729 未加载
评论 #16660552 未加载
评论 #16663109 未加载
评论 #16669511 未加载
评论 #16660389 未加载
drbawb大约 7 年前
&gt;Even something as simple as abstracting a new helper function often turns into a veritable odyssey because getting type annotations right can be so difficult (especially where a third party library is involved).<p>This is a sentiment I can&#x27;t say that I share or even understand. You have a compiler doing inference, it will <i>tell you</i> what the types are if you ask?<p>A lot of times when I find myself writing something where I&#x27;m unsure of the concrete type -- I&#x27;ll just stick a bogus type ascription in the expression somewhere. Then I run `rustc` knowing full well that it will fail. Somewhere in the error will be a message of the form &quot;found &lt;x&gt; expected &lt;y&gt;&quot; and now I know what the inferred type is.<p>&gt;The horribly anti-user futures system, compiler messages generated by a misused macros that are second only to C++ template errors in how egregiously difficult they are to parse, universally terrible documentation and lacking examples, unstable APIs, type annotation hell, and so much more.<p>Given the author&#x27;s dig at the `futures` crate though, I have a feeling a lot of the verbosity in errors they are seeing is due to the extremely long chains of combinators that the futures crate encourages. I haven&#x27;t run into these errors myself since I&#x27;m avoiding async IO in rust until an `await` style abstraction becomes available. In my opinion: jumping into using an async library&#x2F;runtime that is undergoing heavy development is probably not the best place to start when it comes to learning Rust.<p>I think this is one thing that Go definitely got right: having concurrency baked into the language that encourages a &quot;syncrhonous-style&quot; of programming is absolutely the way to go for approachability. I&#x27;m not sure that I&#x27;d go so far as to call `futures` user-hostile, as the tokio devs are doing great work, but it certainly isn&#x27;t user-friendly yet.
评论 #16660272 未加载
评论 #16660464 未加载
评论 #16667077 未加载
vvanders大约 7 年前
I was following along until this:<p>&gt; universally terrible documentation and lacking examples, unstable APIs, type annotation hell, and so much more.<p>The docs in Rust are by far some of the best I&#x27;ve seen, without specifics it&#x27;s really hard to understand what issues he hit.
评论 #16659865 未加载
评论 #16659997 未加载
Dowwie大约 7 年前
I have been working with Rust, full time, for a little less than 100 days. Like the author, I also came from Python (I authored Yosai).<p>Unlike the author, I haven&#x27;t been hitting brick walls. I also have observed all of the warning signs that the futures bridge on the tokio highway is unfinished so I didn&#x27;t cross the barrier and still try to use it anyway.<p>Instead, I have been working on myriad other synchronous parts with great success. I&#x27;ve made substantial progress in this time largely due to the Rust community and --- the Eco system! Sure, I&#x27;ve had to build custom parts but there haven&#x27;t been showstoppers.
评论 #16660804 未加载
评论 #16664392 未加载
pcwalton大约 7 年前
I&#x27;m obviously about as far from the modal Rust user as one can get, but at this point the language has completely melted away into the background. I&#x27;m often tempted to write smallish scripts in dynamic languages, but even for those I frequently choose Rust just for the Cargo ecosystem. In particular I never see a reason to use C++ unless I&#x27;m contributing to a codebase that&#x27;s written in it.<p>It takes different programmers different amounts of time to get to this point, and I certainly believe we can do better to make it easy to get up to speed, especially when async I&#x2F;O is involved. But it does come eventually.
评论 #16665307 未加载
评论 #16664999 未加载
评论 #16663212 未加载
评论 #16662236 未加载
steveklabnik大约 7 年前
We&#x27;ve been putting a lot of work into making Rust easier to learn. A lot of that stuff is just starting to land now. Some of it is inherent, but some of it is also just rough edges. Including things that the author talks about here.<p>So, my message is, we hear you! We&#x27;re working on it. Might want to check back in in a few months.
dman大约 7 年前
Disclaimer: Am a C++ programmer<p>Watching from a distance I have to concede that from a safety, dynamism of the community and package management using cargo Rust has improved upon C++ in meaningful and measurable way.<p>However on the complexity of the language front, I wonder if Rust will also join C++ in the realms of &quot;too complex&quot; 10 years from now. Would love to get some Rust experts to weigh in here on their thoughts about managing complexity of the language long term and whether being a simple systems programming language is an end goal.
评论 #16662976 未加载
评论 #16661701 未加载
评论 #16662155 未加载
Analemma_大约 7 年前
I&#x27;m looking forward to the full article, because it&#x27;s nice to know that I&#x27;m not alone here. I too started learning Rust with great optimism, and had the same experience: I expected that things would be difficult starting out, but assumed it would get easier as I acquired more knowledge, and then it didn&#x27;t. Mostly this was for the same reasons as the author cites: Rust futures are incomprehensible, and there is rarely documentation to answer simple questions (one that I ran into the other day was &quot;How do I parse a string into a datetime in a particular timezone?&quot;, which took about an hour to answer, compared to the 60 seconds it would take in something like C#)<p>I&#x27;m saying this as a lover, not a hater. I really believe in the mission of Rust, and I really <i>want</i> to like it, but I realized that even after a few months of learning, it was still taking me orders of magnitude longer to accomplish things in Rust than in C# (or even C++), and I wasn&#x27;t finding the tradeoff worth it.
评论 #16659757 未加载
评论 #16659772 未加载
评论 #16659776 未加载
评论 #16659784 未加载
robotmay大约 7 年前
I&#x27;ve been learning Rust for a little while, and while I agree that it can be frustrating, it&#x27;s nowhere near as bad as trying to learn Haskell. I regularly get a friend of mine to explain things to me, because the documentation and community for Haskell are 90% incomprehensible to anyone who doesn&#x27;t have a comp-sci degree or a higher education in mathematics. Example: <a href="https:&#x2F;&#x2F;wiki.haskell.org&#x2F;Lifting" rel="nofollow">https:&#x2F;&#x2F;wiki.haskell.org&#x2F;Lifting</a>. It&#x27;s not that I don&#x27;t get the concept (after being given a much better explanation), it&#x27;s just that the Haskell community in particular really seems to struggle with communication. And I think that&#x27;s where Rust is actually in a good place for learning.<p>Rust has some confusing concepts, and it does feel like you&#x27;re fighting the compiler sometimes, but I can see what it&#x27;s trying to achieve and it&#x27;s improving very rapidly. I find that I can more-or-less stumble my way through it until I get where I want, as the documentation that is about is generally well-written, even if it doesn&#x27;t cover everything yet :)<p>And it&#x27;s kinda fun!
评论 #16660067 未加载
dpc_pw大约 7 年前
I think what happened here, is the author wanted to do something with futures and the whole frustration is comming from not understanding that Rust Futures are just not ready yet. The whole language and ecosystem has plenty of stuff in the pipeline to make them better.
weregiraffe大约 7 年前
This is a 100 sentences rant with 0 substances. Literally, there are no examples at all of any &quot;brick wall&quot;.<p>Why was this even posted here?
评论 #16659689 未加载
评论 #16659828 未加载
评论 #16659629 未加载
gnode大约 7 年前
I feel like a lot of difficulties people run into with Rust are because they&#x27;re trying to do things the &quot;right&quot; way. You can often make your life easier with liberal use of reference counted objects, instead of solving difficult lifetime constraints, but it doesn&#x27;t feel like the perfect way to do it. Often people are pursuing zero-cost abstractions to their detriment. They then compare the language unfavourably against languages where those zero-cost abstractions weren&#x27;t even an option.
评论 #16666557 未加载
szemet大约 7 年前
<i>&quot;getting type annotations right can be so difficult&quot;</i><p>I had the same experience. After getting lifetimes (more or less) this became my largest headache... I wish for stronger type inference and features like this: <a href="https:&#x2F;&#x2F;downloads.haskell.org&#x2F;~ghc&#x2F;7.10.1&#x2F;docs&#x2F;html&#x2F;users_guide&#x2F;partial-type-signatures.html" rel="nofollow">https:&#x2F;&#x2F;downloads.haskell.org&#x2F;~ghc&#x2F;7.10.1&#x2F;docs&#x2F;html&#x2F;users_gu...</a><p>I feel my productivity (and code quality) would increase a lot. For example right now I have to struggle so hard if I would like to write generic code, while in haskell that&#x27;s more or less the default thing (the compiler infers it) if I just omit type annotations...
greydius大约 7 年前
&gt; I don’t like how little time I spend solving the problems that are interesting to me.<p>Welcome to systems programming.
roadbeats大约 7 年前
PG had this comment about programming languages: The correct solution of a problem is the most simple solution. Just like in math, you can solve one problem in multiple ways, but the correct one is the shortest, beautiful looking one.<p>When I look at Rust, it gives the feeling &quot;could be simplified&quot;. Obviously it&#x27;s a new language and it comes with lots of cool stuff, but it looks ugly, doesn&#x27;t excite those who seek simplicity.<p>If I had the time to invest in learning Rust, I&#x27;d use that time for building something new with any language that makes me productive.
评论 #16662987 未加载
brabel大约 7 年前
Exactly my feelings. Interesting how some people claim a rather different experience. Rust was voted the most loved technology on StackOverflow, which is unbelievable to me.
评论 #16661351 未加载
评论 #16660731 未加载
评论 #16660515 未加载
jkarneges大约 7 年前
As a long-time C guy, it&#x27;s nice to see Rust as a modern replacement. But most of the time, such low level programming is not needed.<p>The popularity of Rust and its friendly hand-holdy docs almost don&#x27;t even make sense for what it is, to me anyway. I suspect it will end up frustrating many high-level developers.
zyxzevn大约 7 年前
The problem with Rust is that it is very hard to program interconnected graphs.<p>Basic Rust does not allow cyclic references, which means that almost every graph needs to use special tricks to make it work. These tricks are variants of reference counting. A trick that was copied directly from C++.<p>It feels like having to build a car with only a screwdriver and hammer. Each section of your graph needs to be managed separately. With non-safe rust or C++ you can put whole panels or sections on your car. And a garbage collector works like a robot: usually effortless.
评论 #16661238 未加载
评论 #16661635 未加载
评论 #16660698 未加载
valw大约 7 年前
This sort of feedback would much more helpful and credible if you added what sort of project you&#x27;re using Rust on, your technical background, and concrete facts (not just metaphorical opinions &#x2F; complaints) about what goes wrong. As it is, this article helps no one make informed technology decisions. See <a href="https:&#x2F;&#x2F;vimeo.com&#x2F;9270320" rel="nofollow">https:&#x2F;&#x2F;vimeo.com&#x2F;9270320</a>.
AndyKelley大约 7 年前
I have a similar story: <a href="http:&#x2F;&#x2F;genesisdaw.org&#x2F;post&#x2F;progress-so-far.html" rel="nofollow">http:&#x2F;&#x2F;genesisdaw.org&#x2F;post&#x2F;progress-so-far.html</a><p>This is why one of the main features of zig listed on the home page is:<p>&quot;Small, simple language. Focus on debugging your application rather than debugging your knowledge of your programming language.&quot;
评论 #16660392 未加载
encoderer大约 7 年前
I consider myself a good enough engineer, and I&#x27;ve picked up a lot of languages. Recently I built and launched a server agent for Cronitor. Going in I knew it needed to be portable and compile to an executable. I considered Go, Rust and C.<p>I decided to spend a day and build 3 versions of a basic Usage block to get a feel for each. I&#x27;d never written Go or Rust, and only passable C.<p>I did C first and then tried Rust. I gave up. It was too much of a learning curve for a ~3 mos project. I ended up using Go. I&#x27;ll write up a blog post soon, Go is not without challenges, but I&#x27;m comforted by blog posts like this to see that I&#x27;m not the only mortal here still challenged by Rust.
评论 #16665064 未加载
brandur大约 7 年前
Author here. I want to apologize a bit for the tone of this article — it was written from a place of frustration, and this part of the site is very much akin to a development journal — these are short articles without a lot of concrete facts that are not really intended for broad or comprehensive consumption. In no way is this meant to be an anywhere-near comprehensive critique on Rust.<p>I&#x27;ll quickly point out that Rust is my favorite programming language, even if reading this piece in isolation would give you the opposite impression. There are about a million things to like about it: The syntax, type safety, sober choices around language design, built-in documentation facilities, conventions, `rustfmt`, linting with `clippy`, toolchain management with `rustup`, community (in the sense of project management and organization), development momentum, ecosystem, and a whole host of other things are all downright <i>incredible</i>. Some of the people working around the core are undoubtedly some of the smartest throughout the entirety of professional software.<p>That said, I wouldn&#x27;t take back anything I wrote here because even when I read it back today with a much more optimistic place (I bypassed many &quot;brick walls&quot; that I alluded to since I wrote it), I still think it&#x27;s true. Months later, even after writing a lot of Rust, I often still don&#x27;t feel productive.<p>No language is perfect, and it&#x27;s probably healthy to have the occasional counterpoint to its fairly consistent positive press. I&#x27;ve spoken to people who don&#x27;t know much about the language and refer despairingly to the &quot;Rust Evangelism Strikeforce&quot;, which I think is largely internalized rationalization that what they&#x27;ve read is too good to be true, so there must some nefarious element at work. Rust really <i>does</i> deserve its good press, and hopefully the occasional dissenting opinion and subsequent discussion will help convince them of such.<p>IMO, Rust has a few existential threats — the one that I think most about is that despite being well passed 1.0 at this point, there&#x27;s a distinct lack of pragmatism around getting core features like concurrency nailed down and shipped. Futures and Tokio are widespread at this point, but the APIs are still changing, and the error messages that they produce are still quite awful. Even once they&#x27;re fully feature-complete and stable, they&#x27;re still not going to be very pleasant to use — you have to think really hard about how you&#x27;re doing future composition. Contrast this to a concurrency system like Go&#x27;s, where you can more or less pretend that you&#x27;re writing synchronous code, and let the runtime take care of the heavy lifting. I love how much careful thought and consideration is being put into the development of a cohesive concurrency model, but unless it can get to the point where it&#x27;s stable and far more user-friendly, people (like me) who are trying to use the language to build things are going to continue having a hard time.<p>In summary, Rust is awesome, the core team is awesome, and the development community is awesome. I&#x27;m confident that the usability problems it has today will be worked out.
评论 #16663020 未加载
评论 #16665630 未加载
isaachier大约 7 年前
I&#x27;m not sure how easy Rust claims to be... The main idea here is &quot; I love that Haskell-esque feeling where a compiling program is usually a working program.&quot; Rust will probably get easier, but it&#x27;s main goal is safety.<p>The main problem I have with a pure safety focus is that the warnings often feel like overkill for 99% of programs. For example, when gcc yells about comparing signed and unsigned ints, I find that there rarely is a true safety concern involved. I hope Rust is better than that.
评论 #16661084 未加载
评论 #16660244 未加载
评论 #16660162 未加载
weberc2大约 7 年前
I&#x27;ve been dabbling in Rust on and off since 2014, and this has always been my feeling. I thought my background in C++ would make things reasonably easy, and while I have little fondness for C++, it&#x27;s still easier to get things done than with Rust, which is not at all what I expected given my 4 years with the language.<p>There&#x27;s a lot to like about Rust, but it falls far short of the &quot;easy-as-Go&quot; promises made by many of its proponents.
评论 #16660447 未加载
评论 #16661675 未加载
jokoon大约 7 年前
The more I read about those new-wave languages, the more I end up thinking that the simple languages like python and C are the clear winners.<p>I started to learn about rust, but honestly it feels like it has the same design and features of ADA, in term of code correctness. It&#x27;s a great thing, but I still wonder if it&#x27;s really useful for everyone. Usually ADA was used in aerospace.<p>And I still believe C++ has a good future, of course as long as you keep using the good parts.
评论 #16665571 未加载
rayascott大约 7 年前
There are a few things in life you just should not do. One of them is jump from your only language experience being Python into an advanced language like Rust when you’re struggling to grok SQL.
评论 #16660819 未加载
评论 #16661222 未加载
评论 #16660632 未加载
评论 #16661389 未加载
EugeneOZ大约 7 年前
I knew people are different. But if somebody can say that Rust compiler generates complicated error messages, then I just can&#x27;t imagine how different people can be.
xliiv大约 7 年前
Rust is not for you, and better stick to something which you are good at it. Friendly advice :)
always_good大约 7 年前
You can spend a month or two and get used to the bulk of Rust out of raw exposure. After seeing the same compiler errors over and over, you start to pattern match and learn how to jiggle the handle to get what you want.<p>For example, have you ever accidentally passed &amp;Request across a thread boundary? The compiler explodes with UnsafeCell errors deep within the inner sanctums. It feels impenetrable for a while. You throw some clone() at it and whatever your go-to guesswork is. Then 30 minutes pass and you realize you just needed to pass Request instead of &amp;Request. And at the end of i you really haven&#x27;t learned much beyond &quot;I&#x27;ll try that sooner next time.&quot;<p>I think that&#x27;s the hardest part about Rust. It takes quite a bit of mastery to actually understand and work around the more difficult compiler errors, like one that seems to threaten the whole abstraction you were going for. But adding a `+ Send + Sync` somewhere suddenly fixes it and it&#x27;s not obvious why. It can feel very precarious.<p>Anyways, I think most of Rust&#x27;s issues are just tooling issues. For example, imagine being able to hover identifiers to see their scope shaded in and where they&#x27;ll get dropped -- instead of just error-message ASCII art. Or being able to hover something to see that it can do something because it implements this certain trait.