Questions tagged [rust]

Rust is a systems programming language focused on three goals: safety, speed, and concurrency. It maintains these goals without needing a garbage collector, making it a useful language for a number of use cases other languages aren't good at: embedding in other languages, programs with specific space and time requirements, and writing low-level code, like device drivers and operating systems.

Tag excerpt copied from: http://stackoverflow.com/tags/rust/info

44 questions
85
votes
1 answer

How are Rust Traits different from Go Interfaces?

I am relatively familiar with Go, having written a number of small programs in it. Rust, of course, I am less familiar with but keeping an eye on. Having recently read http://yager.io/programming/go.html, I thought I'd personally examine the two…
Logan
  • 953
  • 1
  • 7
  • 7
62
votes
9 answers

Why do "checked exceptions", i.e., "value-or-error return values", work well in Rust and Go but not in Java?

Java has "checked exceptions", which force the caller of the method to either handle an exception or to rethrow it, e.g. // requires ParseException to be handled or rethrown int i = NumberFormat.getIntegerInstance().parse("42").intValue(); Other,…
Heinzi
  • 9,646
  • 3
  • 46
  • 59
39
votes
2 answers

How does Rust diverge from the concurrency facilities of C++?

Questions I am trying to understand whether Rust fundamentally and sufficiently improves upon the concurrency facilities of C++ so that to decide if I should spend the time to learn Rust. Specifically, how does idiomatic Rust improve upon, or at any…
thb
  • 747
  • 5
  • 12
28
votes
8 answers

Using a "strong" type system in the real world, say, for large-scale web-apps?

I know this is a very broad, ambiguous, and possibly philosophical question. To an extent, that the most important keyword in the question - "strong" type system - itself, is ill-defined. So, let me try to explain what I mean. Overall context for…
Saurabh Nanda
  • 557
  • 4
  • 8
19
votes
1 answer

Is it possible to achieve Rust's ownership model with a generic C++ wrapper?

Looking through this article on Rust's concurrency safety: http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html I was wondering how many of these ideas can be achieved in C++11 (or newer). In particular can I create an owner class that…
Brannon
  • 361
  • 1
  • 9
18
votes
5 answers

How can Rust be "safer" and "faster" than C++ at the same time?

I have been told that Rust is both safer and faster than C++. If that is true, how can that be even possible? I mean, a safer language means that more code is written inside the compiler, right? More code means more instructions for the processor to…
euraad
  • 305
  • 2
  • 6
10
votes
5 answers

Is it possible to programmatically evaluate safety for arbitrary code?

I've been thinking a lot lately about safe code. Thread-safe. Memory-safe. Not-going-to-explode-in-your-face-with-a-segfault safe. But for the sake of clarity in the question, let's use Rust's safety model as our going definition. Often, ensuring…
TheEnvironmentalist
  • 1,159
  • 1
  • 8
  • 14
9
votes
1 answer

How to design a good generic tiled image downloader?

Tiled images Tiled images are large images that have been split in smaller square tiles. There are several tiled image formats, with different ways of organizing the tile files. A tiled image on the web can be downloaded only by finding all the…
9
votes
2 answers

Rust-style error handling in C++

I've been reading some articles on how Rust does error handling using the Result type and to me it seems like a hybrid best-of-both-worlds (exceptions and return codes) solution which can be very useful. I think it would especially be handy…
stijn
  • 4,108
  • 1
  • 25
  • 31
7
votes
1 answer

Comparision of modeling with inheritance vs idiomatic trait based composition

I recently I started learning Rust and Scala and what struck me was the lack of inheritance model that I'm used to in C++ and Java. Although I can model simple things with structs and traits in Rust, I want to see a more idiomatic way to model…
6
votes
0 answers

Rust and lifetime elision rules for structs?

In the Rust documentation, under the structs section, they give this example of how structs need lifetimes when they contain references: struct Foo<'a> { x: &'a i32, } because We need to ensure that any reference to a Foo cannot outlive the…
AxiomaticNexus
  • 776
  • 2
  • 7
  • 11
6
votes
1 answer

Implementing a construct like Rusts `match` in C?

I'm writing a compiler that compiles to C, one thing I'm attempting to do is implement a construct like Rust's match: // { some function let mut foo = 32; match foo { 3 => return "hey", 4 | 5 | 6 => return "foo", 9…
Jon Flow
  • 363
  • 2
  • 7
6
votes
1 answer

What is the most generic way to provide a variable amount of outputs from a Rust function?

I am currently writing an API for machine learning algorithms in Rust and I would like for a single genetic algorithm, artificial neural network, or Bayesian network to provide multiple outputs so that for instances in which there may be redundancy,…
vadix
  • 71
  • 3
5
votes
3 answers

Why datatypes are marked as thread-safe instead of procedures?

In Rust, Send (or Sync) marker traits are used to indicate whether a value of a type (or a reference to that) can be worked on within threaded context. However, it is an attribute of a function or a procedure that whether it is thread-safe, as…
5
votes
1 answer

Why does Rust require external linkers? Any other similar languages?

Rust needs external linkers (e.g. GCC) to generate final output. Why doesn't it provide a bundled one? Are there any languages that does the similar?
1
2 3