News for hackers. Stuff that matters.
Re:Why I love Rust by fmstephe on Friday January 08, 2016 @04:20AM (#10863794)
This is good advice. I am totally confused by the Rust vs Go debate. They occupy such different spaces.
Re:Why I love Rust by Avshalom on Friday January 08, 2016 @08:46AM (#10864742)
Because we have weird memories we all still remember Go claiming to be a systems programming language, which everyone took to mean "programming language you would use when you need to talk to metal" but which A) Go isn't suited for B)Rob Pike decided meant "programming language you would use to when you need to write a program"

Rust sort of went public around the same time as Go which automatically "made it" a competitor AND actually is a programming language you would use when you need to talk to metal.

So now people have tied them up in a PR battle.

Re:Why I love Rust by untothebreach on Friday January 08, 2016 @09:27AM (#10865026)
I think there was the added wrinkle of "programming language made by the company that also makes Chrome" vs "programming language made by the company that also makes Firefox". Google's and Mozilla's browsers were/are competitors, so why wouldn't there programming languages be? Obviously, the two companies have completely different reasons for the development of the new languages, but I think that was overlooked at the time that Rust first came out.
Re:Why I love Rust by geofft on Friday January 08, 2016 @02:11PM (#10867368)
Yup. It turns out that Google internally uses C++ for developing web applications (or at least HTTP API endpoints), which nobody on the outside quite internalized. So Go is a perfectly reasonable C++ replacement from the point of view of Google, but doesn't hit the majority of use cases outside, and it feels rather more like a compiled competitor to Python/Ruby/etc. to most of us on the outside.

Also, until about a year before 1.0, Rust had heavy focus on lightweight concurrency (à la goroutines), a garbage collector built into the language (or at least plans for one, complete with syntax), a mandatory runtime to manage those things, etc. You had to give up on the standard library if you wanted to use Rust code as a shared library in non-Rust programs. That changed fairly rapidly, and the last bits of that (like runtime removal) only hit a few months before 1.0, so people's first impressions of Rust were much closer to that of Go.

They're very different languages today. It is technically true that for both of them they are better than C++ for some things people have traditionally used C++ for, but once you get beyond that they're not that similar.

Re:Why I love Rust by nickpsecurity on Friday January 08, 2016 @10:01AM (#10865274)
I'm going with your assessment of things as I think that's why it stays stuck in my head to a degree. The other reason is it was a modern version of Oberon: a simple, GC'd, system language ETH wrote operating systems with. Given that, I still assume an OS can be written in Go in current form or with small changes (eg runtime, FFI).

Hell, people wrote OS's in Haskell, Java, and C#. JX partly put the device drivers in Java. I'd be shocked if Go was only one that couldn't handle it.

Re:Why I love Rust by derefr on Friday January 08, 2016 @04:44AM (#10863868)
I think the reasoning behind the debate is that, together, they mostly obsolete C/C++. Go takes the high-end and Rust takes the low-end, and there's no niche left for C to occupy in the middle.

I guess the real answer is, if you want to learn "the language that people will be using instead of C in ten years"... learn both of them.

Re:Why I love Rust by 0xFFC on Friday January 08, 2016 @06:13AM (#10864131)
I don't think so. Of course, there is space for Rust and Go. But that does not mean there will be no niche for C and C++. That is simply not correct. Ignoring C and C++ mean you are ignoring maybe billion $ industry around them . and That is simply wishful thinking.
Re:Why I love Rust by kamaal on Friday January 08, 2016 @11:59AM (#10866300)
>>Ignoring C and C++ mean you are ignoring maybe billion $ industry around them

Right, very difficult to move the inertia in any direction. The same is true about Java too.

But there are fewer reasons for any starting a new project to do it in C or C++.

Newer stuff replaces older stuff, Heck when C came along, there were languages with billion $ industry around them. C replaced them.

Re:Why I love Rust by ybx on Friday January 08, 2016 @10:11AM (#10865364)
Sure, but you could argue the same for things like COBOL
Re:Why I love Rust by yoklov on Friday January 08, 2016 @09:24AM (#10865007)
As someone in the games industry, I don't see anybody moving towards either of these languages over C++, or really even any excitement over them. I'd be very surprised if Rust displaces C++ here, and put the chance of Go doing so at pretty much 0.

If anything, the current trend is moving more low level (rather than higher level, which these languages both are), as techniques like data oriented design becoming more mainstream.

Re:Why I love Rust by steveklabnik on Friday January 08, 2016 @09:38AM (#10865108)

  > (rather than higher level, which these languages both are)
Rust should be (and is, modulo wrinkles, I mean there's no fundamental reason) as low level as it gets. What makes Rust too high-level for gamedev?
Re:Why I love Rust by mike_hearn on Friday January 08, 2016 @12:27PM (#10866530)
It's probably not too high level for game dev.

However, modern AAA game dev is largely about customising and upgrading large existing game engines, which are all C++ based. Rust could be used for them, but isn't, and the extra features Rust brings are not compelling enough to rewrite huge amounts of working code and suffer (re)training costs.

This is a hole many new languages find themselves in. JetBrains have come up with a very clever solution for their Java/Scala competitor Kotlin: the language was carefully designed from the ground up with perfect Java interop in mind (Java/Kotlin call into each other seamlessly, the IDE can refactor across languages, Kotlin uses the same standard library etc). And quite amazingly, the IDE can automatically rewrite Java into Kotlin. This isn't a party trick, it works very well.

I think if Rust wants/wanted to be a serious competitor to or upgrade path from C++ it'd have needed to take at least some level of C++ interop into account from the start such that Rust and C++ could be intermixed freely. AFAIK though, the best you get is a typical C export/import layer which is too trivial to be compelling.

Of course, it's a lot harder than connecting with Java because of the way C++ stuff is defined using header files. But at least basic interop could have been done.

Re:Why I love Rust by fiedzia on Sunday January 10, 2016 @07:12AM (#10875059)
If you want to be fully compatible with C++, you have to be fully compatible with all its issues and design mistakes. If those could be fixed without sacrificing compatibility, they would be fixed within C++ already. In case of rust, such compatibility would defeat the purpose of its existence.
Re:Why I love Rust by steveklabnik on Friday January 08, 2016 @12:37PM (#10866604)
Yes, this is a good point about AAA.

The issue with interop is on the C++ side, unfortunately, not our side. Until C++ has a well-defined ABI, it's not really possible.

Re:Why I love Rust by pcwalton on Friday January 08, 2016 @12:51PM (#10866714)
It's not clear to me that it's impossible. The ABI isn't a huge issue; templates are, though. I can see a potential path forward by using clang heavily, but it requires a lot of thought.

Isn't Swift looking heavily into C++ interop? It might make sense to collaborate with them to get it to work in both languages.

Re:Why I love Rust by steveklabnik on Friday January 08, 2016 @12:57PM (#10866753)
Swift is implemented in C++, and uses LLVM stuff that we don't because it's not exposed in the C ABI, last I heard.
Re:Why I love Rust by pcwalton on Friday January 08, 2016 @01:55PM (#10867236)
Well, sure, but how the compiler calls into libclang/LLVM isn't the difficult issue here. The more interesting issue is how, conceptually, the Swift or Rust compiler would use libclang to interoperate with C++ in a foreign environment. Once that's established, writing C bindings to whatever part of libclang is necessary should be straightforward.
Re:Why I love Rust by mike_hearn on Friday January 08, 2016 @12:52PM (#10866724)
C++ has a well defined ABI on many important platforms.

On GCC/LLVM based platforms it's standardised in specification documents. On Windows, I think the Visual C++ ABI is the de-facto standard.

Regardless, there are only a handful of top C++ compilers. Interop with even one of them would be of tremendous value.

Re:Why I love Rust by pcwalton on Friday January 08, 2016 @02:02PM (#10867282)
I totally agree. As I mentioned in a sibling comment, maybe the right solution is for Swift and Rust to solve the problem together by using libclang in the same way.

To be concrete, I could envision some sort of bolt-on "inline C++" feature that libclang would expose to all LLVM-based languages. It wouldn't have to be principled interop any more than Objective-C++ is principled interop. It'd just need to get the job done.

Re:Why I love Rust by steveklabnik on Friday January 08, 2016 @12:58PM (#10866770)
Yeah, I mean, the basics of interop might be possible, it will just never be as robust as it could be if C++ had features better designed to play with other languages.

(This of course also affects Rust as well; we don't have a defined ABI either.)

Re:Why I love Rust by mike_hearn on Friday January 08, 2016 @03:22PM (#10867916)
Sure, you can't get completely perfect interop. However a LOT of real C++ codebases don't use or explicitly ban some of the trickiest features, so even partial support can go a long way. For instance, supporting the basic class/vtable layout C++ uses (or even just adopting the C++ ABI for Rust itself here) along with char* strings, would immediately allow you to call into a lot of real C++ APIs, albeit older ones.

Supporting C++ value types, even without templates, would in turn be enough to support quite a lot more. For instance Unreal Engine defines its own string types, as do Qt and so on.

Re:Why I love Rust by steveklabnik on Friday January 08, 2016 @04:56PM (#10868616)
Yeah, to be clear, I think such a thing would have value too. Just hard to get 100%, there are always gonna be caveats.
Re:Why I love Rust by Sharlin on Friday January 08, 2016 @09:51AM (#10865186)
I guess Rust has many features people are only used to seeing in high level languages - and to some people that equals "too much abstraction" which equals "slow". But the thing is - Rust's "high-level" features are all compile time with either no or very little runtime overhead.
Re:Why I love Rust by tux on Friday January 08, 2016 @08:39AM (#10864712)
"together, they mostly obsolete C/C++. Go takes the high-end and Rust takes the low-end"

In that case some one just code "GoRust" language ^_^

Re:Why I love Rust by nickpsecurity on Friday January 08, 2016 @10:11AM (#10865357)
Go is of Pascal tradition of simple, efficient programming languages. Rust has memory and concurrency safety. So GoRust would be...

Concurrent Pascal (1975) by Brinch Hansen http://brinch-hansen.net/papers/

...Concurrent Pascal used in Solo OS. It supported human review via readable syntax, type safety, safe ops on memory, and a concurrency system that caught race conditions at compile time. The runtime underlying the OS was about 4K with the OS itself concise enough to put in one PDF in source form. So, Hansen for the [1975] win in the GoRust competition?

Re:Why I love Rust by untothebreach on Friday January 08, 2016 @09:28AM (#10865032)
Nah, just use CGo to link to a lower-level Rust library :)