News for hackers. Stuff that matters.
Re:A 30 minute introduction to Rust by ChuckMcM on Monday January 13, 2014 @03:14PM (#7052972)
This is an excellent summary Steve, it also points out one of the challenges of 'System' languages, which is the requirement for 'unsafe.'

One of the first things I did when I started working on Oak (which became Java) was to see about writing an OS in it. The idea being that if you could write an OS in a 'safe' language then you could have a more reliable OS. But we were unable to write it completely in Oak/Java and that lead to some interesting discussions about what might be the minimum set of 'unsafe' actions might be required by a systems language.

Sadly we did not get to explore that very much, although I did pass it on as a possible thesis topic to some interns who came through Sun at the time. I'd be interested in your experience with what actions require 'unsafe' and if you have seen a canonical set that might point toward a process to get to a 'safe' OS.

Re:A 30 minute introduction to Rust by steveklabnik on Monday January 13, 2014 @03:49PM (#7053160)
Glad you liked it, Chuck.

Some of my closest friends in college specialized in operating systems, and we (mostly them) worked on http://xomb.org , an exokernel in D. I'd hope that today we'd choose Rust instead.

Julia Evans has been writing _fantastic_ series about a kernel in Rust: http://jvns.ca/blog/categories/kernel/

As she says "This is typical of a lot of Rust code I’m writing – I need to write a lot of unsafe code."

I'll have to give this 'minimum set' idea some thought. I think that safety will be more useful for things like kernel modules than in the kernel itself, though I'm not sure why I think that, exactly. Hmmmmm...

Re:A 30 minute introduction to Rust by kibwen on Monday January 13, 2014 @03:55PM (#7053190)

  > I need to write a lot of unsafe code.
To contrast with application-level code, pcwalton has measured that less than 1% of Servo's code is contained within `unsafe` blocks.
Re:A 30 minute introduction to Rust by ChuckMcM on Monday January 13, 2014 @04:30PM (#7053507)
Exactly, and of course this leads me to wondering about computer architectures that "require" unsafe things in their kernels, versus things like Multics where the OS and hardware co-operated at some level to make things safe. Lots of interesting questions.
Re:A 30 minute introduction to Rust by fanf2 on Tuesday January 14, 2014 @02:33AM (#7055868)
One possibility might be to add hardware support for fine-grained capability security - http://www.cl.cam.ac.uk/research/security/ctsrd/
Re:A 30 minute introduction to Rust by twic on Wednesday January 15, 2014 @12:30PM (#7064647)
Would that help? Wouldn't the use of a safe language make hardware-level memory protection less important, not more?
Re:A 30 minute introduction to Rust by kibwen on Monday January 13, 2014 @03:35PM (#7053083)
For reference, the following actions are what are enabled within `unsafe` blocks in Rust:

1. Dereferencing raw pointers (a.k.a. "unsafe" pointers). Note that's just dereferencing: there's nothing inherently unsafe about just creating and passing around the pointers themselves.

2. Calling a Rust function that has been marked with the entirely-optional `unsafe` keyword.

3. Calling an external function via the C FFI, all of which are automatically considered unsafe.

Re:A 30 minute introduction to Rust by silon3 on Tuesday January 14, 2014 @03:56AM (#7056055)
>Note that's just dereferencing: there's nothing inherently unsafe about just creating and passing around the pointers themselves.

Sure there is. Passing around multiple pointers can result in a double free and then the dangerous dereference can happen. I'm guessing the developer must be careful when writing unsafe blocks to make sure this doesn't happen.

Re:A 30 minute introduction to Rust by dbaupp on Tuesday January 14, 2014 @06:32AM (#7056462)
Unsafe behaviours with raw pointers:

  - dereferencing
  - arithmetic (implemented as ptr.offset(number) in the stdlib), 
    since it is undefined behaviour for LLVM to move a pointer to
    point outside* of the object that it came from originally 
    (even without deferencing)
Everything else is OK. (Although the only other thing possible is passing it around as "black box" value.)

*One byte past the end is ok.

Re:A 30 minute introduction to Rust by octo_t on Tuesday January 14, 2014 @04:41AM (#7056173)
but they are safe until you decide to do that deferencing, otherwise they're just uint_ptrs really.
Re:A 30 minute introduction to Rust by valtron on Monday January 13, 2014 @06:34PM (#7054367)
Don't points 2 & 3 together imply that anything that uses built-ins, which I assume are implemented with C FFI, is `unsafe`?
Re:A 30 minute introduction to Rust by evincarofautumn on Monday January 13, 2014 @08:24PM (#7054782)
No, “unsafe” means “evaluate this unsafe block as though it were safe”. This enables Modula-style safe interfaces for unsafe implementations.
Re:A 30 minute introduction to Rust by anon_d on Monday January 13, 2014 @06:56PM (#7054464)
Just to clarify, using a `unsafe` block in a function does NOT mean that you have to tag that function as unsafe.
Re:A 30 minute introduction to Rust by steveklabnik on Monday January 13, 2014 @06:37PM (#7054382)
I'm not 100% sure exactly what you mean by 'built-ins', but Rust is almost entirely written in Rust. I don't think there's anything major implemented via C FFI in the compiler itself.
Re:A 30 minute introduction to Rust by scott_s on Monday January 13, 2014 @06:28PM (#7054327)
You'll probably be interested in the Singularity project at Microsoft Research: http://research.microsoft.com/en-us/projects/singularity/

Much of the kernel is implemented in managed code.

Re:A 30 minute introduction to Rust by volatile on Tuesday January 14, 2014 @07:44AM (#7056678)
I remember hearing about Singularity a few years back - it sounded promising. Looking at the linked page, there doesn't seem to be anything published or presented since 2009. Anyone know what's going on with Singularity these days?
Re:A 30 minute introduction to Rust by seanmcdirmid on Monday January 13, 2014 @06:49PM (#7054433)
Sun eventually did JavaOS, though I'm not sure how much of its code was Java.

IBM did Jikes RVM (old name: Jalapeno) which was mostly, if not purely Java. They handled the bootstrapping problem with some clever ahead-of-time compilation + meta-programming. Even their GC is implemented in Java.

Re:A 30 minute introduction to Rust by twic on Wednesday January 15, 2014 @12:29PM (#7064635)
Jikes RVM was an absolutely amazing project. Superb work.

googles

Jikes RVM is an absolutely amazing project. Superb work. And i'm very glad to see it's still under somewhat active development!

http://jikesrvm.org/