News for hackers. Stuff that matters.
Re:Rust is not fast by pcwalton on Tuesday November 19, 2013 @10:40AM (#6761842)
Unsurprisingly, I disagree with most of this post.

* The part about Rust having no shared memory is just wrong. Rust has a very rich set of concurrency primitives at this point: you can use immutable shared memory (Arc), mutexes (MutexArc), reader-writer locks (RWarc), and atomic variables (AtomicInt and friends). And if you're willing to drop down to unsafe code, you get the full set of LLVM concurrency primitives.

* The complaint about smart dereferencing strikes me as odd. Almost every new systems language—Objective-C, D, Go, and Rust (and also Nimrod I think?)—does the same thing that Rust does in that the "." operator also works on pointers. It's type-directed: if you don't know whether you're working with a pointer or not, just go look at the type of the value you're working with. If you don't know a value's type, then you have much bigger problems than knowing whether you'll get an extra memory access on ".".

Hiding the difference between a memory access and a cheaper operation is something compilers have done ever since the invention of register allocation.

* I don't know what the complaint about "bugs with small objects" is, but all word-sized objects were made into LLVM Values a while back, making us as efficient there as you can be. Unless I'm misunderstanding the complaint.

* Doing code duplication to accommodate different types of smart pointers doesn't work. The smart pointers have different semantics: that's why they exist in the first place. You can't just copy and paste your code.

* The GC in Rust does need work. But so does C++'s GC and nobody is saying "C++ is not fast" because of it.

About the only part I agree with is is "fork-join parallelism and work-stealing should be better supported". This is an area we'll need to flesh out more fully at some point. Note that there is now a much more advanced work-stealing scheduler. (It's not using the most efficient data structures for work stealing yet though.)

