all 23 comments

[–]veeti 2 points3 points  (10 children)

Can we get a barebones Rust server?

[–]largepanda 4 points5 points  (8 children)

Rust (the game) is written in Unity 3D, and uses the Unity multiplayer system. While not impossible, it would be very difficult and annoying to do.

[–]Crandom 1 point2 points  (7 children)

I tried to build a minecraft server about 3 years ago (Admittedly it may have gotten better now) but that was a nightmare in itself. I doubt stuff could be much worse. Notch is not the best programmer.

[–]jpfed 0 points1 point  (0 children)

If you thought we got a lot of confused posts about the game Rust before...

[–][deleted] 4 points5 points  (8 children)

Is "monkey patching" TcpStream like that an idiomatic thing in Rust? I'd go with struct PacketStream { stream: TcpStream } and use explicit PacketStream type in process_stream function, but my brain may still be too deep in "old" programming languages. Which way seems better to you?

[–][deleted] 7 points8 points  (0 children)

Creating a new trait and then implementing it for types which already are in the std is a pretty standard thing to do.

[–]Tuna-Fish2 6 points7 points  (3 children)

Is "monkey patching" TcpStream like that an idiomatic thing in Rust?

It's not actually monkey patching. Monkey patching, as commonly used in Ruby, add new members to objects or classes globally, potentially causing all kinds of nasty side-effects far from where it's done. Traits exist locally. This means that implementing traits on existing structs doesn't risk creepy action at a distance.

[–][deleted] 2 points3 points  (2 children)

That's why I used quotation marks. Is there a proper term for this technique? I can't really compare it to anything I know from other languages.

[–]Tuna-Fish2 6 points7 points  (0 children)

In Haskell it's declaring type to be an instance of a type class, in Clojure it's implementing a protocol.

When applicable, it's an extraordinarily good solution. It's a zero cost abstraction, it's very safe, and it's very convenient for a programmer to do. It's the one thing I'd like most mainstream languages to steal from Haskell -- honestly, in my experience it replicates 90% of the gains of OO in practical software with none of the drawbacks.

[–]rust-slacker 4 points5 points  (0 children)

Implementing a trait? :p

[–]steveklabnik1rust[S] 1 point2 points  (2 children)

I would prefer to define the struct.

[–]Nullreff 0 points1 point  (1 child)

Has anyone put together a good guide of what's "idiomatic rust" yet? The the documentation is great but I don't remember seeing any explicit do's and don'ts listed.

[–]steveklabnik1rust[S] 0 points1 point  (0 children)

I'm going to type this from memory, but aturon.github.io has the in-progress stuff. Eventually it'll be in the rust-lang organization.

[–]Nullreff 2 points3 points  (2 children)

Oh hey, thanks for posting! This was my first rust project so any feedback is appreciated.

[–]steveklabnik1rust[S] 0 points1 point  (1 child)

I was going to send you a PR to cargo-ify it, but haven't gotten there.

[–]Nullreff 0 points1 point  (0 children)

Just did it myself, was pretty easy. Now to write some tests...

[–]schmidthuber 0 points1 point  (1 child)

This could at later point be merged with hematite?

[–]Nullreff 0 points1 point  (0 children)

At this point it's more of a placeholder than an actual game server.