Live data from Hacker News

What is Rust and why is it so popular?

stackoverflow.blog

131–140 of 284 posts

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

#131

Earlier quoted context omitted.

The key is in another comment on this thread: > Lots of these things that look like syntax problems are in fact design problems surfaced by the compiler. A lot of people are finding value in the rules Rust provides. This is irrespective of domain. The strict compiler helps you refactor code in ways that less strict languages don't. You still can do it, of course, you just have a lot less help. The trick is, is the in…

I think this is misplaced causation. Don’t discount the fact that a significant number of programmers just like novelty and like Rust because it’s new in the same way Haskell is new to a Java dev. That said, Rust’s domain does seem wider than just systems programming. It has the right abstractions to be suitable for (edit: some ) higher level things like web apps. Personally Rust is turning into what I was assuming a…

> because it’s new in the same way Haskell is new to a Java dev

Do you have any hypotheses about why we don't see as much publicity for Haskell then?

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

#132

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…

For massively parallel even with async, I still think Go is better than NodeJS. I still don't know how to do bounded parallelism in NodeJS but really easy in Go.

https://github.com/caolan/async/blob/master/lib/internal/eac... - this is the code the async Node lib uses for every "(X)Limit" function to limit the number run at once.

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

#133

Earlier quoted context omitted.

I think you're asking rhetorically, but just in case: 1. Rust-the-language doesn't know anything about allocations, so strictly speaking, it cannot. Furthermore, without a GC, it's unclear how it could in the first place, given that a compaction would invalidate all pointers to that memory. 2. Certainly not to the same degree as the JVM, given that there's nothing inherently to inspect, like there is in languages wit…

> Rust-the-language doesn't know anything about allocations AIUI, Rust knows more about allocations than it should, since it's still limited to a single global allocator, and Box (which relies on that global allocator) is implemented via compiler magic and cannot be supplemented by equivalent library code. If Rust supported "pluggable" allocators in some fashion, fancy features (including heap compaction, although I…

> If Rust supported "pluggable" allocators in some fashion

It's coming, but it's still unstable and being actively developed

- https://github.com/rust-lang/rust/issues/32838

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

#134

Earlier quoted context omitted.

Are you familiar with C++? That example is roughly equivalent to: #include #include #include int main() { std::string name { "Vivian" }; auto nickname = std::string_view { name }.substr(0, 3); name.clear(); std::cout which will happily compile, but whose behavior is undefined.

Is the behavior undefined because std::string makes a deep copy of the string? I thought 'Vivian' would be placed in read-only memory and as long as you don't modify it, you can hold read-only references to it.

Yes, `std::string` owns its own copy of the string in typical implementations (as does Rust's `String` type).

`std::string_view` references that copy. `std::string::clear` destroys it, leaving the `std::string_view` dangling.

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

#135
post #104
post #80

Earlier quoted context omitted.

> As someone who never much got into systems programming, Rust is a breath of fresh air. I think that's part of the problem :) Because Rust looks high level it appeals to people used to high-level programming. But once you get into systems programming, the issues are different from high-level programming, and you're less happy to pay for features that solve other problems. What I'm saying is, obviously, a matter of t…

Part of the problem is that "systems programming" is an overloaded term that means a number of different things. Is writing a web browser "systems programming"? What about a CLI utility like grep? Kernel module? Bare metal on a STM32? Depending on who you ask most of those will get both a yes and a no answer. On a related note, some language are more or less suitable for each of those. Can you write an OS in Java? Ye…

> If you're doing anything higher level than kernel programming, Rust is just as viable as anything else

I don't think so because it suffers from the same limitation that all low-level languages have, which is that API clients need to be aware of implementation details. Rust sometimes makes that propagation of leaked information automatically via the type system, but internal implementation details -- how allocated memory is managed, whether a target is a subroutine or a coroutine, whether an argument is passed at runtime or compile-time -- still leak in a viral way. It's just that Rust and C++ can look high-level, but they don't behave like high-level languages. But Rust is great for those low-level programmers who like this high-level style and are willing to pay for it.

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

#136

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.

I don't know the current state, but I hang out in the Zulip room dedicated to the work on the optimizations

- https://rust-lang.zulipchat.com/#narrow/stream/189540-t-comp...

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

#137
I like the fact that Rust has a set of libraries (crates and the standard library) that provide a lot of the features that you end up re-inventing if you stick with C. Even C++ is pretty fractured in this regard.

A lot of why this is hard in C/C++ is memory management. Even if you had a package manager it would be hard to compose libraries together unless they were designed together (like boost for C++).

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

#138
post #102

Earlier quoted context omitted.

> None of the Rust complexity leaks over into the LLVM IR it generates The leakage even triggers performance issues in compilers: https://users.rust-lang.org/t/5-hours-to-compile-macro-what-...

No, that's not "Rust leakage", because that misbehavior has nothing to do with the semantics of Rust as a language. That's the effect of some non-optimized function-scope-level pattern-matching substitutions that LLVM is applying, as applied to the user's very large function body. Quoting a reply in that same thread: > LLVM is not good at big functions, I have seen this before as well. One of the functions you are ge…

> 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 100k lines functions either, they can easily expand into 100k small functions.

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

#139
post #34

Over the last couple of months I've been slowly, but steadily playing with Rust. I work on embedded systems and while it's gaining traction only slowly, it feels to me reasonably likely that we'll be seeing non-trivial applications in the next 8-10 years. 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, an…

Yeah, some of the nice things about Rust aren't immediately obvious. Professionally, I use Rust for a few specific things:

1. Rust is surprisingly great for making cross-platform CLI tools and shipping static Linux binaries. Everybody can just install a single executable and they're ready to go. (Go is good at this, too.)

2. Rust is great for anything where I ask, "How big a cluster do we need for this?" I get roughly the same speed as C++, except there are far fewer footguns. And I can add threading support to existing code in an afternoon, and I can expect it to just work.

3. Rust's very new async support is powerful in some very interesting ways, and I have a couple of programs that it has worked beautifully for. (I'm working on an upcoming open source release of one of them.)

4. Rust's algebraic data types (aka "enum" and checked "match") are a joy for any software involving lots of special cases and complex logic. I think every typed, high-level language should steal this feature.

However, I have mixed experience using Rust for business logic. Yes, item (4) above does help with business logic. But business logic changes a lot, and it needs to be accessible to many developers within an organization.

So on my recent team projects, Rust often winds up doing the heavily lifting. But the rapidly-changing business logic will often get deferred to a GCed language. So far, this is working nicely.

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

#140

Earlier quoted context omitted.

> To me the Rust community seems to want to argue that everything should be rewritten in Rust I haven't seen this. At most, I've seen the push for rewriting important libraries where security is a core issue in Rust. I don't blame them. I'm tired of C/C++ being used everywhere because of performance, leading to the current-day situation of so much fundamentally unsafe code running the world.

I'm involved in a couple of github projects where we have had drive-by "hey, rewrite your project in Rust" PRs. Obviously not official or anything, but never seen anything like that for any other language.

Oh, back when Java first came out, Sun themselves were pushing this ("Rewrite it in Java!") line in spades. The hype train was unbelievable back then.
Post reply on HN