Re:Rust is not fast by richardwhiuk on Tuesday November 19, 2013 @10:50AM (#6761931)
> The GC in Rust does need work. But so does C++'s GC and nobody is saying "C++ is not fast" because of it.

C++ doesn't have a garbage collector, so I'm not sure what you are getting at here.

Re:Rust is not fast by kibwen on Tuesday November 19, 2013 @10:55AM (#6761980)
Sure it does, here's one:

http://www.hpl.hp.com/personal/Hans_Boehm/gc/

Rust has a GC in the same sense that C++ has one, which is to say that its GC can be provided by libraries rather than being baked-in to the language.

Re:Rust is not fast by cwzwarich on Tuesday November 19, 2013 @12:08PM (#6762552)
Rust has GC that is part of the standard runtime / library with special language syntax to go with it. C++ has no such thing.
Re:Rust is not fast by kibwen on Tuesday November 19, 2013 @12:21PM (#6762663)
I'm about to blow your mind here: Rust has never had a GC. Managed pointers were always backed by reference counting, and the cycle collector stopped working sometime in 2010 and was never brought back online. Note that I said "were backed by reference counting" (emphasis mine), because managed pointers no longer exist in the language (unless you turn on the backwards-compatibility flag for them, which is only being provided temporarily).

So there's no longer even special syntax for a theoretical GC. Instead the plan is to greatly expand our support for custom pointer types in general, which will make all user-provided pointer types (implemented in whatever libraries our users come up with) first-class citizens. Our own stdlib will include several pointer types of this nature, including: `Rc` (reference counting), `Arc` (atomic (thread-safe) reference counting), `RWArc` (memory-safe Arc for mutable objects), and, yes, a `Gc` type.

And while it's true that we may provide hooks into the runtime to allow the `Gc` type to be implemented more efficiently, any user library will be able to use these hooks to implement its own GC. There won't be any implementation in the language itself.

Re:Rust is not fast by axelf on Tuesday November 19, 2013 @12:17PM (#6762620)
The special language syntax is being removed. Its now just a library.
Re:Rust is not fast by tomp on Tuesday November 19, 2013 @11:42AM (#6762350)
C++ has ways of dealing with memory and garbage (i.e. memory no longer in use), such as `malloc()` and `free()`, or reference counting, or destructors, and not all of these are as fast as you want them to be in every situation (e.g. see the numerous malloc implementations), so in performance-critical applications/operations, you have to be very mindful of memory use and optimize correctly (e.g. by using memory pools).
Re:Rust is not fast by widdershins on Tuesday November 19, 2013 @11:50AM (#6762412)
He may be referring to shared_ptr, which implements reference-counted garbage collection in the standard library.
Re:Rust is not fast by pcwalton on Tuesday November 19, 2013 @12:20PM (#6762651)
Both, really. Neither shared_ptr nor Boehm are perfect, but that hasn't stopped C++ from being fast in practice.
Re:Rust is not fast by cscottnet on Tuesday November 19, 2013 @11:59PM (#6766388)
Boehm is far from "fast in practice".
Re:Rust is not fast by tete on Tuesday November 19, 2013 @10:50AM (#6761930)
A few small addendum:

* Objective-C is from 1983, do you? It's not exactly new. ;)

* Nimrod is pretty fast and as the only language even supports soft-realtime applications out of the box. Besides that it feels the nicest to use and has a fat standard library with stuff like Redis. Sorry, I only played with that language, but already feel like a fanboy

* About GC. Yes, that's a problem of all newer languages, but whatever implementation you choose there are advantages and disadvantages and which one is the right one also depends a lot on the language itself. Sometimes you are better off with your big fancy algorithm and sometimes you really just want good old reference counting. But yeah, GC is the big great topic and I am sure it will be for the next few decades.

Re:Rust is not fast by pcwalton on Tuesday November 19, 2013 @11:14AM (#6762129)
> Nimrod is pretty fast and as the only language even supports soft-realtime applications out of the box.

Rust has a richer set of safe memory management primitives than Nimrod does (Nimrod is reliant on non-thread-safe deferred reference counting with stack scans, while Rust has thread-safe unique ownership and thread-safe RC as an option), so I'm not sure I agree that Nimrod is the only language that can do soft real time. It's definitely a neat language though.

Re:Rust is not fast by taumhn on Tuesday November 19, 2013 @10:56AM (#6761981)
> Objective-C is from 1983, do you? It's not exactly new

The dot-syntax for accessing object properties is much more recent though (2009?).

Re:Rust is not fast by mistercow on Tuesday November 19, 2013 @11:43AM (#6762355)
Announced in 2006, released in 2007 with Mac OS X 10.5.
Re:Rust is not fast by mikeash on Tuesday November 19, 2013 @11:52AM (#6762433)
It's a pretty unimportant feature though. It's just some very minor syntactic sugar for a regular message send. All uses of obj.property can be replaced with either [obj property] or [obj setProperty:...] depending on whether it's being written or read. It's about as significant as when C added the ability to declare variables in the middle of a block or support for // style comments i.e. not at all.
Re:Rust is not fast by kbd on Tuesday November 19, 2013 @12:44PM (#6762865)
Yes but that's pcwalton's point. The OP complained that Rust is slow, in part, because of that feature and pcwalton pointed out that A. most languages do it now and B. that it has no runtime cost because it's just sugar syntax.
Re:Rust is not fast by mikeash on Tuesday November 19, 2013 @12:50PM (#6762925)
Sure. And I'm just saying that it doesn't really matter what year ObjC got them because they're not a big deal anyway.
Re:Rust is not fast by gress on Tuesday November 19, 2013 @12:24PM (#6762695)
For now perhaps, but it does seem as though properties are gradually being lifted into a first class language feature rather than a set of conventions.
Re:Rust is not fast by mikeash on Tuesday November 19, 2013 @12:34PM (#6762764)
Properties are, but dot syntax is almost entirely not about properties.
Re:Rust is not fast by gress on Tuesday November 19, 2013 @08:18PM (#6765778)
I'm not sure I understand what you mean by that. Dot syntax is a way to refer to properties independent of the usual message sending syntax. How can it not be about properties?
Re:Rust is not fast by mikeash on Saturday November 23, 2013 @01:57PM (#6786980)
Because... it's not?

Declare a plain getter method:

    -(id)foo;
Call it with dot syntax:

    id foo = obj.foo;
Works fine. Now declare it as a property:

    @property id foo;
Call it without dot syntax:

    id foo = [obj foo];
Works fine. They are completely unrelated and just introduced at the same time. You could take dot syntax out of the language without affecting properties in the least. You could take properties out of the language without affecting dot syntax in the least.

(There is one exception to this, and that is the part where dot syntax understands and calls custom getter/setter names for properties. But that is the only place where they even touch, and it certainly doesn't mean they're somehow integrated.)

Re:Rust is not fast by gress on Saturday November 23, 2013 @11:28PM (#6788720)
If you define 'properties' as only use of the @property directive, then what you say follows.

However that's a pretty arbitrary definition, since properties pre-date the introduction of that directive.

Re:Rust is not fast by mikeash on Sunday November 24, 2013 @10:37AM (#6789817)
Well no, the wishy-washy "properties are certain kinds of methods that we can't really define in a particularly concrete manner" definition of properties is the arbitrary one. Saying that properties are those things which are declared with @property is pretty non-arbitrary. That's the definition the compiler users, that's the definition the runtime uses, and that's the definition I use.

Using the wishy-washy definition doesn't help, in any case. Nobody would say that e.g. autorelease is a "property", but you can still call it with dot syntax.

Re:Rust is not fast by gress on Sunday November 24, 2013 @03:01PM (#6790865)
I seriously doubt your intellectual integrity here.

You know that the dot syntax is a mechanism that matches with the conventions for property access, and no other access pattern.

You also know that its possible to call zero argument methods that aren't accessors using the dot syntax.

I don't believe that you think that this is the purpose for which the dot syntax was designed, and yet you bring up 'autorelease' to support your position.

As I said, based on your specific definition, you are correct, but using denigration, a false straw-man 'quotation', and dishonest examples doesn't make your definition fit the evidence.

As I said, and you sidestepped, properties pre-date the directive, therefore the directive cannot be the sole definition of what properties are.

Re:Rust is not fast by mikeash on Sunday November 24, 2013 @04:29PM (#6791220)
You've decided that I must agree with you, and the only reason I could possibly disagree is that I have no intellectual integrity.

Well, how the fuck can I argue against that? Sure, you must be right. Clearly I could not possibly disagree with you for any other reason.

Seriously, fuck off.

Re:Rust is not fast by gress on Sunday November 24, 2013 @09:05PM (#6792137)
You aren't reading what I wrote. I didn't decide you must agree with me. I accepted your point of view and told you why mine differs.

You then went on to argue that your point of view was the only reasonable one.

If you addressed the actual question instead of being aggressive and insulting, we might have had an interesting technical discussion.

Re:Rust is not fast by eonil on Tuesday November 19, 2013 @11:20AM (#6762181)
> Nimrod is pretty fast and as the only language even supports soft-realtime applications out of the box.

This catches me. Especially for soft-realtime stuff. Because I am looking for strongly, explicitly typed in-game logic language - which needs deterministic and symmetric coroutine.

I have to check it out.

Re:Rust is not fast by girvo on Tuesday November 19, 2013 @11:43AM (#6762351)
2D or 3D, out of curiosity? I'm just getting my feet wet playing with game programming (a 2D engine, and likely using Nimrod itself for the game logic as well as engine) in nimrod, and am going to be blogging about it.
Re:Rust is not fast by eonil on Tuesday November 19, 2013 @11:56AM (#6762466)
3D. I don't think there's really a a lot of difference… Anyway it's just a small project, not a block-buster.

Graphics part is already mostly written in C/C++. I won't use immature languages for low-level system due to library support and debugging ability

I am still reading the manual, but Nimrod doesn't seem to have coroutine support. Do you have any idea?

Re:Rust is not fast by girvo on Tuesday November 19, 2013 @12:25PM (#6762708)
No coroutines per se, but it does have really nice native threading support, and I'm nearly certain that coroutines could be easily put in userspace. It's a powerful language in that regard.

Ask the guys and gals in #Nimrod on freenode, they're super Super helpful -- I'm not well versed enough in parallelism and concurrency to answer your question, but they are!

Re:Rust is not fast by girvo on Tuesday November 19, 2013 @11:02AM (#6762034)
Glad I wasn't the only insta-convert to Nimrod! Such a neat language!
Re:Rust is not fast by trailfox on Tuesday November 19, 2013 @12:18PM (#6762633)
It does look very interesting. I was surprised to learn that it cross-compiles to C before being compiled. I'd be even more interested if there was an IntelliJ plugin for Nimrod.
Re:Rust is not fast by masklinn on Tuesday November 19, 2013 @12:26PM (#6762712)
Why? That's a fairly common strategy, GHC worked the same way until a few years ago (and IIRC you can still ask for compilation to go through C).

It makes for easier reading of the codegen (reading C source is easier than reading machine code, even if it's generated C source) and before LLVM made it much easier to leverage C compiler optimizations & multiplatform support.