TE
테크에코
홈24시간 인기최신베스트질문쇼채용
GitHubTwitter
홈

테크에코

Next.js로 구축된 기술 뉴스 플랫폼으로 글로벌 기술 뉴스와 토론을 제공합니다.

GitHubTwitter

홈

홈최신베스트질문쇼채용

리소스

HackerNews API원본 HackerNewsNext.js

© 2025 테크에코. 모든 권리 보유.

Flattening Rust’s learning curve

438 포인트작성자: birdculture2일 전

36 comments

Animats1일 전
It&#x27;s like reading &quot;A Discipline of Programming&quot;, by Dijkstra. That morality play approach was needed back then, because nobody knew how to think about this stuff.<p>Most explanations of ownership in Rust are far too wordy. See [1]. The core concepts are mostly there, but hidden under all the examples.<p><pre><code> - Each data object in Rust has exactly one owner. - Ownership can be transferred in ways that preserve the one-owner rule. - If you need multiple ownership, the real owner has to be a reference-counted cell. Those cells can be cloned (duplicated.) - If the owner goes away, so do the things it owns. - You can borrow access to a data object using a reference. - There&#x27;s a big distinction between owning and referencing. - References can be passed around and stored, but cannot outlive the object. (That would be a &quot;dangling pointer&quot; error). - This is strictly enforced at compile time by the borrow checker. </code></pre> That explains the model. Once that&#x27;s understood, all the details can be tied back to those rules.<p>[1] <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch04-01-what-is-ownership.html" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch04-01-what-is-ownership.htm...</a>
评论 #43982619 未加载
评论 #43981587 未加载
评论 #43979460 未加载
评论 #43979907 未加载
评论 #43981313 未加载
评论 #43981064 未加载
评论 #43981720 未加载
评论 #43996196 未加载
评论 #43983156 未加载
评论 #43982074 未加载
评论 #43982747 未加载
评论 #43984730 未加载
评论 #43982249 未加载
评论 #43990363 未加载
评论 #43988460 未加载
评论 #43980199 未加载
8s2ngy1일 전
It took me a few tries to get comfortable with Rust—its ownership model, lifetimes, and pervasive use of enums and pattern matching were daunting at first. In my initial attempt, I felt overwhelmed very early on. The second time, I was too dogmatic, reading the book line by line from the very first chapter, and eventually lost patience. By then, however, I had come to understand that Rust would help me learn programming and software design on a deeper level. On my third try, I finally found success; I began rewriting my small programs and scripts using the rudimentary understanding I had gained from my previous encounters. I filled in the gaps as needed—learning idiomatic error handling, using types to express data, and harnessing pattern matching, among other techniques.<p>After all this ordeal, I can confidently say that learning Rust was one of the best decisions I’ve made in my programming career. Declaring types, structs, and enums beforehand, then writing functions to work with immutable data and pattern matching, has become the approach I apply even when coding in other languages.
评论 #43982573 未加载
评论 #43987358 未加载
评论 #43984521 未加载
jillesvangurp1일 전
Rust has a few big hurdles for new users:<p>- it&#x27;s very different from other languages. That&#x27;s intentional but also an obstacle.<p>- it&#x27;s a very complex language with a very terse syntax that looks like people are typing with their elbows and are hitting random keys. A single character can completely change the meaning of a thing. And it doesn&#x27;t help that a lot of this syntax deeply nested.<p>- a lot of its features are hard to understand without deeper understanding of the theory behind them. This adds to the complexity. The type system and the borrowing mechanism are good examples. Unless you are a type system nerd a lot of that is just gobblygook to the average Python or Javascript user. This also makes it a very inappropriate language for people that don&#x27;t have a master degree in computer science. Which these days is most programmers.<p>- it has widely used macros that obfuscate a lot of things that further adds to the complexity. If you don&#x27;t know the macro definitions, it just becomes harder to understand what is going on. All languages with macros suffer from this to some degree.<p>I think LLMs can help a lot here these days. When I last tried to wrap my head around Rust that wasn&#x27;t an option yet. I might have another go at it at some time. But it&#x27;s not a priority for me currently. But llms have definitely lowered the barrier for me to try new stuff. I definitely see the value of a language like users. But it doesn&#x27;t really solve a problem I have with the languages I do use (kotlin, python, typescript, etc.). I&#x27;ve used most popular languages at some point in my life. Rust is unique in how difficult it is to learn.
评论 #43986202 未加载
评论 #43983336 未加载
cyber11일 전
&quot;Safe&quot; Rust is generally a simple language compared to C++. The borrow checker rules are clean and consistent. However, writing in it isn&#x27;t as simple or intuitive as what we&#x27;ve seen in decades of popular systems languages. If your data structures have clear dependencies—like an acyclic graph then there&#x27;s no problem. But writing performant self-referential data structures, for example, is far from easy compared to C++, C, Zig, etc.<p>On the opposite, &quot;Unsafe&quot; Rust is not simple at all, but without it, we can&#x27;t write many programs. It&#x27;s comparable to C, maybe even worse in some ways. It&#x27;s easy to break rules (aliasing for exmaple). Raw pointer manipulation is less ergonomic than in C, C++, Zig, or Go. But raw pointers are one of the most important concepts in CS. This part is very important for learning; we can&#x27;t just close our eyes to it.<p>And I&#x27;m not even talking about Rust&#x27;s open problems, such as: thread_local (still questionable), custom allocators (still nightly), Polonius (nightly, hope it succeeds), panic handling (not acceptable in kernel-level code), and &quot;pin&quot;, which seems like a workaround (hack) for async and self-referential issues caused by a lack of proper language design early on — many learners struggle with it.<p>Rust is a good language, no doubt. But it feels like a temporary step. The learning curve heavily depends on the kind of task you&#x27;re trying to solve. Some things are super easy and straightforward, while others are very hard, and the eventual solutions are not as simple, intuitive or understandable compared to, for example, C++, C, Zig, etc.<p>Languages like Mojo, Carbon (I hope it succeeds), and maybe Zig (not sure yet) are learning from Rust and other languages. One of them might become the next major general-purpose systems language for the coming decades with a much more pleasant learning curve.
评论 #43982560 未加载
GenshoTikamura1일 전
&gt; Stop resisting. That’s the most important lesson<p>&gt; Accept that learning Rust requires...<p>&gt; Leave your hubris at home<p>&gt; Declare defeat<p>&gt; Resistance is futile. The longer you refuse to learn, the longer you will suffer<p>&gt; Forget what you think you knew...<p>Now it finally clicked to me that Orwell&#x27;s telescreen OS was written in Rust
评论 #43983002 未加载
toprerules1일 전
As a systems programmer I found Rust relatively easy to learn, and wonder if the problem is non-systems programmers trying to learn their first systems language and having it explicitly tell them &quot;no, that&#x27;s dangerous. no, that doesn&#x27;t make sense&quot;. If you ask a front end developer to suddenly start writing C they are going to create memory leaks, create undefined behavior, create pointers to garbage, run off the end of an array, etc. But they might &quot;feel&quot; like they are doing great because there program compiles and sort of runs.<p>If you have already gotten to the journeyman or mastery experience level with C or C++ Rust is going to be easy to learn (it was for me). The concepts are simply being made explicit rather than implicit (ownership, lifetimes, traits instead of vtables, etc).
评论 #43987347 未加载
评论 #43989311 未加载
TheChaplain1일 전
My problem with rust is not the learning curve, but the absolute ugliness of the syntax. It&#x27;s like Perl and C++ template metaprogramming had a child. I just can&#x27;t stand it.<p>Python is my favourite, C is elegance in simplicity and Go is tolerable.
评论 #43982379 未加载
评论 #43989277 未加载
评论 #43982172 未加载
mprovost1일 전
One approach that I don&#x27;t see often enough is to focus on learning a subset of the language first. For example, in my own book on Rust, I skip teaching lifetimes. It&#x27;s not necessary to write functions with lifetimes to build quite a few fully functioning programs. The same with macros (although the fact that their signatures are opaque doesn&#x27;t make it easy for beginners). On the other hand, I disagree with the advice to rely on copy() or clone() - it&#x27;s better to learn about borrowing from the beginning since it&#x27;s such a fundamental part of the language.
cadamsdotcom1일 전
Rust is wonderful but humbling!<p>It has a built in coach: the borrow checker!<p>Borrow checker wouldn&#x27;t get off my damn case - errors after errors - so I gave in. I allowed it to teach me - compile error by compile error - the proper way to do a threadsafe shared-memory ringbuffer. I was convinced I knew. I didn&#x27;t. C and C++ lack ownership semantics so their compilers can&#x27;t coach you.<p>Everyone should learn Rust. You never know what you&#x27;ll discover about yourself.
评论 #43996710 未加载
评论 #43979674 未加载
评论 #43980750 未加载
评论 #43982334 未加载
评论 #43979578 未加载
baalimago1일 전
&gt;For instance, why do you have to call to_string() on a thing that’s already a string?<p>It&#x27;s so hard for me to take Rust seriously when I have to find out answers to unintuitive question like this
评论 #43981713 未加载
评论 #43981709 未加载
评论 #43981621 未加载
评论 #43981417 未加载
评论 #43981663 未加载
评论 #43982610 未加载
评论 #43981274 未加载
9999000009991일 전
The only way I think I’ll learn rust is if there’s a surge of job opportunities paying 300 K and up which require it.<p>The potential is definitely there, it looks like it might compete with C++ in the quant .<p>But we already have ocaml . From Jane Street, at least for me if you’re going to tell me, it’s time to learn an extremely difficult programming language, I need to see the money.<p>So far my highest paid programming job was in Python
ants_everywhere1일 전
A learning curve measures time on the x axis and progress on the y axis.<p>A flat learning curve means you never learn anything :-\
评论 #43979525 未加载
评论 #43979482 未加载
评论 #43979923 未加载
评论 #43979955 未加载
评论 #43983315 未加载
评论 #43979571 未加载
评论 #43980422 未加载
jmull1일 전
I&#x27;m not sure there are many cases where I would choose rust. I&#x27;m open to it. I just think in any given situation there would most likely be a better option.<p>Perhaps it will become prevalent enough that it will make sense in the future.
评论 #43985593 未加载
评论 #43985214 未加载
评论 #43984813 未加载
评论 #43986622 未加载
doug_durham1일 전
This reads like a list of symptoms of what&#x27;s wrong with the ergonomics of Rust. This is not to bash Rust. It has its uses. But you need to balance what you are sacrificing for what you are getting.
writebetterc1일 전
Ownership and lifetimes are arguably not about Rust, but about how we construct programs today. Big, interdependent, object graphs are not a good way of constructing programs in Rust or C++.
the__alchemist약 24시간 전
I seem to have eased into a rust programming style that dodges these, perhaps at the cost of some optimizations. Using the first example, for example (The article suggests this): Don&#x27;t return an `&amp;str`; use those for transient things only like function parameters; not for struct fields or returned types.<p>I&#x27;m starting to wonder what I&#x27;m missing out by doing this. Not addressed in the article: Any tips for using the more abstract features, like Cow etc? I hit a problem with this today, where a lib used Cow&lt;&amp;str&gt; instead of String, and the lifetime errors bubbled up into my code.<p>edit: I found this amusing about the article: They demo `String` as a param, and `&amp;str` as a return type for triggering errors; you can dodge these errors simply by doing the opposite!
评论 #43987752 未加载
评论 #43987527 未加载
评论 #43987394 未加载
ramon1561일 전
These replies mainly revealed to me the general response people have on being corrected. Its very easy to become a stubborn programmer after being in the industry for so long.<p>I&#x27;d advise these people to personally figure out why they&#x27;re so against compiler suggestions. Do you want to do things differently? What part stops you from doing that?
Meneth1일 전
Feels like a cult manual. &quot;Do all things our way! Don&#x27;t question anything!&quot;
评论 #43983131 未加载
评论 #43983870 未加载
Havoc1일 전
I thought it was quite manageable at beginner level…though I haven’t dived into async which I gather is a whole different level of pain
评论 #43979133 未加载
jamil71일 전
The whole learning curve seems overblown to me. You don’t need to grok every part of the language to start using it and being productive.
sesm1일 전
Is there a concise document that explains major decisions behind Rust language design for those who know C++? Not a newbie tutorial, just straight to the point: why in-place mutability instead of other options, why encourage stack allocation, what problems with C++ does it solve and at what cost, etc.
评论 #43984758 未加载
评论 #43980063 未加载
评论 #43979717 未加载
评论 #43979806 未加载
评论 #43982558 未加载
nmeofthestate1일 전
&quot;You will have a much better time if you re-read your code to fix stupid typos before pressing “compile.”&quot;<p>This is a strange one - I thought the rust compiler had famously helpful error messages, so why would I want to pore over my code looking for stupid typos when I can let the compiler find them for me? I am guaranteed to make stupid typos and want the computer to help me fix them.
评论 #43987820 未加载
评论 #43984999 未加载
Waterluvian1일 전
Write a CHIP8 emulator!<p>Bonus: do it with no heap allocation. This actually makes it easier because you basically don’t deal with lifetimes. You just have a state object that you pass to your input system, then your guest cpu system, then your renderer, and repeat.<p>And I mean… look just how incredibly well a match expression works for opcode handling: <a href="https:&#x2F;&#x2F;github.com&#x2F;ablakey&#x2F;chip8&#x2F;blob&#x2F;15ce094a1d9de314862abbe21416a2660ae97625&#x2F;src&#x2F;chip8.rs#L194">https:&#x2F;&#x2F;github.com&#x2F;ablakey&#x2F;chip8&#x2F;blob&#x2F;15ce094a1d9de314862abb...</a><p>My second (and final) rust project was a gameboy emulator that basically worked the same way.<p>But one of the best things about learning by writing an emulator is that there’s enough repetition you begin looking for abstractions and learn about macros and such, all out of self discovery and necessity.
评论 #43980773 未加载
mellosouls1일 전
Good article, thoughtful and well-written and (idioms aside) much of it applicable to learning other languages.
mdwhatcott1일 전
[flagged]
评论 #43992716 未加载
评论 #43980582 未加载
评论 #43981862 未加载
评论 #43981636 未加载
评论 #43981065 未加载
评论 #43979747 未加载
评论 #43981787 未加载
评论 #43981118 未加载
评论 #43982909 未加载
评论 #43981329 未加载
评论 #43980897 未加载
评论 #43980452 未加载
评论 #43980029 未加载
MasterYoda1일 전
What is it that make that rust is said to have steep learning curve compared to other programing languages (in the same category)?
评论 #43981714 未加载
评论 #43982848 未加载
CobrastanJorji1일 전
Regarding the first example, the longest() function, why couldn&#x27;t the compiler figure it out itself? What is the design flaw?
评论 #43979765 未加载
评论 #43980940 未加载
评论 #43979986 未加载
pjmlp1일 전
Traits are yet another way of doing the CS concept of interfaces, regardless of the author&#x27;s opinion.<p>Polymorphic dispatch on a set of known operations, that compose a specific type.
ajross1일 전
&gt; Use String and clone() and unwrap generously; you can always refactor later<p>At that point you might as well be writing Java or Go or whatever though. GC runtimes tend actually to be significantly faster for this kind of code, since they can avoid all those copies by sharing the underlying resource. By the same logic, you can always refactor the performance-critical stuff via your FFI of choice.
评论 #43980203 未加载
评论 #43981902 未加载
评论 #43981812 未加载
评论 #43980632 未加载
评论 #43980432 未加载
jokoon1일 전
Sorry, but it&#x27;s easier to learn basic C++&#x2F;C, and let beginner developers get lessons from a basic linter or clang-tidy for about the same result, for a fraction of the developer cost.<p>I want rust to be adopted and I believe companies should force it, but you will not get adoption from young developers and even less from senior C++ developers.<p>Not to mention rewriting existing C++ code in rust, which cost would be astronomical, although I do believe companies should invest in rewriting things in rust because it&#x27;s the right thing to do.
worik1일 전
Surrender! to compile<p>Weather the ferocious storm<p>You will find, true bliss
umajho1일 전
&gt; …. For instance, “a trait is a bit like an interface” is wrong, …<p>Wait. What&#x27;s wrong with this statement?
评论 #43984772 未加载
scotty791일 전
For me the most important thing about Rust is to understand that it&#x27;s a langue with value semantics. Which makes it completely different than every mainstream language you encountered so far.<p>Variable in rust is not a label you can pass around and reuse freely. It&#x27;s a fixed size physical memory that values can be moved into or moved out of. Once you understand that everything makes sense. The move semantics, cloning, borrowing, Sized, impl. Every language design element of rust is a direct consequence of that. It&#x27;s the values that get created, destroyed and moved around and variables are actual first-class places to keep them with their own identity separate from values that occupy them. It&#x27;s hard to notice this because Rust does a lot to pretend it&#x27;s a &quot;normal&quot; language to draw people in. But for anyone with experience in programming that attempts to learn Rust I think this realization could make the process at least few times easier.<p>It&#x27;s hard to shift to this new paradigm and embrace it, so in the meantime feel use a lot of Rc&lt;&gt; and cloning if you just need to bang out some programs like you would in any other mainstream language.
truth_seeker1일 전
Compared to other programming languages, Rust&#x27;s compiler and linters go a long way to implement best practices at build time.
dmitrygr1일 전
&gt; Treat the borrow checker as a co-author, not an adversary<p>Why would I pair-program with someone who doesn’t understand doubly-linked lists?
评论 #43979123 未加载
评论 #43979152 未加载
评论 #43979041 未加载
评论 #43980304 未加载
评论 #43980150 未加载
评论 #43982624 未加载
woah1일 전
Does anyone still have trouble learning Rust? I thought that was kind of a 2015 thing
评论 #43979518 未加载
评论 #43979158 未加载
评论 #43981227 未加载
评论 #43980244 未加载
评论 #43985955 未加载
评论 #43980144 未加载