5 ms·
> "Clever" memory use is frowned upon in Rust. In C, anything goes. No, it does not. If Rust programmers don't have discipline in C, other people have. And do
by brwell 6y ago
> "Clever" memory use is frowned upon in Rust. In C, anything goes.
No, it does not. If Rust programmers don't have discipline in C, other people have.
And don't drag out some random CVE numbers again. These are about a fraction of existing C projects, many of them were started 1980-2000.
It is an entirely different story if a project is started with sanitizers, Valgrind and best practices.
I'm not against Rust, except that they managed to take OCaml syntax and make it significantly worse. It's just ugly and looks like design by committee.
But the evangelism is exhausting. I also wonder why corporations are pushing Rust. Is it another method to take over C projects that they haven't assimilated yet?
- mfru 6y ago> It is an entirely different story if a project is started with sanitizers, Valgrind and best practices. What are the agreed upon tools and best practices in the C community as of right now?
- gridspy 6y ago> The evangelism is exhausting. My best guess is that people who are "stuck" working in C or C++ wish they could use Rust at their Jobs. Or that others would make the leap and get over the learning curve.
- pjmlp 6y agoNot until it reaches the same level as Visual Studio, Android Studio, QtCreator, XCode, CUDA and SYSCL tooling for graphical applications and GPGPU. For anything else managed languages are a much more productive option, other than writing kernel and drivers.
- c-cube 6y agoWe get that you don't like rust. But it seems like a lot of people currently using C or C++ while like to use rust at work, and might disagree about the benefits of the language and tooling. I personally know a few friends in distinct domains who work on established C++ codebases and are in this situation. There are also a lot of people who do not use C or C++, but use a bit of rust because it's so much easier to write fast little tools with it. I'm in this category. I even use threads sometimes, and it's reasonably easy. A crop of new unixy tools in rust seems to indicate other people also think alike.
- pjmlp 6y agoQuite on the contrary, Rust is the ideal language to replace C and C++ where automaric memory option is a no go, like MISRA-C, kernel and device drivers. Liking a programing language doesn't make me blind to what use cases it actually makes sense to use it, I don't see nails everywhere.
- gridspy 6y agoI agree. I think you'll find that most rational advocates for any language agree that their favorite language is only strong in its subdomain. Any compiled language is more painful than a quick scripting one for quick projects where the project complexity is low and the language overhead doesn't matter. Rust is substantially more painful to get compiling (due to the borrow checker) and harder to debug (due to tool maturity) than C# or C++. It's much harder to use than Python. Every language has its place. But when you are investing the time to make an efficient, high performance program... or you have limited requirements like you said -- Rust becomes a great choice. Every langauge has its place. I'm just dreadfully excited that we have a new choice now to trade a bit more time interacting with compiler errors for high performance and stability -- when that makes sense.
- howinteresting 6y agoHave you ever had to deal with tail latency due to memory pressure on web or backend services? Command-line tools are also ideal for Rust because startup performance matters a lot there.
- pjmlp 6y agoYes, writing distributed systems since 1999. What was done in C, C++ and Tcl, I nowadays use Java and .NET languages. If we really need something low level that either Java or .NET cannot offer, a native library for a specific component will do, no need to throw the whole thing away and do one of those rewrite blog posts.
- howinteresting 6y agoTail latency due to memory pressure tends to be inherent to the nature of garbage collected languages with mutable state. This is not an issue if you have more RAM then the system needs, but often RAM is extremely scarce.
- pjmlp 6y agoGarbage collected languages also offer means to do C like memory allocation, it is matter to use the language features and FFI capabilities, but many just learn their stacks superficially and follow Rewrite in X trendy blog posts instead.
- howinteresting 6y agoThere is a very big difference between what particular environments offer in theory (yes, you can write object pools in Java and many high-performance projects use them) and the situation in practice (there are people who spend a large chunk of their professional careers doing JVM tuning). Idiomatic Rust avoids the situations which require JVM tuning experts. You can write a Rust service, put it into production and tail latency is very likely not going to be a problem at all. Now you may decide that needing the occasional services of a JVM tuning expert is better overall than ownership concerns being pervasive throughout a codebase, depending on the specifics. But do accept that the trade-off exists.
- p0nce 6y ago> I also wonder why corporations are pushing Rust. Recruiting.
- pjmlp 6y agoMost surveys place the use of static analysis tools at about 11%, and they all go back to early 80's. Some people are hard learners.
- im3w1l 6y agoI think it's simply the power of defaults. If it takes an extra step then a lot of people wont do it.
- sullyj3 6y agoC programmers like to talk about discipline, but no human is more disciplined than a compiler.
- ben0x539 6y agoC evangelism is exhausting too. Maybe we can stick to discussing the merits of each language instead of complaining about how people with differing opinions make us feel.
- up2isomorphism 6y agoActually I never see any occasion that a C guys jump into a well establish project and ask them to rewrite that in C. And TBH I rarely see other popular language did the similar things either, including very popular ones like python, Java or Go. And you even observe there is thing called "C evangelism" actually exists?
- ben0x539 6y agoYeah? Check out any very public discussion of Rust and to a first approxiation there's always gonna be someone talking about how we should all just be using C instead. It's also not hard to find instances in open source projects of people ascribing ulterior motives or brain damage or ineptitude or whatever to anyone using another programming language. They don't call it C-lioning for nothing :^)
- up2isomorphism 6y agoCan you give an example instead of just describing something rarely happened? For rust this is certainly the case, demonstrated by this thread and almost any other thread about rust, it is . TBH it is a pattern to see title "fastest xxx written in rust". C programmers do not have the tradition to ASK other people to write something in C, they WRITE something in C. That's the real difference here.
- creata 6y ago> It's just ugly and looks like design by committee. I don't think it's ugly because it's design-by-committee, I think they intentionally made it ugly so that it's familiar to C++ people. > I also wonder why corporations are pushing Rust. You said it yourself: undisciplined people can't write C without introducing memory-related bugs, and it's much easier to hire undisciplined people than disciplined people. > It is an entirely different story if a project is started with sanitizers, Valgrind and best practices. Do you have an example of a project that is (a) built in such a way, (b) large, and (c) has a good track record on memory safety?
- howinteresting 6y agoA tool that requires "discipline" from its users is strictly worse than a tool that doesn't. I want to be able to write code without having to be "disciplined" about how I access memory. Means I can be more "disciplined" about business logic.