News for hackers. Stuff that matters.
Re:Rust Priorities after 1.0 by hanlec on Thursday April 16, 2015 @10:05PM (#9391913)
After using Go for a couple of pet projects in the last couple of months, I came out bored. Many people seem to be quite excited about Rust. I'm setting up my (new) Emacs end for Rust.

Any cool projects I can take a look at?

Re:Rust Priorities after 1.0 by malkia on Thursday April 16, 2015 @10:07PM (#9391918)
Servo. Seriously that was the first one I took, and compiled, and kept on reading (not that I understand a lot of it)
Re:Rust Priorities after 1.0 by jmilloy on Thursday April 16, 2015 @11:51PM (#9392165)
Is there a law for this yet? It seems like any time I see discussion about Rust, over half of the discussion is actually about Go.
Re:Rust Priorities after 1.0 by kibwen on Thursday April 16, 2015 @11:53PM (#9392168)
Likewise, in any discussion about Go on HN half of the discussion will be about Rust. A truly bewildering phenomenon.

Would anyone like to compare Rust to ATS instead? Maybe Erlang? Anybody??

Re:Rust Priorities after 1.0 by doublec on Friday April 17, 2015 @01:12AM (#9392360)
I can help with a Rust vs ATS.

ATS is more like a safe version of C wrapped in ML syntax vs Rust as a safe version of C++.

ATS is lower level. You can do memory safe pointer arithmetic whereas in Rust you'd use unsafe blocks.

Some things are implicit in Rust but explicit (and more verbose) in ATS. For example, Rust has destructors for RAII whereas ATS requires manually calling functions to clean up resources. The type checker tells you when you need to do this (via linear types) but programmer still needs to do the call.

Borrowing is automatic in Rust. In ATS it requires keeping track of borrows in proof variables and manually giving them back. Again the type checker tells you when you get it wrong but it's more verbosity.

ATS has a restricted form of dependent types - Rust is not dependently typed.

With current implementations, ATS compiles to C which can be compiled independantly of an ATS install. You can ship the C code to someone to build without them needing ATS. Rust uses LLVM.

The two languages feel very differently when programming.

Re:Rust Priorities after 1.0 by kibwen on Friday April 17, 2015 @01:48AM (#9392434)
This is awesome, I'm so happy to finally hear from somebody with experience in ATS. :)

  > For example, Rust has destructors for RAII whereas ATS 
  > requires manually calling functions to clean up 
  > resources.
This especially intrigues me, as recent events have shaken my faith a little in RAII. Who knows, maybe Rust will one day regret not embracing linear types wholeheartedly...
Re:Rust Priorities after 1.0 by doublec on Friday April 17, 2015 @06:21AM (#9393311)
I much prefer explicit over implicit so I'm not a big fan of RAII. I find it hides things that are happening in the code which makes it hard to find performance and other problems from inspection. ATS has tail call optimisation and destructors would make it hard to tell when TCO can't be done due to the hidden destructor calls.

Another nice thing ATS has is the ability to specify the API for a C function to a level of detail that enables removing a whole class of erroneous usage of the C API. I have an example of this where I start with a basic API definition and tighten it up by adding type definitions:

http://bluishcoder.co.nz/2012/08/30/safer-handling-of-c-memo...

Re:Rust Priorities after 1.0 by dorfsmay on Friday April 17, 2015 @12:10AM (#9392221)
Rust: ATS for the rest of us!
Re:Rust Priorities after 1.0 by sacado2 on Friday April 17, 2015 @05:48AM (#9393202)
And the other half is about C++.

Well, to be fair, talking about a language is also about talking about what makes it different from others.

Re:Rust Priorities after 1.0 by aikah on Friday April 17, 2015 @12:23AM (#9392255)
I wonder why each time there is a news on Rust, people somehow manage to talk about Go in a negative fashion? At that point it's just trolling.

Go is mentioned 45 times in that thread about Rust...

Re:Rust Priorities after 1.0 by oscargrouch on Friday April 17, 2015 @03:24AM (#9392689)
And Rust are almost-always mentioned in threads about Go :)
Re:Rust Priorities after 1.0 by unfamiliar on Friday April 17, 2015 @05:31AM (#9393143)
They are the two new systems languages on the block, which take quite different approaches. It makes perfect sense that they would be compared often.

There are plenty of people in this thread also complaining about aspects of Rust and its development.

Re:Rust Priorities after 1.0 by xiaq on Friday April 17, 2015 @05:53AM (#9393219)
Except that go is hardly a "new" system language.
Re:Rust Priorities after 1.0 by unfamiliar on Friday April 17, 2015 @08:17AM (#9393793)
It's 6 years old as opposed to 43 years old, I would call that new.
Re:Rust Priorities after 1.0 by apta on Friday April 17, 2015 @03:58PM (#9396840)
Or even a "system" language :-)
Re:Rust Priorities after 1.0 by thuffy on Friday April 17, 2015 @06:10AM (#9393276)
Because there is a battle going on. The lines are being drawn. People who where fighting this battle will see this happening before those who were unaware to start with; however, the lines are now being drawn thanks to Edward Snowden, and this battle is becoming visible to all.

Meaning: GO was dead at birth from out of the sphincter of the NSA.

Re:Rust Priorities after 1.0 by andrewchambers on Thursday April 16, 2015 @10:32PM (#9391983)
The problem with rust is that it has been around for nearly as long as Go, yet is nowhere near stable or production ready in nearly every aspect.

Go has been ready for years.

Re:Rust Priorities after 1.0 by kibwen on Thursday April 16, 2015 @11:13PM (#9392077)
Rob Pike has been working on Go's design since Newsqueak in the 90s, and further explored the same space later with Limbo. For reference, Newsqueak is a C-inspired language that features CSP for concurrency (which should sound familiar to Go programmers). Here's some example syntax (which should look familiar to Go programmers):

  a := mk(array[10] of int)
Given this lineage, it seems disingenuous to compare the ages of the two languages. Modern Rust is to early Rust as Go is to Newsqueak.
Re:Rust Priorities after 1.0 by andrewchambers on Thursday April 16, 2015 @11:16PM (#9392085)
This is true, but it does confirm my point about language flux potentially being a problem. It may work out nicely though.
Re:Rust Priorities after 1.0 by kibwen on Thursday April 16, 2015 @11:29PM (#9392110)
Indeed, it may ultimately turn out that modern Rust is to early Rust as Limbo (rather than Go) is to Newsqueak. I expect Rust will experience growing pains over the next few years as people begin employing it on an industrial scale and discover where the dark corners of the language lie. But nobody's saying that Rust will be the last systems programming language to ever be written. :)
Re:Rust Priorities after 1.0 by tatterdemalion on Thursday April 16, 2015 @11:26PM (#9392103)
This comment is very strange. Go was made public when it was stable (or maybe shortly before?), Rust was made public long before it was.

Rust will be stable in 4 weeks, Go was stable several years ago. So what? If we judged languages by how early they were stable, we would all be writing Fortran 57, Algol 58, and COBOL 60.

Re:Rust Priorities after 1.0 by andrewchambers on Thursday April 16, 2015 @11:39PM (#9392138)
I'm not judging the language, I'm just warning people to be careful in choosing to build a product with it.

The team still seems to be changing stuff like crazy even after the "stable beta" release.

Re:Rust Priorities after 1.0 by kibwen on Thursday April 16, 2015 @11:59PM (#9392193)
The team is emphatically not changing things like crazy. Every week the nightly unstable branch runs against the stable packages on crates.io to automatically smoke out potential stability regressions. Here's last week's:

http://internals.rust-lang.org/t/regression-report-beta-2015...

Two regressions out of 900 packages, and one of those was due to a bug that was fixed (the other was due to a new warning being added, which caused breakage in a package that had opted in to turning all warnings into hard errors; a plan to keep this from happening in the future is being formed at https://github.com/rust-lang/rfcs/issues/1029 ).

For this week, the big breaking change will be the deprecation of thread::scoped due to its API being found unsound. This is exactly the sort of thing that you want to cause breakage for, and does not happen lightly.

Re:Rust Priorities after 1.0 by dbaupp on Thursday April 16, 2015 @11:59PM (#9392191)
I think you have the wrong impression about the recent changes, e.g. a recent "regression report"[1] found only two regressions between nightly and the original released beta. Furthermore, several changes have been rejected due to being breaking. The team is seriously committed to stability.

[1]: http://internals.rust-lang.org/t/regression-report-beta-2015...

Re:Rust Priorities after 1.0 by andrewchambers on Friday April 17, 2015 @12:10AM (#9392220)
You can be sure if more people used rust, there would be many more detected breakages. The undetected ones are more worrying.

I get that the language is a beta, but be warned. One example I saw - http://internals.rust-lang.org/t/memcpy-is-backwards/1797

Re:Rust Priorities after 1.0 by dbaupp on Friday April 17, 2015 @12:23AM (#9392256)
Breaks during beta that are not detected seem fine to me: people were not using the feature, and the improvement/bug fix could land without issue.

That particular change caused heartache, yes, but it was purposely made before the beta release, exactly because it was breaking.

Re:Rust Priorities after 1.0 by kibwen on Friday April 17, 2015 @12:24AM (#9392258)
The language was not yet in beta when the linked change was made. Using that change to criticize the stability of the beta is disingenuous.
Re:Rust Priorities after 1.0 by andrewchambers on Friday April 17, 2015 @12:38AM (#9392294)
My mistake.

I also just skimmed the issues page and saw people who are contributors discussing whether a memory leak is classified as unsafe behavior and changing api's based on this. It feels like this sort of thing should be put to rest before you declare any sort of stability.

Re:Rust Priorities after 1.0 by kibwen on Friday April 17, 2015 @01:03AM (#9392340)
The notion that memory leaks do not constitute memory unsafety has been the party line for a long time, since last year at least (since we can't prevent memory leaks statically: imagine sending something across a channel to a deadlocked thread (remembering that Rust cannot statically prevent deadlocks in general, only data races)). The disruption this week has been due to a stdlib API that made use of a very specific pattern involving a mix of unsafe code, ownership transfer, and destructors. Previously it was believed that this particular unsafe code could not lead to memory unsafety, but that happens to be untrue when memory leakage is thrown into the mix. As a result of this coming to light people will need to reevaluate unsafe code in destructors in a way that had previously not been considered, which is why there's been a general tizzy about it.
Re:Rust Priorities after 1.0 by andrewchambers on Friday April 17, 2015 @01:12AM (#9392361)
Thanks for the explanation.
Re:Rust Priorities after 1.0 by oldmanjay on Thursday April 16, 2015 @10:40PM (#9392002)
of course, if you're interested in rust's memory safety, performance, low-level control, and expressive type system, then in a very real way, go isn't ready at all.

it does have some marquee names behind it, though. I suppose if you squint, that can make up the difference.

Re:Rust Priorities after 1.0 by aikah on Thursday April 16, 2015 @11:31PM (#9392115)
> go isn't ready at all

It's ready when people use it in production.And that's the case so it's ready.

> it does have some marquee names behind it,

So does Rust,or are you saying Mozilla isn't a strong brand?

I don't think its fair to compare both anyway.

Rust looks like it wants to compete with C++, while Go is used by scripters coming from Ruby,Python,Js and PHP. Go devs aren't interested in memory unsafe programming.

Re:Rust Priorities after 1.0 by adamnemecek on Thursday April 16, 2015 @11:43PM (#9392146)
you skipped the "if you're interested in rust's memory safety, performance, low-level control, and expressive type system, then in a very real way" part.
Re:Rust Priorities after 1.0 by aikah on Friday April 17, 2015 @12:03AM (#9392199)
> you skipped the "if you're interested in rust's memory safety, performance, low-level control, and expressive type system, then in a very real way" part.

You skipped the fact that user oldmanjay heavily edited his message, and the current one has little to do with the one I answered too. Not going to edited mine, I quoted his previous message and answered to these specific points.

Re:Rust Priorities after 1.0 by dbaupp on Friday April 17, 2015 @12:14AM (#9392235)
"go isn't ready at all" is still a substring of the parent comment, so one perfectly valid interpretation is that the quote was taken out of context, especially since HN provides no edit histories or even indication of edits.
Re:Rust Priorities after 1.0 by aikah on Friday April 17, 2015 @12:17AM (#9392241)
> you skipped the "if you're interested in rust's memory safety, performance, low-level control, and expressive type system, then in a very real way" part.

Was not part of the original comment I answered to.

Re:Rust Priorities after 1.0 by andrewchambers on Thursday April 16, 2015 @10:47PM (#9392017)
Go performance is going to converge on C performance with new optimization's being written after go 1.5.

Any gains from rusts expressive type system are lost by all the memory lifetime annotations imo.

I still think rust is probably going to be the best language for embedded software like router firmware, as they need to be fast, low overhead and secure.

Re:Rust Priorities after 1.0 by seanmcdirmid on Thursday April 16, 2015 @11:06PM (#9392056)
As an upper performance bound for a GC language, I don't think Go will be able to surpass C# (which has stack allocation in the form of structs, ahead of time compilation, and many other goodies). Rust, on the other hand, has more potential as a non GC language, though at the end of the day it might be hard to tell given equivalent applications.
Re:Rust Priorities after 1.0 by andrewchambers on Thursday April 16, 2015 @11:14PM (#9392081)
The upper performance for garbage collected languages (and rust) is potentially higher than C. The reasons are non aliased pointers allow more aggressive optimization, and batched garbage collection plus memory compaction can perform better than regular mallocs.

Rust still has these advantages though, time will tell. Does rust have a way to avoid bounds checks on arrays? I suppose that requires unsafe annotations.

Re:Rust Priorities after 1.0 by pcwalton on Friday April 17, 2015 @01:51AM (#9392444)
> The reasons are non aliased pointers allow more aggressive optimization

Rust's type system is all about controlling aliasing. But virtually all garbage collected languages, including Go, have much weaker aliasing guarantees than C does. At least C has "restrict".

Granted, if you compile with "-fno-strict-aliasing", a C compiler will have a tougher time of alias analysis, but that isn't strictly C anymore.

In any case, alias analysis here has nothing to do with garbage collection and everything to do with type safety.

> Does rust have a way to avoid bounds checks on arrays? I suppose that requires unsafe annotations.

In most cases using iterators will avoid them.

Re:Rust Priorities after 1.0 by kibwen on Thursday April 16, 2015 @11:36PM (#9392131)
Rust essentially never wastes cycles on bounds checking thanks to the design of its iterators. The Servo team tells me that bounds checking has never shown up in any performance profiles.
Re:Rust Priorities after 1.0 by higherpurpose on Friday April 17, 2015 @03:51AM (#9392773)
I wonder if after Mozilla writes Servo in Rust 1.x and Google sees how fast Servo is, even compared to its own JS engine, it will also consider writing a new JS engine in Rust 2.x (I assume, by then), as I doubt they'd use Go for that. Same for the whole browsers. Due to the safety features of Rust over C++ we might see both Firefox and Chrome be rewritten in Rust over the next 5 years.
Re:Rust Priorities after 1.0 by Ded7xSEoPKYNsDd on Friday April 17, 2015 @05:18AM (#9393106)
Servo isn't a JS engine, it does make use of Firefox' SpiderMonkey, written in C++.
Re:Rust Priorities after 1.0 by captaincrowbar on Friday April 17, 2015 @12:09AM (#9392215)
"Rust essentially never wastes cycles on bounds checking thanks to the design of its iterators."

Can you explain this or point me to the relevant documentation or code please?

Re:Rust Priorities after 1.0 by kibwen on Friday April 17, 2015 @12:29AM (#9392268)
The documentation on iterators describes the advantages of using iteration rather than direct indexing in a loop: http://doc.rust-lang.org/nightly/book/iterators.html

The gist is that an iterator has enough information about the thing that it's iterating over that we, as library authors, can avoid unnecessary bounds checking and just perform unchecked indexing while retaining all the safety. LLVM is also surprisingly good at automatically vectorizing our iterators.

Re:Rust Priorities after 1.0 by captaincrowbar on Friday April 17, 2015 @07:21PM (#9397738)
Thanks!
Re:Rust Priorities after 1.0 by adamnemecek on Thursday April 16, 2015 @11:44PM (#9392150)
you might want to check this out

http://c2.com/cgi/wiki?SufficientlySmartCompiler

Re:Rust Priorities after 1.0 by andrewchambers on Friday April 17, 2015 @12:39AM (#9392297)
Thanks, A good page.
Re:Rust Priorities after 1.0 by gillianseed on Thursday April 16, 2015 @11:44PM (#9392151)
>As an upper performance bound for a GC language, I don't think Go will be able to surpass C#

I don't know how well Mono C# compares to Microsoft's version, but looking at:

http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?t...

Shows that Go certainly beats Mono #C in these benchmarks (often by a very wide margin).

From a technical standpoint I don't see any reason why Go would not be faster than C#, how would 'ahead of time compilation' bring C# a performance benefit over Go ?

Re:Rust Priorities after 1.0 by seanmcdirmid on Friday April 17, 2015 @12:47AM (#9392309)
Mono is considered slow in the .net world. Lets hope the new stance on open source makes things better.

Go and C# are dealing with similar constraints, there is no language design advantage in go with respect to performance, and the resources applied to implementation are similar.

Re:Rust Priorities after 1.0 by rdtsc on Thursday April 16, 2015 @11:13PM (#9392076)
> Go performance is going to converge on C performance with new optimization's being written after go 1.5.

Do you have more details. It would seem like it would be rather difficult to do that. Sure it can rival Java in some workloads, but C performance is a tall claim.

Re:Rust Priorities after 1.0 by andrewchambers on Thursday April 16, 2015 @11:32PM (#9392118)
Go is currently pretty fast, maybe half as fast as C. There is a new backend for the Go compiler being planned which uses more modern techniques.

This plan[1] estimates at 10 percent speed improvements initially, I just think they will continue to progress further over time once the SSA framework is built. They will be able to port essentially every optimization llvm uses eventually, and add a few new ones that can rely on memory safety and pointer aliasing guarantees Go provides.

Go can also do whole program analysis with the ssa form because all source is present at build time.

An addition of a moving garbage collector may also improve cache locality. We will see, google cares about making servers efficient, as it saves money in power.

[1] https://docs.google.com/document/d/1szwabPJJc4J-igUZU4ZKprOr...

Re:Rust Priorities after 1.0 by sinistersnare on Friday April 17, 2015 @02:54AM (#9392599)
What guarantees does Go provide about pointer aliasing? I have no production code in Go, but from what I have played with, Go has no way of indicating that a pointer is not aliased, so how can it optimize that, other than through static analysis, which will not catch the majority of cases.

I ctrl-f'd "alias" on your paper that you linked, and no mention is shown.

edit: in fact, I forgot to look for "escape analysis." So it does get mentioned, but only to point out that it is a non-goal of the project.

Re:Rust Priorities after 1.0 by andrewchambers on Friday April 17, 2015 @08:40PM (#9397919)
Go just guarantees different typed pointers don't alias, I think C has a flag to allow this assumption though.
Re:Rust Priorities after 1.0 by rdtsc on Friday April 17, 2015 @12:03AM (#9392200)
That makes sense Andrew, thanks for explaining.
Re:Rust Priorities after 1.0 by arthursilva on Thursday April 16, 2015 @10:37PM (#9391995)
Well, once you compare both languages you can see why. Hint: inovation/complexity (not that either is a good or bad thing). Anyway, that's only one possible reason... I think Go is actually 2 years older.
Re:Rust Priorities after 1.0 by andrewchambers on Thursday April 16, 2015 @10:40PM (#9392003)
Go hasn't changed much from its initial versions, iirc rust is unrecognizable compared to early versions. Rust didn't know what it wanted to be from the start.

I wanted to give rust a crack years ago, but I am glad I didn't because it would have required constant updates for anything serious.

Re:Rust Priorities after 1.0 by dbaupp on Thursday April 16, 2015 @10:45PM (#9392016)
Go hasn't changed much from its initial released version, or initial internal version? As I understand it, Go was released in a much more final state, whereas Rust was developed in the open from very very early. Rust has always known what it wanted to be, it has just taken a while to find the best way to actually fill that goal. That isn't really a fundamental problem with the language (in fact, I see the constant iteration and change as a good thing: the language was developed empirically, removing features that didn't work/pull their weight, adding ones that did), although it is definitely a good reason for people to have not used Rust historically.

In any case, this discussion seems like a non-sequitur: whether Go is boring to hanlec or not is orthogonal to whether Go is more stable than Rust or not. The fact that a language has been stable for years rather than only just now approaching stability might be something you value highly, but clearly hanlec has a different utility function.

Re:Rust Priorities after 1.0 by andrewchambers on Thursday April 16, 2015 @10:50PM (#9392023)
Go hasn't changed much, because it is the natural extension of plan9 C and other languages from the past. If you look at the project layout of the plan9 source tree, it matches the Go project layout now.

I think plan9 C even used CSP channels in the form of a C library for most of the servers. They just took what they already knew worked, and tried to polish it and add garbage collection.

Rust is trying many things at once then letting things die off as they prove useless.

Re:Rust Priorities after 1.0 by dbaupp on Thursday April 16, 2015 @11:09PM (#9392065)
> Rust is trying many things at once then letting things die off as they prove useless.

Yes, this is perfectly true. I cannot tell from your phrasing whether you think experimentation, learning from experience and removal of pointless code is good or bad. I personally think all of those are good, but you're perfectly entitled to differ.

Go was designed with the lessons learned and experienced gained from plan9, Rust was designed with the lessons learned and experienced gained from iterating on Rust itself. Seems pretty similar. :)

Re:Rust Priorities after 1.0 by andrewchambers on Thursday April 16, 2015 @11:34PM (#9392127)
You are right on all counts.

I think experimentation is a good thing, I don't know if I want to be the guinea pig though.