A simple Minecraft written in Rust
github.com
github.com
Piston, the project that's backing Hematite, is very interesting in that it's an attempt to explore idiomatic approaches to game engine design in Rust. I'm not sure how many game developers will value Rust's memory safety over C++'s sheer flexibility and mature tooling, but I commend the Piston developers for taking a chance on a new and unproven language!
EDIT: If you'd like to take a closer look at game development in Rust, be aware that there exist dedicated communities for this on reddit ( http://www.reddit.com/r/rust_gamedev ) and IRC ( http://client01.chat.mibbit.com/?server=irc.mozilla.org&chan... , a.k.a. #rust-gamdev on irc.mozilla.org).
They're trying to make those two images look exactly the same.
Spot on. What sets an immediate roadblock for me is this, straight from the Piston readme:
> You should be able to run the command rustc -v > You should be able to run the command cargo -V
The first one is incredibly easy: brew install rust, which currently brings in 1.0.0-alpha. The second one, well†... Its very homepage[0] says:
> The easiest way to get Cargo is to get the Rust nightly build
So the only easy step out of two is instantly invalidated. This is followed by:
> This will get you the latest Rust nightly for your platform along with the latest Cargo. You should run this script almost every day to get the latest updates.
Okay so the de facto standard dependency manager is apparently deeply tied to rust itself, yet not included in the rust distro, and it's apparently quite not stable enough to warrant daily updates. And even 1.0.0 (granted, "-alpha") doesn't include it, so it may not be ready before god knows when.
Compare:
export GOPATH=$(pwd)
brew install glew
brew install homebrew/versions/glfw3
go get github.com/go-gl/gl
go get github.com/go-gl/glfw3
vim whatever.go # https://github.com/go-gl/glfw3#example
go run whatever.go # yay OpenGL!
This means that although Piston does look great, and Rust looks promising, it does not look not dependable right now, because it just doesn't feel mature (even if it is, which I don't know, because my time is limited and there were enough explicit or implicit warnings about dragons to turn me away).† I'm perfectly aware that cargo is available as a Cask, but for various reasons, I don't want casks in my system, and it doesn't preclude the remainder of the discussion.
[0]: http://doc.crates.io
or were you just wanting to talk about go?
Precisely†. This is just to give some credence to the "mature" part of the parent comment, beyond language features and alleged "proven-ness". I'm not complaining in any way, just reporting how things are or can be perceived.
The comparison with Go is purely factual: I just happen to have done exactly this in Go, and recollected an account of my experience when I wanted to explore doing the same thing in Rust. If referencing Go has to do with anything, it's laziness as I extracted that from my shell history.
I am deeply sorry if the above post sounded snarky or whatever. This was not the intent.
† BTW, when I did this originally, Rust was 0.9 (no alpha anywhere), which has the virtue of saying squat about what you should expect without a statement of version semantics (e.g node.js is 0.12 and definitely production-ready)
> Rust was 0.9 (no alpha anywhere), which has the virtue
> of saying squat about what you should expect without a
> statement of version semantics
Rust has been openly adhering to Semantic Versioning (semver.org) since 0.1. According to the semver specification, any releases with a major version of zero carry no guarantees whatsoever.Recursion at its finest.
With the C and the kind of C++ I write I have some kind of idea what the assembly language that will be generated by the code I'm writing looks like. I have some idea how the data is going to be laid out in memory. You can think of C and good C++ code as a more convenient way of writing the machine instructions that will execute on your cpu, well at least kinda. But you really can't do this with say, haskell or clojure (he said aware he knows little about the former and even less about the latter).
How is rust? Can you write some rust code knowing this datastructure will be laid out like so, knowing this function will likely not thrash cache too badly and so on? Inline asm? If you had the crazy idea of writing the "platinum" linker in rust in an attempt to outperform the (written in c++) gold linker is that doomed before you start. Nothing to choose for efficiency between these languages?
Oh and how's the debugger? Same as gdb on c++?
You can certainly guarantee data layout (such is required for C interop, for which Rust has very nice support), though by default Rust will e.g. reorder a struct's fields in order to optimize its representation (taking into account padding and such) unless you explicitly ask it not to.
Rust also tries to favor explicitness where it can. For example, even though many people have requested C#-style properties where `foo.bar = baz` can implicitly call a setter function, Rust has rejected this because the runtime behavior of a function call is too different from the runtime behavior of a field lookup. As another example, anything that looks like `foo.bar()` will always be a method call, and `foo.bar` (without direct parentheses) will always be a field lookup, so if you want to call a function pointer stored in a struct field you need to write `(foo.bar)()`.
There are also places where Rust is more explicit than C++. For example, a C++ function `void bar(int& foo)` can be called like `bar(6)`, but the analogous Rust function `fn bar(foo: &i32)` must be called like `bar(&6)`.
However, Rust also has places where it is less explicit than C++. For example, whereas C++ has both `bar.foo()` for direct method calls and `bar->foo()` for method calls that are invoked through a deref, Rust has only `bar.foo()` which has the capability to dereference `bar` if necessary. So it would be incorrect to say that Rust is ultimately more or less explicit than C++... it just has a different mix of explicit and implicit operations.
As to the rest, Rust does indeed have inline asm, and I hear that Rust produces DWARF debuginfo which allows it to be debugged via gdb (though it has to pretend to be C++ in order to play nicely with existing tooling, which can make it awkward sometimes).
The Windows section should read:
Minecraft folder: %appdata%\minecraft
Worlds folder: %appdata%\minecraft\saves\<world>
(observe the "closing" percent sign)and the OSX one could read:
Minecraft folder: $HOME/Library/Application Support/minecraft
Worlds folder: $HOME/Library/Application Support/minecraft/saves/<world>
or, of course, using the same tilde syntax as in Linux.And although it would probably make a good jumping-off point for anyone who wanted to develop a Minecraft clone, the original goal of Hematite was only to serve as a proof-of-concept of rendering 3D graphics in Rust.
The most egregious stutter though is when Minecraft generates new chunks.
Minecraft is not a well-coded game. ;)
But Minecraft itself is in Java. And it does get pretty slow even with low settings as compared to other games on high settings.
As with any performance question, this is hard to actually say in general. In the Benchmarks game(1), there are several benchmarks where Rust has no unsafe code and is still faster than C.
1: personal note: ugh, all usual caveats apply, etc.
I'll note that this kind of skepticism has been going on since John Backus[1] was heckled over using (ahem, "wasting") then-precious CPU time on compiling code using the first versions of FORTRAN. His detractors (and everyone else) quickly learned the value of conserving programmer time vs. CPU time.
You have a ton of work to do and cannot take more than 16.7ms (60Hz) to do it in period. Heck given the recent move some have made for 144Hz monitors it leaves you with less than half the time (6.9ms).
Not to say that C++ is the only way to pull it off, just that games are a soft-real-time system which therefore have stricter requirements for performance.
In any case, the route people will hopefully take is to write the code in the obvious way, with bounds checks and all, and profile. Functions which take significant amounts of time can then be optimised more manually (and, bounds checks usually aren't the bottleneck).
I have personally never seen the bounds checks be a problem except in microbenchmark-like things, and those are almost always compiler bugs involving missed optimizations that the compiler could have done but does not presently. I think "the design of Rust does not guarantee the possibility of matching C++ performance unless you use unsafe code" is too strong a statement.
https://www.reddit.com/r/rust/comments/2nlis8/which_classes_...
If that were something to worry about, then wouldn't OpenOffice, LibreOffice, iWork, Google Docs, etc. all be in legal trouble right now for the same thing with .doc files?
I have no idea about the former, but if MS had any claim to a world built from scratch then Adobe would own everything ever made in Photoshop and Autodesk would own pretty much all video game content since the late 90s.
I'll probably revisit it soon now that 1.0 is fairly imminent, but prs are welcome of course!
graphiz is amazing for making graphs. My favorite interface for it is dorothy (https://github.com/daveray/dorothy).