News for hackers. Stuff that matters.
Re:Servo Nightly Builds Available by pekk on Friday July 01, 2016 @04:36AM (#12014621)
> expect severe bugs, crashes, and missing functionality.

I really don't mean this in a snarky way: wasn't this kind of thing supposed to be obviated by the switch to Rust? It often seems that every other post about Rust on HN says that if it compiles, it works.

Re:Servo Nightly Builds Available by IanCal on Friday July 01, 2016 @04:49AM (#12014668)
No language can fix missing functionality, that seems pretty clear.

Your compiler doesn't know what you're trying to do, so you can't prevent all bugs.

That leaves crashes, and ... well it may also depend on what you mean by a crash. The UI becomes unresponsive? Might have absolutely nothing to do with memory issues or even code written in rust. Maybe your rust code is fine but you're trying to open and write to the same file from two places which you don't realise because the users file system is case insensitive but you've only tested on a case sensitive one, etc.

It's also multi-threaded and while languages can significantly help improve the safety of multi-threaded code, I don't think anything can stop you from creating a deadlock or putting your system into an inconsistent state.

And finally, they may not even particularly expect those things, but putting out early nightly builds to a wider audience and expecting nothing to go wrong would be cavalier. A typical warning on many early releases is "don't blame me if this destroys all your files".

Re:Servo Nightly Builds Available by alex_duf on Friday July 01, 2016 @05:34AM (#12014795)
>Maybe your rust code is fine but you're trying to open and write to the same file from two places which you don't realise because the users file system is case insensitive but you've only tested on a case sensitive one, etc

That sounds too precise to be just an example :) We've all been there!

Re:Servo Nightly Builds Available by IanCal on Friday July 01, 2016 @06:40AM (#12015001)
Haha, yes, this kind of thing has bitten me a few times. I remember getting SVN really confused where the server thought files were different but my machine thought they were the same (or similar). I think I had to make a whole new repo.

It's now on my mental list for "but it works on my machine", checking filenames and their cases.

Re:Servo Nightly Builds Available by Manishearth on Friday July 01, 2016 @04:55AM (#12014685)
By crashes we mean panics. We still panic in various places in the code when something goes wrong.
Re:Servo Nightly Builds Available by tinco on Friday July 01, 2016 @05:40AM (#12014814)
To clarify, a panic in rust is the result of an unhandled exception. Usually this is due to laziness rather than a real bug. For example Servo might encounter an IMG tag, start to load the body. The result might be stored in an option because something could have gone wrong during loading (peer disconnected etc.) but the developer didn't feel like implementing robust image handling that day and instead called .expect to extract the image. This throws a panic and exits the application if the image is not there.

This is just a hypothetical example, I bet image loading is one of the things Servo does fine. Just to give you an idea of when Rust might panic.

Re:Servo Nightly Builds Available by Manishearth on Friday July 01, 2016 @06:02AM (#12014878)
Heh.

Earlier in this thread, someone did indeed find a bug in our image loading: https://news.ycombinator.com/item?id=12014108

We were basically panicking when an invalid URL was given to us. There was a comment there noting this -- which means that this was probably written when it wasn't so important to handle all the cases, and more important to handle some cases so that we can test out various ideas. We're still sort of in that stage, and you may see other comments like this throughout the code :)

Re:Servo Nightly Builds Available by Morgawr on Friday July 01, 2016 @05:55AM (#12014853)
I do things like this all the time in Haskell when quickly prototyping new code and then swiftly kick myself because of it. Safe languages are nice, but there's really no way to prevent a developer from saying "Yeah fuck it, this case will never happen anyway" and then calling a fromJust on a Maybe monad which turns out was a Nothing and throws a runtime exception.
Re:Servo Nightly Builds Available by majewsky on Monday July 04, 2016 @07:21AM (#12030071)
Well, there is a way: Don't allow partial functions like fromJust or head. But a) it's going to make prototyping so tedious that no one will bother using this hypothetical language, and b) there are problems that you just cannot solve without partial functions (e.g. foldl1).
Re:Servo Nightly Builds Available by gsnedders on Friday July 01, 2016 @06:24AM (#12014951)
And importantly, a panic is not a result of a memory safety bug, and those are the crashes (with their potential security risks) that Rust is aiming to get rid of.
Re:Servo Nightly Builds Available by AlisdairO on Friday July 01, 2016 @09:45AM (#12015949)
It would be quite nice if there was a synonym for expect (say unimplemented_expect) that meant 'I haven't bothered to implement the proper error handling yet' rather than 'error handling shouldn't be required'. That would really enhance auditability of in-progress code.
Re:Servo Nightly Builds Available by tedmiston on Friday July 01, 2016 @10:13AM (#12016149)
Python has a nice built-in exception for this: NotImplementedError. It's intended usage was related to abstract base classes, but it's taken on this secondary use case recently.
Re:Servo Nightly Builds Available by Manishearth on Friday July 01, 2016 @12:20PM (#12017420)
unimplemented!() exists
Re:Servo Nightly Builds Available by AlisdairO on Friday July 01, 2016 @02:54PM (#12018743)
Yeah, I use that, but it obviously requires more work than a simple unwrap or expect, so the temptation is to just use those and think you'll remember to flesh it out later :-)
Re:Servo Nightly Builds Available by pcwalton on Friday July 01, 2016 @11:52AM (#12017151)
> It often seems that every other post about Rust on HN says that if it compiles, it works.

I'm always careful not to say that "if it compiles, it works"--no language can guarantee that (well, except those that prove your program correct). Instead I like to say "if it compiles, it will fail for a not-stupid reason". :)

Re:Servo Nightly Builds Available by lmm on Friday July 01, 2016 @05:22AM (#12014760)
In pure Rust that never uses "unsafe", maybe. (Though even then, you only get memory safety; it's still possible to e.g. go into an infinite loop and use all CPU and/or memory).
Re:Servo Nightly Builds Available by yoklov on Friday July 01, 2016 @08:56AM (#12015593)
It's also still possible to panic.
Re:Servo Nightly Builds Available by Jweb_Guru on Friday July 01, 2016 @12:56PM (#12017773)
Panic's implementation uses unsafe code, IIRC. But stuff like stack overflow can happen even without explicit unsafe code, I think.
Re:Servo Nightly Builds Available by kibwen on Friday July 01, 2016 @01:39PM (#12018113)
Rust intercepts most stack overflows and aborts the program when they occur. There are some more difficult cases where legit stack overflows are still possible, the resolution to which is blocked on LLVM support on most platforms (notably, Windows is the best here).
Re:Servo Nightly Builds Available by Manishearth on Friday July 01, 2016 @02:19PM (#12018454)
Well ultimately any useful program will use a library that uses unsafe. All I/O is unsafe at the bare metal so while you can safely wrap it it still is unsafe internallly.

When talking about the usage of unsafe code in rust, we generally ignore encapsulated unsafe code in libstd since it has the same safety guarantees as tgr compiler itself. all unsafe code encapsulated in a safe API has these guarantees, but you trust libstd more :)

Re:Servo Nightly Builds Available by mythmon_ on Friday July 01, 2016 @12:58PM (#12017784)
Does anyone know if Servo has any unsafe Rust code?
Re:Servo Nightly Builds Available by panic on Friday July 01, 2016 @01:27PM (#12018026)
Re:Servo Nightly Builds Available by majewsky on Monday July 04, 2016 @07:25AM (#12030077)
Any reasonably large program will have at least some amounts of unsafe code. And that's not a big deal. The point of Rust is to very clearly isolate the unsafe parts, so that you only need to audit 1% or less for memory safety.
Re:Servo Nightly Builds Available by kbenson on Friday July 01, 2016 @01:35PM (#12018079)
If it uses any external libraries (for example, for image handling) then I believe it does by definition, since the API wrapper you end up writing ends up being a small shim that wraps the actual library call in unsafe (because object code is unsafe, as the term in used in Rust).
Re:Servo Nightly Builds Available by ndesaulniers on Friday July 01, 2016 @03:42PM (#12019108)
if feature_thats_not_implemented_yet:

  explicitly_crash