Live data from Hacker News

What is Rust and why is it so popular?

stackoverflow.blog

151–160 of 284 posts

Re: What is Rust and why is it so popular?

#151

Earlier quoted context omitted.

> that misbehavior has nothing to do with the semantics of Rust as a language. Macros are part of the language; they aren’t an external code generation tool. > The same would happen if you wrote (or generated) 100,000 lines of C in one function body Absolutely, but neither C nor C++ makes it easy to generate such code. Technically doable with C preprocessor, but it’s not easy. C++ templates don’t normally expand into…

People write code generators that emit C/C++ code all the time, and 10KLOC functions coming from such a generator isn't unheard of. The x86 instruction selector LLVM generates from tablegen is over 240KLOC, although that's emitted effectively as an interpreted table, so the actual code size of the function is much, much smaller.

You’re correct that it’s possible to trigger that performance issue without Rust.

However, it doesn’t happen with idiomatic C or C++ code. C macros are too hard to use for that. C++ templates are designed to expand into many small functions, as opposed to a single huge one.

It was Rust complexity leaking over into the LLVM IR.

Re: What is Rust and why is it so popular?

#152

Earlier quoted context omitted.

We have started doing our own optimizations too: https://blog.rust-lang.org/inside-rust/2019/12/02/const-prop... Your overall point is absolutely correct though. We couldn’t have done this without LLVM.

Can you comment on the current state of non-aliased related optimizations? The issue tracker is byzantine on that one and i can't tell if or to what degree those optimizations are now done.

They’re not on right now.

Re: What is Rust and why is it so popular?

#154

Earlier quoted context omitted.

OK, I will bite. If I had to come up with a case where Python is better than Rust, I would say with rapid prototyping and scientific computing. If you just want to try a few things out, python has faster development cycle and if you want to do some super clever math python has better library support. With a bit more mind stretching, I can make a case for Go with a bit more mind stretching. If you want to write a mass…

> If I had to come up with a case where Python is better than Rust, I would say with rapid prototyping and scientific computing. Scripting? I'm not gonna write a 50 LOC single-use script in Rust.

I do write a lot of Python and Bash scripts, even in my Rust projects. They're perfect for gluing together a build. But I'd add that as soon as I want an external dependency (often a more featureful command line flag parsing library), I usually RIIR.

Re: What is Rust and why is it so popular?

#155
post #126

Earlier quoted context omitted.

What is the complexity, and what are its costs? As an active user of Rust, I haven't seen the (adverse) complexity or its costs yet. It's worth pointing out that Rust combats more than undefined behavior. Undefined behavior is a category of bad things that Rust works to eliminate, but Ownership goes beyond eliminating UB, and eliminates a large swath of potential logic bugs.

Programming in Rust is complex, I'm not sure how can argue against that, it is not straight forward to do simple tasks because of how you need to organise your architecture with the borrow checker. Most people that starts using Rust get stuck on issues that you woudn't have with other languages.

> Programming in Rust is complex

Make a distinction between programming and the overall programmer experience. C++ is not a simple language and it feels like some of the the rules are arbitrary, vendor dependent, or for the same of backwards compatibility.

When programming C++ at scale you start dealing with manifest files. Different understanding of C++ (templates/precompiler? exceptions? std? the list goes on).

Rust on the other hand is mostly pleasant. Sometimes I have problems with cargo. However like C++ build systems made life legitimately miserable sometimes.

I'm really excited for Rust. I think that at some point it might replace large parts of the OS. I can imagine important parts of the internet (DNS servers, caching servers etc) running on raw hardware. Your OS eats too much of your perf.

You are right, some parts of Rust are tricky (still working out proc_macros) however you get a lot of power from these.

It also feels like the Rust team really thinks ahead.

Like C++ is still working on the Range type. Originally, it was supposed to be in C++03 but that didn't happen and here we are 17 years later still waiting.

You can say things like that the type system doesn't support higher kinded types and such. You are right and I think that at some point, Rust will get them, right now there are more important battles. Whoever manages to implement them will be crowned the king of Rust I'm sure.

Re: What is Rust and why is it so popular?

