Live data from Hacker News

2017 Rust Roadmap

github.com

91–100 of 201 posts

Re: 2017 Rust Roadmap

#91
post #15

I read through the Rust book, and the problem I was having with it and the other docs is that it was hard to map the Rust concepts with what actually runs when it is compiled. For a language that touts "uncompromising performance", it was difficult for me to find performance characteristics of the underlying abstractions and std library (for example, are algebraic data structures just tagged unions or does the compil…

> . Is it to be avoided if at all possible, or should I go there any time the 'safe' part of the language is making it difficult to express what I want?

The main reasons to use unsafe code are when you're doing FFI and have to regrettably talk to C/++ libraries, or when designing new abstractions with a safe API boundary. It's tricky to ensure that the former is safe since you eventually have to trust C++ (but then, that's not Rust's fault). It's not hard to ensure that the latter is safe. Looking at a page of code and ensuring that it can't cause segfaults is a much easier task than doing it for the entire codebase.

This is almost all the unsafe code out there. There's a bit of it used for doing manual optimizations. When Rust doesn't let you do what you want, often there are abstractions like RefCell that have a small cost that you can use (and they contribute to the overall safety). In case this happens in performance critical code, you can use unsafe again, but this is very rare.

In Servo, for example, almost all of the unsafe code is of the first two kinds. I've been hacking on Servo for years and didn't write much unsafe code at all -- when I did, it had to do with talking to Spidermonkey, and even that was pretty rare. More recently I'm working on integrating Servo's style system into Firefox (which is C++), and only now have I been regularly writing unsafe code. Even for this project the unsafe code I'm writing abstracts away the inherent unsafety of Firefox's C++ so that others can talk to Firefox with safe Rust code.

But many projects have no unsafe code at all. It's not that common to have unsafe code.

> it was difficult for me to find performance characteristics of the underlying abstractions and std library (for example, are algebraic data structures just tagged unions or does the compiler do more fancy things with them? What about iterators?).

Note that a C++ book won't help here for C++ too. What is a switch compiled down to? Does it use a jump table? :)

But yeah, it would be nice to have a thing for this. I don't think it belongs in the official book, but it should exist :)

ADTs are tagged unions. When non-nullable pointers are involved sometimes the tag is stored as a null pointer (e.g. `Option>` is a single pointer, and is None when null. Aside from that, nothing fancy.

Iterators compile down to the equivalent for loops. I can't think of any stdlib iterator which implicitly allocates; they all operate on the stack. In general these are just zero-cost abstractions, they will compile down the the code you would have written with manual loops. This is a recurring theme with the stdlib and even crates from the ecosystem. "extra" costs for abstractions are eschewed in Rust and will often be documented when they exist. So as a rule of thumb assuming that a random abstraction doesn't have an overhead unless explicitly mentioned is good.

Re: 2017 Rust Roadmap

#92

Earlier quoted context omitted.

It's important to note that Go and C have very different design goals from Rust. Go was never designed to have zero-cost abstractions (garbage collection being the most obvious outcome of this, but there are many others), and it has a runtime. C was never designed for safety and security, memory safety or otherwise. In short, Go sacrifices performance and C sacrifices safety, while Rust's goal is to sacrifice neither…

What are your thought on making `rustc` poly-lingual? Ideally, all libraries (i.e. should be written by experts) are written in Rust, but applications are allowed to be written in RustScript. RustScript would be optimized for lower learning curve. example[0]: - No `unsafe` allowed. - Everything is implicitly an `Arc `. - All numerics are BigNum. - etc. This is inspired by the popularity of using Rust within other lan…

https://github.com/jonathandturner/rhai ?

It doesn't do exactly this, but it's similar I think.

Re: 2017 Rust Roadmap

#93
post #53
post #40

Earlier quoted context omitted.

I agree with some of your points, but think this is phrased a bit harsh. FWIW, I write both Go and Rust on a regular basis. Here's where I would agree with you: - Go makes it harder for someone to write overly abstract code (a common affliction!). - Being able to occasionally do type assertions in an ergonomic way is surprisingly nice. - I wish Rust had something in the stdlib like net/http. - I like that go fmt is s…

I forgot to add - I partially agree with you about the productivity of GC. For non-performance sensitive code, GC simplifies a lot. Otherwise, I find Go much nicer to reason about than Java since it has real arrays (value types!). But I find it a mixed bag of whether the naive Go version of something that shares memory by GC is simpler than the naive Rust version of something that shares memory. Sometimes ref-countin…

> Sometimes ref-counting (Rc in Rust) is fine, although that's more expensive than GC.

This is a very interesting and hard comparison to make.

The marginal cost of GCing one more thing is much less than the marginal cost of RCing one more thing. But you need to pay the cost of the GC runtime to get there, and Rust doesn't, so it's a rather hard comparison to make.

However, the cost of RCing something itself is pretty small (and you don't RC very often in Rust anyway), so this rarely matters :)

Re: 2017 Rust Roadmap

#94
post #33
post #9

> Rust should integrate easily with C++ code The day that Rust manages to have always up to date Qt bindings that do not force you to make compromises compared to the C++ API, I think the C++ support will be at a comfortable level. Right now there are fresh efforts in the Rust and Haskell camps to solve this cleanly in a modern way. It would certainly help if the consumption of C++ APIs via llvm (which is used a lot…

I'm ignorant of Rusts ABI/requirements, but can the C ABI be used as a lingua franca, or are there necessary facilities that are unsupportable there?

There is no general C++ ABI, the ABI depends on the compiler and the standard library.

Re: 2017 Rust Roadmap

#95
post #32

Earlier quoted context omitted.

It's also important to note that Go was designed for programmer productivity and Rust wasn't. GC is incredible productivity boost which is why no recent language (except Rust) does manual memory management. Compile times in Go are a fraction of Rust compile times, which is another productivity boost. Go gives you one good way to do concurrency, Rust believes in tyranny of choice. Without mentioning that you don't pai…

> It's also important to note that Go was designed for programmer productivity and Rust wasn't. Rust was absolutely designed for programmer productivity. Source: I was one of the designers. > GC is incredible productivity boost which is why no recent language (except Rust) does manual memory management. That's true, it is a productivity boost. But it also has a cost. Rust didn't want to pay that cost, especially when…

> The only thing I can think of that Rust has that Go doesn't is, like, SIMD, and I'm sure your comment wasn't just referring to SIMD.

Just to clarify, are you referring to Rust using SIMD by way of LLVM, or by way of being able to use SIMD primitives / intrinsics directly in Rust code?

The former works much better than I had anticipated. I've been surprised by the extent that my iterator code ends up vectorized without me doing much work.

The latter does not give me warm Rust feelings today. There's a SIMD crate, but it doesn't look maintained and only works with the nightly compiler releases. I didn't think there was any stable way to do inline assembly, so I think linking C is my best bet here?

Re: 2017 Rust Roadmap

#96

Still no mention of standardization of a "systems language" that's served off a platform known to censor and manipulate... Klabnik and others have lashed out at people in the past over political ramblings, github has been known to engage in political correctness and majority shaming, ugh. Why on earth do people trust Rust at all? Without a standardized specification there's absolutely no good reason to trust mozilla…

>From a langtheory perspective, rust is one of the most backwards, mixed up, kludgy languages to come to light recently.. Would really like to know more about this. It is not very often that you come across Rust criticism in this forum. >C++ already works, why don't we just improve on whatever's lacking? But can it done in such a way that it works with the rest of the language and standard library?

C++ at this point can only be principally improved by drastically reducing the language, and that will never happen. Ever.

Re: 2017 Rust Roadmap

#97
post #53

Earlier quoted context omitted.

I forgot to add - I partially agree with you about the productivity of GC. For non-performance sensitive code, GC simplifies a lot. Otherwise, I find Go much nicer to reason about than Java since it has real arrays (value types!). But I find it a mixed bag of whether the naive Go version of something that shares memory by GC is simpler than the naive Rust version of something that shares memory. Sometimes ref-countin…

> Sometimes ref-counting (Rc in Rust) is fine, although that's more expensive than GC. To nitpick: The jury's still out on that one, because Rc in Rust isn't thread-safe reference counting. I believe that non-thread-safe reference counting is quite competitive with global, cross-thread tracing GC. When people (rightly) talk about how much slower reference counting is than tracing GC, they're almost always talking abo…

Yes, this is a great point! I was a bit sloppy in my wording above.

Re: 2017 Rust Roadmap

#98
It's amazing how much the rust team has nailed it. they know exactly what the problems are. I do not know of any other team as talented as rust. Then language is also quiet brilliant. I have started rewriting all my code in rust the days. It just makes sense.

Re: 2017 Rust Roadmap

#99
post #4

> 1 in 19: lack of IDEs (1 in 4 non-users) I expected that to be higher actually, but that's still the only reason I don't use the language. I've come to rely heavily on IDEs. Whether right or not it's a huge factor in my decision to wait for the language.

I've been writing Java in Vim from time to time for 3 years. Rust is much more pleasant to deal with in a plain text editor. I encourage you to give it a try.

Re: 2017 Rust Roadmap

#100
post #75

Earlier quoted context omitted.

Are you saying that Rust, a system programming language, can compete with the scripting languages in speed of developing features?! Or are you saying that it is a pleasure to use, so you'll use it for smaller backends where development speed isn't that critical? (Asking, not flaming. :-) )

> Are you saying that Rust, a system programming language, can compete with the scripting languages in speed of developing features?! I'll say it. At work, the backend is Rails, and I am a Rust contributor in my freetime. I am in the early stages of working on a framework for web apps in Rust & I believe it will be comparatively productive to Rails. Only your code will be faster and many bugs will be caught at compil…

Bold. :-) I do hope you're correct.

(Given a modest test suite and checking parameters at external API interfaces, scripting languages didn't have much problems with bugs that could be found at compile time, imho.)

Post reply on HN