Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-29 Thread Zoltán Tóth
Devs, please explain how such option could decrease the safety of the language. As it would be just that, an option, an opt-in one. IMHO it even could increase the safety of Rust. There are some extreme optimizing C++ programmers currently. Yes, they are a small fraction, but they exist. And they

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-29 Thread Daniel Micay
On 29/03/14 08:53 AM, Zoltán Tóth wrote: Devs, please explain how such option could decrease the safety of the language. As it would be just that, an option, an opt-in one. IMHO it even could increase the safety of Rust. There are some extreme optimizing C++ programmers currently. Yes, they

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-29 Thread Björn Steinbrink
On 2014.03.29 13:53:49 +0100, Zoltán Tóth wrote: Devs, please explain how such option could decrease the safety of the language. As it would be just that, an option, an opt-in one. As somebody else said before, rust's indexing operator is like C++'s std::vector::at() which throws an exception

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-29 Thread Kang Seonghoon
2014-03-29 21:53 GMT+09:00 Zoltán Tóth zo1...@gmail.com: Use 'unsafe' everywhere? Yes, using the `unsafe fn` in place of `fn` everywhere should be sufficient. Actually it is not very hard to do so (before writing this I have experimented with my own project for this strategy and it only had a

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-29 Thread Zoltán Tóth
Thank Björn Steinbrink for your example. Though Daniel already mentioned the key [the difference between the runtime and logic errors] earlier many times, I only now understood it from the example. Sorry ___ Rust-dev mailing list Rust-dev@mozilla.org

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-29 Thread David Morris
Might it be useful to turn this the other way up, and introduce an option to *add* bounds checks to unsafe indexing when debugging? It seems like removing that undefined behaviour would make debugging of unsafe code easier, like the optional bounds checks for unsafe programming languages that

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-29 Thread Patrick Walton
This is essentially what ASan already does, AFAIK. I would like ASan support for Rust someday, as unsafe code can still benefit from it (although not to the degree that C code does, obviously). Patrick On March 29, 2014 6:44:08 PM PDT, David Morris davidrowlandmor...@gmail.com wrote: Might it

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Lee Braiden
On 28/03/14 03:48, Daniel Micay wrote: On 27/03/14 11:04 PM, Tommi Tissari wrote: Case by case is all fine and good. But you're trying argue what a programmer *should* do if he knew what was good for him. Rust doesn't view the programmer as an infallible, trusted entity. Actually, I believe

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Tommi
On 28 Mar 2014, at 05:48, Daniel Micay danielmi...@gmail.com wrote: I don't know about those other dialects. You're proposing introducing new dialect of Rust. In Crust, code generating a failure on out-of-bounds will now cause silent memory corruption. Crust will do away with safety

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Huon Wilson
On 28/03/14 22:04, Lee Braiden wrote: On 28/03/14 03:48, Daniel Micay wrote: On 27/03/14 11:04 PM, Tommi Tissari wrote: Case by case is all fine and good. But you're trying argue what a programmer *should* do if he knew what was good for him. Rust doesn't view the programmer as an infallible,

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Daniel Micay
On 28/03/14 07:04 AM, Lee Braiden wrote: On 28/03/14 03:48, Daniel Micay wrote: On 27/03/14 11:04 PM, Tommi Tissari wrote: Case by case is all fine and good. But you're trying argue what a programmer *should* do if he knew what was good for him. Rust doesn't view the programmer as an

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Tommi
On 28 Mar 2014, at 05:56, Patrick Walton pcwal...@mozilla.com wrote: I think that Rust should give you the ability to opt out of safety, but on a per-operation basis. Having it as a compiler option is too much of a sledgehammer: often you want some non-performance-critical bounds to be

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Daniel Micay
On 28/03/14 08:25 AM, Tommi wrote: On 28 Mar 2014, at 05:56, Patrick Walton pcwal...@mozilla.com wrote: I think that Rust should give you the ability to opt out of safety, but on a per-operation basis. Having it as a compiler option is too much of a sledgehammer: often you want some

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Patrick Walton
On 3/28/14 5:25 AM, Tommi wrote: On 28 Mar 2014, at 05:56, Patrick Walton pcwal...@mozilla.com wrote: I think that Rust should give you the ability to opt out of safety, but on a per-operation basis. Having it as a compiler option is too much of a sledgehammer: often you want some

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Evan G
We don't WANT that though. Haven't you been reading? If we need that flag to perform as well as C++, we'll have failed in our mission. We don't just want to make a safe language: we want to make one safe, fast, and concurrent. Also, as Daniel pointed out, the stdlib already relies heavily on

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Clark Gaebel
A good plus for rust here is that in general, the idiomatic way to access arrays in a loop doesn't use bounds checking. For example, to write a dot product in c++ you'd do this: double dot(const double* x, const double* y, int len) { double result = 0.0; for(int i = 0; i len; ++i) result

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Daniel Micay
On 28/03/14 07:44 AM, Tommi wrote: This is incorrect. All those range based functions (or majority of them... I'm not sure) are safe if the range(s) you pass to them is safe. That's why those range functions can't guarantee safety as part of their signature. For example, look at the following

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Tommi
On 28 Mar 2014, at 14:27, Daniel Micay danielmi...@gmail.com wrote: On 28/03/14 08:25 AM, Tommi wrote: On 28 Mar 2014, at 05:56, Patrick Walton pcwal...@mozilla.com wrote: I think that Rust should give you the ability to opt out of safety, but on a per-operation basis. Having it as a

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Huon Wilson
On 28/03/14 23:49, Tommi wrote: On 28 Mar 2014, at 14:27, Daniel Micay danielmi...@gmail.com wrote: On 28/03/14 08:25 AM, Tommi wrote: On 28 Mar 2014, at 05:56, Patrick Walton pcwal...@mozilla.com wrote: I think that Rust should give you the ability to opt out of safety, but on a

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Michael Thorpe
If your hotspot is spread across thousands and thousands of lines of code, you have made major architectural mistakes. On 28 Mar 2014, at 12:49, Tommi rusty.ga...@icloud.com wrote: On 28 Mar 2014, at 14:27, Daniel Micay danielmi...@gmail.com wrote: On 28/03/14 08:25 AM, Tommi wrote: On

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Tommi
On 28 Mar 2014, at 15:01, Huon Wilson dbau...@gmail.com wrote: [..] And anyway, as Daniel and Patrick say, if you don't need the utmost safety, then Rust isn't the language you're looking for: things like C++ work well in the speed department, at the cost of safety Yes, it seems that Rust

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Jared Forsyth
It just seems that all arguments have been made 5+ times by both sides. I would agree that mailing list discussions that start going in circles become no longer appropriate for a mailing list. On Fri, Mar 28, 2014 at 7:48 AM, Tommi rusty.ga...@icloud.com wrote: On 28 Mar 2014, at 15:43,

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Matthew Frazier
I would just like to interject that this conversation has been blowing my inbox up all morning and seems to be going absolutely nowhere. The people on both sides of this issue have stated their arguments exhaustively, and I neither believe that the Rust developers would ever introduce a flag that

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Lee Braiden
On 28/03/14 15:31, Sanghyeon Seo wrote: To defend rustc's honor: rustc has no such design issues. That's my favourite part of this whole thread. Really. :D -- Lee ___ Rust-dev mailing list Rust-dev@mozilla.org

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Tommi
On 28 Mar 2014, at 17:46, Erick Tryzelaar erick.tryzel...@gmail.com wrote: Disagreement is fine [..] I would think that to be an axiom which didn't need to be mentioned. What I think this whole discussion boils down to, is orthodoxy vs. pragmatism. The pragmatic think that wiggle room is

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Tommi
On 28 Mar 2014, at 14:47, Daniel Micay danielmi...@gmail.com wrote: On 28/03/14 07:44 AM, Tommi wrote: This is incorrect. All those range based functions (or majority of them... I'm not sure) are safe if the range(s) you pass to them is safe. That's why those range functions can't guarantee

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Tommi
On 28 Mar 2014, at 15:43, Matthew Frazier leafstormr...@gmail.com wrote: I would just like to interject that this conversation has been blowing my inbox up all morning and seems to be going absolutely nowhere. That's a good argument against using mailing lists for this kind of a purpose.

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Zoltán Tóth
Do not close this thread. This is actually the most exciting one currently. ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Tony Arcieri
On Thu, Mar 27, 2014 at 1:17 PM, Steve Klabnik st...@steveklabnik.comwrote: Why isn't there a compiler flag like 'noboundscheck' which would disable all bounds checking for vectors? It would make it easier to have those language performance benchmarks It seems like, prior to even proposing

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Daniel Micay
On 28/03/14 09:52 PM, Tony Arcieri wrote: On Thu, Mar 27, 2014 at 1:17 PM, Steve Klabnik st...@steveklabnik.com mailto:st...@steveklabnik.com wrote: Why isn't there a compiler flag like 'noboundscheck' which would disable all bounds checking for vectors? It would make it easier to

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Tony Arcieri
On Fri, Mar 28, 2014 at 6:55 PM, Daniel Micay danielmi...@gmail.com wrote: You can already use unchecked indexing in any case where there's a performance issue so I don't really understand what the fuss is about. Confirm. This entire thread seems like much ado about nothing. -- Tony Arcieri

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread comex
On Fri, Mar 28, 2014 at 8:14 AM, Daniel Micay danielmi...@gmail.com wrote: Lifetimes serve no purpose other than to prevent the programmer from doing stuff, and are *entirely* stripped out before code generation. Do you want to override/disable borrow checking and freezing too? There's also

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Daniel Micay
On 29/03/14 12:10 AM, comex wrote: On Fri, Mar 28, 2014 at 8:14 AM, Daniel Micay danielmi...@gmail.com wrote: Lifetimes serve no purpose other than to prevent the programmer from doing stuff, and are *entirely* stripped out before code generation. Do you want to override/disable borrow

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread comex
On Sat, Mar 29, 2014 at 12:19 AM, Daniel Micay danielmi...@gmail.com wrote: This is unfair. You're mixing up static checks such as exhaustiveness, freezing, and lifetimes, which have no performance impact (or at least, the performance impact caused by their limitations would be mitigated only

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread Daniel Micay
On 29/03/14 12:36 AM, comex wrote: On Sat, Mar 29, 2014 at 12:19 AM, Daniel Micay danielmi...@gmail.com wrote: This is unfair. You're mixing up static checks such as exhaustiveness, freezing, and lifetimes, which have no performance impact (or at least, the performance impact caused by their

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-28 Thread comex
On Sat, Mar 29, 2014 at 12:41 AM, Daniel Micay danielmi...@gmail.com wrote: A lot of code in the compiler simply leaves out error checking and relies on getting an ICE from the failure. It would take a long time to translate everything into proper error messages. Well, a compiler should not

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Tommi
On 27 Mar 2014, at 22:17, Steve Klabnik st...@steveklabnik.com wrote: Why isn't there a compiler flag like 'noboundscheck' which would disable all bounds checking for vectors? It would make it easier to have those language performance benchmarks (which people are bound to make with no bounds

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Matthew McPherrin
I think your hypothetical situation of saving millions by disabling bounds checks is absurd: To save $10 per machine, assuming $0.20 per kilowatt-hour, and saving 50 nanojoules per bounds check, you'd need to be avoiding about 10^14 check. That's equivalent to avoiding 1 million bounds checks

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Lee Braiden
I think the point is that the compiler should not be forcing people to do things, but enabling people to do things, with sensible defaults. Personally, whilst I would advocate MORE bounds checking in rust for debugging / prototyping purposes, I don't think bounds checking is even ideal. It's

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Corey Richardson
Alternatively, in this future where people are deploying Rust applications to hundreds of thousands of servers, we could be using Intel's Memory Protection Extensions for much cheaper bounds checking etc. Which surely other applications will be using once bounds checks are nearly free. Rust will

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Corey Richardson
It's not about debugging, it's about memory safety. It'd be ridiculous to disable bounds checking just because you've done QA. How many security exploits are over- or under-flows? On Thu, Mar 27, 2014 at 7:16 PM, Lee Braiden leebr...@gmail.com wrote: I think the point is that the compiler should

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Lee Braiden
a) I think Rust is making a mistake by considering boundary checks only on memory accesses b) No, it really wouldn't be ridiculous, if you've checked it properly at a QA stage. By definition, it's ridiculous to KEEP checking it, once it's already been checked thoroughly, as a proper QA

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Tony Arcieri
On Thu, Mar 27, 2014 at 4:51 PM, Lee Braiden leebr...@gmail.com wrote: b) No, it really wouldn't be ridiculous, if you've checked it properly at a QA stage. By definition, it's ridiculous to KEEP checking it, once it's already been checked thoroughly, as a proper QA process would do. I'm

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Daniel Micay
On 27/03/14 07:16 PM, Lee Braiden wrote: I think the point is that the compiler should not be forcing people to do things, but enabling people to do things, with sensible defaults. Personally, whilst I would advocate MORE bounds checking in rust for debugging / prototyping purposes, I don't

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Daniel Micay
On 27/03/14 04:42 PM, Tommi wrote: A flag that removes safety is pretty antithical to the goals of the language, IMHO. Yes, I agree it's not the official Rust way of things. But not providing the option seems quite totalitarian. An example use case might be a company that runs its code

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Tommi Tissari
Compiling with that flag would figuratively speaking wrap everything inside an unsafe block and then omit vector bounds checking. The flag wouldn't be allowed for library builds. What I find a bit totalitarian about this situation is that the language forces a decision which the programmer

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Daniel Micay
On 27/03/14 09:02 PM, Tommi Tissari wrote: Compiling with that flag would figuratively speaking wrap everything inside an unsafe block and then omit vector bounds checking. The flag wouldn't be allowed for library builds. What I find a bit totalitarian about this situation is that the

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Tommi Tissari
Oh, ok, well in that case I suppose the flag should cause all indexing operations to become their unsafe variants instead, all functions that call those to become unsafe, etc. propagating the unsafety where it's needed to make the code compile. On 28 Mar 2014, at 03:15, Daniel Micay

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Tommi Tissari
Opting in case by case is not the same thing as having a compiler flag which you can toggle without modifying the source. Perhaps bounds checking is the only safety measure which has runtime penalty? (Not sure about that) But that would explain why it would be a separate flag. By the way, D

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Daniel Micay
On 27/03/14 10:04 PM, Tommi Tissari wrote: Opting in case by case is not the same thing as having a compiler flag which you can toggle without modifying the source. A case-by-case basis preserves the safety guarantees of the language and doesn't introduce a new dialect. It also means you can

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread SiegeLord
On 03/27/2014 10:04 PM, Tommi Tissari wrote: By the way, D is memory safe (although it's opt-in) and it has this noboundscheck flag. So I don't see what the problem is. Rust takes a very different stance to safety than to D (e.g. making it safe by default). In the D community my perception

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Tommi Tissari
On 28 Mar 2014, at 03:41, Jeffery Olson olson.jeff...@gmail.com wrote: forces a decision which the programmer should be allowed to make for himself. A bit like someone dictating my hair style. Yes. Rust is just like hair salon that forbids you from setting your own hair on fire.

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Clark Gaebel
If you want sharp scissors, use unsafe indexing. You generally don't need it everywhere, just in your inner loop. Profile, then optimize. Rust gives you the tools needed to optimize where things get hot, but we also like safety by default. - Clark On Thu, Mar 27, 2014 at 10:31 PM, Tommi

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Tommi Tissari
Case by case is all fine and good. But you're trying argue what a programmer *should* do if he knew what was good for him. While I'm trying to argue that the programmer should be *free* to test how fast his code would run without bounds checking, just for the hell of it. You want to enforce

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Daniel Micay
On 27/03/14 11:04 PM, Tommi Tissari wrote: Case by case is all fine and good. But you're trying argue what a programmer *should* do if he knew what was good for him. Rust doesn't view the programmer as an infallible, trusted entity. This is clear in the design of lifetimes. For example,

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Patrick Walton
On 3/27/14 1:42 PM, Tommi wrote: On 27 Mar 2014, at 22:17, Steve Klabnik st...@steveklabnik.com wrote: Why isn't there a compiler flag like 'noboundscheck' which would disable all bounds checking for vectors? It would make it easier to have those language performance benchmarks (which people

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Clark Gaebel
I'd like to point out that I agree with your central premise that most bounds checks are useless. Some huge percentage of them, in fact. But I still enjoy the peace of mind that they bring. If I actually need a piece of code to be manually checked, covered in tests, and benchmarked to be fast,

Re: [rust-dev] Compiling with no bounds checking for vectors?

2014-03-27 Thread Daniel Micay
On 27/03/14 11:56 PM, Clark Gaebel wrote: I'd like to point out that I agree with your central premise that most bounds checks are useless. Some huge percentage of them, in fact. In my opinion, this isn't necessarily true for Rust. Iterators provide a lot of functionality without the overhead