Live data from Hacker News

What is Rust and why is it so popular?

stackoverflow.blog

261–270 of 284 posts

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

#261

Rust is a great language if you use for what was intended, system programming and as safe substitute of C and C++. But it's not the answer of everything, to me it's nowadays abused in a lot of projects, there are instances of project where using Rust not only doesn't make a lot of sense but also can be slower than another languages, there are cases where Go is better, other where Node.js is better, other where Python…

> 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.

There is no such language as C/C++. You and I are tired of C being used where using a more powerful, safer language would also be faster. Rust could be that language, but C++ is another, and much more likely to still be known in ten years.

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

#262

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.

Yes, Rust has the potential to be faster than C, or even C++. But the compilers' implementations of such optimizations are far too buggy to turn on.

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

#263
post #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++).

I see that you have no experience with C++ in the past decade. There has been no fragmentation in C++ resource management since C++11.

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

#264
post #235

Earlier quoted context omitted.

A single construct does the work, or most of the work, of generics, value generics, const fn, traits, attributes (although I expect some form of attributes might be added to Zig) and macros, and it does so without type-level programming or macro-level programming, both their own mini-languages. A kludge is in the eye of the beholder, but one is simpler than five or six.

Rust has procedural macros too. And they're not a separate "mini-language" like the C++ template hacks, they just use Rust itself, except with a phase separation involved since they run at compile time.

As someone who is using procedural macros in my crates: they are nowhere close to as powerful yet as Zig's compile time evaluation. For example they cannot be used in expressions in stable Rust without ugly hacks yet, and the tools for generating the new AST are quite clunky and hard to write fast code for.

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

#265
post #258
post #254

Earlier quoted context omitted.

> I can just as easily split comptime into In Rust, generics, macros, traits, compile-time evaluation are different constructs with drastically different syntax (and generics and value generics are different features, implemented at different times, but I can accept them as a single construct). > It has no way to constrain a comptime type argument (traits) It does: introspection, just as Clojure can constrain argumen…

> ... generics, traits ... Again, these are just as much a single feature as Zig comptime. Traits are like comptime types, or else (closer to what Zig does) comptime type variable introspection. > You'd get similar compile-time errors as you would get, at runtime, in, say, Clojure or Python. Exactly- you're not writing plain Zig, you're writing a Zig-adjacent dynamically typed language with new ways to do almost ever…

You're looking at this differently from me. The way I see it, Zig is not, say, C, with an extra compile-time language to replace macros. It's a simple dynamic language, with optional typing, where you select which code runs at compile time and which runs at runtime. Aside from being quite revolutionary in that respect (precisely because the compile-time code doesn't operate on the AST, like in Lisp, but on program objects) -- languages like Nim and Zig have a similar feature, but they also have other features -- it has certain big practical implications. For one, you could imagine stepping through a Zig program with a debugger at compile-time, seeing how it operates on Zig objects, not produces an AST that goes through another stage. For another, in terms of program semantics and analysis, the program means the same thing as if the language were truly dynamic and everything was evaluated at runtime. I.e. Zig has the semantics of a very simple dynamic language. So the subroutines that run at compile time and that you or someone else writes, are just simple Zig code you can read (and maybe, some day, step through).

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

#266
post #186

Earlier quoted context omitted.

fn add2(x: i32, y: i32) -> i32 { x + y } variable declaration is varname: type, it makes it very hard to read when declaring arrays or other things return type is after the paren the let keyword seems redundant/unnecessary, a little like var in js Those are good example of "c flavor". I guess they're easier to parse, but still I would rather have C flavor instead.

"Very hard to read"? As in, harder to read than the C declaration syntax for the same types? That's a logical impossibility!

STL containers are pretty easy to read

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

#267

What influential applications are written in rust? For c++, there is llvm, chrome, game engines, I feel like c++ is standing very strong in any of these fields still, why is that? Do u think it’s going to change soon?

No essential programs are in Rust, in the way that e.g. Docker is in Go, or your examples in C++, and none are on the horizon unless Cargo becomes a popular way to build C++ or C programs. Rust is popular to post about on HN, but the number of people actively coding it is at least 4 orders of magnitude fewer than mature languages, and the number of people adopting it, likewise: the number of people adopting C++ is many times larger than the number who have ever even heard that Rust exists. Those numbers will take many years to change, if they do. Just as likely, some new hotness will pop up and distract the early adopters; Rust could very possibly fizzle out. (That would be a shame unless the new hotness were enough better. Rust++?)

Promoting Cargo as a way to build C++ and C programs could be a way to establish Rust underpinnings. Cargo is better than most other build systems now used for C++, and with C++20 getting modules, the fit is improving.

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

#268
post #78
post #64

Great article. One nitpick: > One of the biggest benefits of using a systems programming language is the ability to have control over low-level details. I think this is a misguided conflation of "systems programming" and "low-level programming", those are separate things. See http://willcrichton.net/notes/systems-programming/

Ah, the eternal argument over what qualifies as "low-level". I think we can all agree it's not Javascript, but beyond that opinions vary greatly and it's mainly a semantic issue.

With current languages, we should speak more about range.

C++'s and Rust's ranges stretch from C's at the bottom up to near ML's. Java is stuck in a little space in the middle.

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

#269
post #232

Earlier quoted context omitted.

Sure, but you still get memory safety.

... hence a better C++. If a better C++ is what you want, then Rust is a great fit.

In 1995 people said Java was a "better C++", but it was basically 1991 C++ plus GC (and numerous misunderstandings), minus concrete types.

Rust can do more of the things C++ can do than Java can, but there is a very great deal that can be put in a C++ library that is wholly beyond Rust's capacity.

If you have lesser expectations to capture semantics in libraries, or to use such libraries that do, Rust serves. But the gap will only grow wider.

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

#270
post #223

Earlier quoted context omitted.

Well, yes. There are plenty of popularity metrics there already, this one is about something else. As you said, mainstream languages won't win this one. But it is a valid metric anyway, and there is plenty of merit on winning it.

Think about this - if a bunch of people hate a language and stop using it, the following year that language's "most loved" score will increase . I wouldn't call that merit, it's just a bad metric.

Yes, if people can simply stop using a language, it will not be hated. That's how it works on real life too.

But most of the time, people can't stop using languages.

Post reply on HN