5 ms·
Can it be replaced with Rust nowadays? Is it low-level enough? Or borrow checker and lifetimes defeat the whole purpose?
by kovrik 9y ago
Can it be replaced with Rust nowadays? Is it low-level enough? Or borrow checker and lifetimes defeat the whole purpose?
- oconnor663 9y agoMy guess is that for this author's purposes, Rust is in the same place as C++. It can do the low level things, but you tend to spend more of your time working with higher level libraries that hide the nuts-and-blots details like allocation.
- pcwalton 9y agoRust libraries don't really hide allocation any more than modern C libraries do. (And if you aren't using modern libraries for stuff like string handling in C, you should be.)
- notriddle 9y agoIsn't the point of this whole argument about avoiding abstraction?
- pcwalton 9y agoI don't see any way in which string.h is less abstract in the "close to metal" sense than a real string or vector library (or Rust) is. The standard C library offers abstractions, just poor ones.
- kibwen 9y agoNot sure why this is being downvoted. Whether or not anyone out there likes Rust, dislikes Rust, or is completely apathetic to Rust, we can unanimously agree that the standard string-handling routines in C are quite poor. This isn't a controversial statement.
- mwcampbell 9y agoWhat modern C libraries do you have in mind?
- sreque 9y agoFor teaching purposes in a university I don't know if rust would be better or not. Keep in mind that the goal isn't necessarily to learn C the language; it's to learn enough of the core language to explore things like: * How the code is executed on modern hardware and operating systems. * How various language features might be compiled to assembly * Memory layouts for things like stack frames, how a simple heap allocator might work, array layouts, layouts for other structures like linked lists, etc. * The relative cost of various operations and how to write code that is cache friendly. * How debuggers generally work and how to debug code. Could these things be taught equally well or better in an undergraduate seeing using rust? Honestly I don't know; I know very little about Rust. I can say that I think C++ is a worse language for this purpose because of the language's complexity and because of features that aren't well suited for the above purposes. I have heard, for instance, that's it's actually very difficult in rust to write a linked list without dropping to unsafe code. I would consider this a bad thing for the above purposes.
- kqr 9y ago> * How the code is executed on modern hardware and operating systems. Does anyone know this at this point? With pipelining, out of order execution, vectorisation, register renaming, speculative execution, buffered micro-op fusing and what have you, it's very hard to say general things about how the code executes on the actual hardware.
- yjftsjthsd-h 9y agoPerhaps, "Understand the model of how code pretends to be executed"? Pipelining, etc. are meant to produce the same results as the older/simpler systems. You need to understand that that's not quite reality anymore, but as a basic model it's fine.
- kqr 9y agoSure, but at that point you are content with learning "the x86 virtual machine" -- and is that fundamentally different from being content with learning "the Java virtual machine"? I'm arguing that it's a matter of degree, not of kind. People make it seem like it's the latter.
- GirlsCanCode 9y agoMaybe for gay people.