#156
post #153

I like Rust, however as usual the article fails short of mentioning Ada, and GC languages that share the same resource management capabilities as C++, alongside their GC.

I wouldn't want to mention any language I don't have experience with for the risk of mis-speaking. I also tried to minimize talking about any specific language where I could.

Re: What is Rust and why is it so popular?

#157
post #111
post #38

Earlier quoted context omitted.

I think that Rust's approach to safety -- soundly eliminate UB in safe code -- comes at the high cost of complexity. This affects how easy it is to write custom compilers (very important in the embedded space), but it is also not necessarily the best way to reduce bugs. For some, this cost is acceptable, and I'm sure some people may even welcome the high-level-looking code [1] that Rust and C++ support, but I think t…

You've been asserting this for a while now, without really describing what you mean by "Zig's approach." What features are you thinking of here, and why would we expect them do any better than existing tools in C++ (or even C)? For example, "modern C++" is also often described as having similar benefits to safety.

Zig's approach to safety is to optionally add runtime checks either in debug builds and/or in arbitrary code scopes even in product builds, rather than to try to soundly eliminate them. This means that the language can be drastically simpler. Some UB can escape this kind of unsound safety, but on the other hand the simplicity of the language makes the semantics of an expression easier to understand -- which may make, say, code reviews cheaper -- and may free up time for other kinds of assurance, be it through faster compilation, shorter development cycles, and possibly static analysis tools, that generally like simple languages.

Now, note that I am not saying that Zig's approach to safety is definitely better than Rust. Correctness is an extremely complex issue, with many factors, and it's hard to say with any certainty what works and why. My preference for Zig (which is largely hypothetical as Zig doesn't really exist in a meaningful sense yet) is because I personally value language simplicity and short cycles over what some call "expressivity", but as someone who is also very much interested in formal methods and software correctness in general, I am not convinced that Rust's complexity buys you increased correctness over Zig, and it may even be worse. So the tradeoff is simplicity vs. "expressivity", where correctness can go either way.

Re: What is Rust and why is it so popular?

#158
post #123

Earlier quoted context omitted.

Are you going to use Rust on a PIC12 with 32 bytes of data memory and max 256 code instructions? Of course not. Assembly is still king in this low-powered embedded class and will stay as such for the foreseeable future.

But the full quote is: "I doubt that we'll see it used for low-power/resource-constrained firmware, but lots and lots of embedded systems are now bulky Linux boxes with years of uptime, and I can see Rust making inroads there." There is a massive number of devices between an 8-bit PIC and a Cortex-A. Obviously you're not going to use Rust on a tiny PIC or similar, hell that architecture is outwardly hostile towards e…

Yeah, this segment (Cortex-M) is on the order of a billion devices shipped each year. With growth expected to stay high for years to come. Plenty of space for Rust to get adopted.

Re: What is Rust and why is it so popular?

#159
post #12

Earlier quoted context omitted.

I did an internet search for Rust jobs and it was near-zero. Would be nice but reality calls.

Rust is over the "100% hobbyist" phase, but it isn't still in the phase where you hire "Rust developers" verbatim. There's an important phase in between: Rust is being introduced in organizations as we speak, and some people that were originally hired for some other skills, develop in Rust they picked up because they were enthusiastic about it. I am in that position at the moment. We are a multi-language shop, and th…

I'm in the same spot. Given the large number of companies who are willing to state that they use Rust (https://www.rust-lang.org/production/users) without being able to find openings that are explicitly for Rust, I'd say you're right.

Re: What is Rust and why is it so popular?

#160
post #153

I like Rust, however as usual the article fails short of mentioning Ada, and GC languages that share the same resource management capabilities as C++, alongside their GC.

I wouldn't want to mention any language I don't have experience with for the risk of mis-speaking. I also tried to minimize talking about any specific language where I could.

Fair enough.

I just made the point, because from security point of view, we all have to gain no matter what safe systems programming languages get adopted.

It doesn't need to be Rust vs the others, in what concerns improving the current state of IT security.

For example, Nvidia is now adopting Ada/SPARK for security critical firmware.

Post reply on HN