292 points by speckx 4 days ago | 187 comments | View on ycombinator
bryanlarsen 4 days ago |
dabinat 4 days ago |
Instead of hoping you remember to check for NULL, Rust forces you to make a decision on how to handle the possibility of failure. Sure, you can still pick a bad decision (unwrap) but that is at least a specific decision and you can’t forget to do it.
You can take it even further with things like the newtype pattern. If you have lots of numeric IDs (project ID, user ID, etc) you can give them distinct types so you don’t mix them up.
So Rust taught me I can program defensively against my own brain, which sometimes gets tired or lazy or distracted.
edarchis 3 days ago |
JuniperMesos 3 days ago |
I wholeheartedly agree. I learned this lesson from learning Haskell, before I was even aware of Rust and before Rust had its 1.0 release. One of the reasons I was first excited about Rust in fact was precisely that it had a type system like that of Haskell.
abbefaria27 3 days ago |
sedatk 3 days ago |
jan_m_savage 3 days ago |
also, the author is a great communicator who genuinely wants to convey his points in clear prose, instead of showing off their intellect (which seems to be the case in some other blogs)
xeubie 4 days ago |
scotty79 3 days ago |
Yeah. When I tried to code fairly complex thing in Rust, when I was learning it, as I struggled, I simply noticed that I don't have the freedom I'm used to when it comes to at which level of my architecture I create objects or perform writes or who can pass a reference to whom. Once I learned I can't do it, and not that I just don't know how, suddenly things had their proper place. Yes, I don't have full freedom how I architect things here, but until the end of the project, I haven't found a single case where this restriction would lead to worse not better architecture. Once I leaned into it, as the author says, later I caught myself many times thinking, that C++ would happily let me do it which would result in a bug that would be super hard to find, that would probably burry the whole project.
kator 3 days ago |
I wrote this on my website in like 2014. I raise it because I think poorly understood problem is usually the reality, and using many languages over time you find ways of describing solutions to those problems and then learning to hone your understanding of the problem.
To me learning new computer languages forces you to think differently about a problem, if you really try to learn the language. I often just write all my side projects in whatever I am trying to learn for as long as it takes from me to learn it. Sometimes I stay with them for very long times if I enjoy them.
That said I look at computer languages like tools. Focus on the right tool for the job. More than once that tool is what others on the project know, because it still solves problems and it’s better that we have a shared toolset to work from.
zzzeek 3 days ago |
This is happening in Python land as well. now that type annotations are a normal everyday thing we are doing a lot of code generation. Of course I'm sure how Rust does it is much better integrated and "correct" and all that but the Python thing of generating functions/classes/etc. on the fly is not quite the sole choice anymore for various reasons, and pep484 and related are making static code generation more feasible.
throwaway81523 3 days ago |
xiange 3 days ago |
coldtea 4 days ago |
But reading this in 2026, when the entirety of the profession has changed (for better or worse) due to LLMs, seems strange.
Like someone writing how some new preservation method for making food last longer revolutionized how they manage their pantry, shortly after the invention of the fridge.
I like the post - it's just sad how many will not have these epifanies anymore, or they wont mean anything, and how many starting today would already just say "how quaint" and move on.
srean 3 days ago |
“A language that doesn't affect the way you think about programming is not worth knowing.” -- Alan J. Perlis.
mrblinky 3 days ago |
user20180120 3 days ago |
Guess it also applies to computer programming and hardware description languages.
undefined 4 days ago |
clench 3 days ago |
kinfish 3 days ago |
atulvi 3 days ago |
einpoklum 3 days ago |
I do want to push back on one point though:
> It also stops you from mutating data you're also reading elsewhere
No it doesn't. It stops you from mutating data _that it controls_ which you're also reading elsewhere _also within your Rust code_. But Rust presumes to be a systems programming language. In a system, there are other processes, other devices, interaction across the network, etc. Any of those breaks the integrity of Rust control, and forces you to contend with other independent entities which allocate or deallocate resources, write when they feel like it etc.
> making it impossible to stumble into whole classes of weird undefined behavior, especially with code that runs in parallel.
... and this is the half-false promise that belongs in marketing talk. Although if OP means "undefined behavior in the sense of "undefined by the language spec", that's a whole other kettle of fish.
wg0 3 days ago |
It's just another tool not a philosophy of life or benchmark of intellect.
madspaaskesen 3 days ago |
Uptrenda 3 days ago |
p-s-v 3 days ago |