5 ms·
It's easy. "Rust is better for safety than C because it makes it harder or impossible to make certain kinds of mistakes that are easy to make than C." "What k
by Espressosaurus 2y ago
It's easy.
"Rust is better for safety than C because it makes it harder or impossible to make certain kinds of mistakes that are easy to make than C."
"What kind of mistakes?"
"There are times when you need to acquire some shared resource. Let's say memory. In Rust, it's easy to ensure you return that memory when you're done with it. In C, it's easy to forget to return that memory when you're done with it. This is called a memory leak, and you might find that eventually there's not enough memory for other programs to run."
"What's memory?"
"Think of a program as a recipe you're performing. Memory then is like working space. Like your counter space in your kitchen. If you run out of counter space, you don't have room to chop up more vegetables or temporarily store your cooked meat or what-have-you. Maybe you ran out of counter space because you left last night's dirty dishes on it. Rust automatically puts the dirty dishes in the dishwasher. In C, you have to remember to do that yourself, and sometimes you forget to."
And so on.
There's an easy explanation as long as you're not expecting them to perform detailed analysis. And I'm not.
edit: eventually you'll get to your limit of simplicity, things like "what is fire?" and maybe you need to say "I don't know, let's find out together!" We all have limits to our expertise, after all.
- hurril 2y agoThis hinges on a thorough understanding of safety. It also does not even mention trading things off. Both of which are topics that will require further clarifications. And as it were: and so on.
- Espressosaurus 2y ago"Why doesn't everyone use Rust then?" "Because it turns out that people aren't using the language too much yet, and it makes some things that are easy to do in C, hard to do in order to keep the language safe. It's all tradeoffs." At some point the person asking is satisfied and that tangent ends. This is how conversation works. You aren't trying to teach a layman how to write production-ready Rust code, and they aren't interested in learning how.
- hurril 2y agoWhat does it mean for a thing to be hard to do in the context of different programming languages? Hard and easy here are extremely deep and complex subject matters. Is goto hard or easy, for example? The person is going to give up (or you are,) because you are not going to be able to just have this conversation for any meaningful length of time. This is a (bad) fantasy, and one that books sometimes attempt (that I hate) and some people fantasise this way. They are not going to Ask The Next Question because if they could do that, it would come from a position of already understanding in a sort of anachronistic way. (In that they already have your answer, yet still want it.) They lack intuition for all the new concepts, they have a bunch of false friends (to borrow from linguistics, in that they think they understand some of the concepts - but they are different concepts with the same or simliar names). If you are a good teacher, then I am sure you will be very successful in explaining, but it's just not happening quickly nor with just anyone.
- alexey-salmin 2y ago> what is fire Funny you ask, this was the most frustrating question in my childhood because no one could give a satisfactory answer of what exactly is the visible part of fire or whether it even exists as a body.
- mjburgess 2y agofire is a fundamentally organic phenomenon. you heat dry organic material until there's a gas-like emission of particles, these are then nearly instantaneous oxidised causing more light and heat. The emission of heat and light in this gas-like state ("plasma") then causes more emission and so on.
- jcynix 2y agoYou can burn certain metals (magnesium, sodium, sulfur, even iron (wool)) neither of which is "organic". So fire isn't a fundamentally organic phenomenon ...
- mjburgess 2y agoWell I meant several things with that claim, which is why, per the theme of the thread, you cannot summarise these matters in cute sentences. Fire is only possible in an atmosphere with extraordinarily high accumulations of oxygen on planets with an atmosphere, etc. The only known process to bring this about, as far as I know, is life. Generically, lighting is the 'original' fire on earth. But I take it the commentor was thinking more in their school days of the sustained sort of burning commonly called 'fire'.
- nanomonkey 2y agoWhile oxygen is the most common oxidizer, it's entirely possible to have combustion without it. Such as utilizing halogens.
- deleted 2y ago[deleted]
- mjburgess 2y agoI said python, not C. Answering the C vs. Rust question would be presumably easier, because the claim is true (ie., it doesnt rest on a misunderstanding) and the person asking is likely familiar enough with the relevant concepts. The person claiming Rust is safer than python is so whoely confused this 2min tap-dance isnt good enough. When you're dealing with people with a-bit-more-than-surface understandings, the main problem is their head is full of misunderstandings. It is these that can take hours, or years, to undo. To suppose otherwise is to suppose that all questions can be answered in a cute couple of setences. This is, indeed, the opposite lesson of expertise.
- Espressosaurus 2y agoI shifted it to C because I am intimately familiar with C's drawbacks. I don't have the same understanding of Python's drawbacks. And it's always about explaining to the target person's level of understanding. A layman isn't going to know the difference between languages and why pick one vs. another. That's a long digression. Explaining why to use Rust to a Python expert is a very different discussion. An expert can switch between explanations as required for the audience. Non-experts, in my experience, cannot tailor the explanation for the audience. They typically bottom out at a level that leaves them unable to meet the questioner in the middle. Hell, I've been the non-expert, especially when it comes to something like why a particular material was acting like a diode instead of not passing the signal or passing the signal intact. I can regurgitate that the half-rectified signal from the aggressor is bleeding into the signal of interest, but I can't tell you why. That's when I'll tell you to talk to the EE team for specifics on why, as well as what they plan to do to fix it.
- mjburgess 2y agoThe purpose of my choosing python is that the comparison is essentially a category error. Python's semantics, and that of all GC'd interpreted languages, make memory safety irrelevant.. there is no manual allocation of memory in the language. I chose this example as I assumed it would be clear and non-controversial enough to make my point, ie., I assumed most HN readers would appreciate that a person claiming Rust's memory safety model made it safter than an interpreted language would be a person clearly deeply confused about the meaning of any of these terms.
- AlotOfReading 2y agoNotice that you've shifted the parent's question from Rust vs Python to the entirely different discussion of Rust vs C.
- deleted 2y ago[deleted]
- bragr 2y agoIn my experience, very few people are able to articulate their lack of understanding with straight forward questions like "What's memory?", and that's before we get into cognitive blind spots. For example, you've completely skipped over what it means to aquire and free memory, so I'm not sure your explanation is as clear as you think.
- exe34 2y agoThey usually make several leaps of imagination from the lack of understanding to the question they actually ask.
- kloop 2y ago> What's memory? Room full of buckets. And each of those has 8 light switches in it. And on modern computers, the janitor keeps the buckets he's used most recently next to his desk.
- TheOtherHobbes 2y agoThat's not an explanation, it's a description-by-analogy. If you think they're the same, consider why we need explanations at all if a description-by-analogy does the same job.
- ToValueFunfetti 2y agoIf someone thinks that they're the same, they probably don't already agree that we need both
- charleslmunger 2y ago>In Rust, it's easy to ensure you return that memory when you're done with it. This is a false explanation though - the problem is that memory is returned before you're done with it. https://doc.rust-lang.org/book/ch15-06-reference-cycles.html https://doc.rust-lang.org/book/ch15-06-reference-cycles.html This is extra-wrong as python has a garbage collector to break reference cycles. If giving a simplified explanation to a layman, it's important that if they repeat the explanation to another expert they don't hear "well that's wrong".
- kaba0 2y agoOkay, now do explain your paper’s result on this specific JIT compiler optimization that allows vectorization in certain cases? Like, I never got further than “computers can only execute and understand these few specific commands” before the layman party gave up. It is absolutely the same with plenty of mathematical topics (like, just the field of abstract algebra is absolutely mind boggling for almost everyone), physics, engineering, etc. Sure, one might bring up Feynman, but physics does have several topics that are easy to grasp - it’s literally about the world around us, and while a layman may not understand anything about the complex calculations about, say, an internal combustion engine, they will find it accessible due to the common ground.
- jdefr89 2y agoIronically Rust binaries link to libc.
- jiggawatts 2y ago> what is fire It is the light of other days. Feynman explains it here: https://youtu.be/N1pIYI5JQLE?si=APotFnCuOVKN0wc8 https://youtu.be/N1pIYI5JQLE?si=APotFnCuOVKN0wc8