
A Doom Renderer written in Rust - adamnemecek
https://github.com/cristicbz/rust-doom
======
temuze
Holy crap, this is f __*ing awesome. Rust has made systems programming
exciting for me again.

Seeing well written Rust code like this (also, the repos on Github
[https://github.com/trending?l=rust](https://github.com/trending?l=rust)) has
been a really good learning experience. As a Rust newbie, I only wish there
were better examples of testing in public Rust repos.

~~~
jnbiche
>As a Rust newbie, I only wish there were better examples of testing in public
Rust repos.

Testing is incredibly easy. The reason you may have missed the testing is that
tests are often in the same file as tested code. Go back and check, it's very
common in Rust to test your code. And it's as simple as writing:

    
    
      #[test]
    

on the line before your unit test function, and then using some of the unit
test macros in std like `assert` and `assert_eq` along with `fail` to perform
the tests[1].

Then you test your code by running the normal rustc command but with the
`--test` flag. A test runner with very attractive output is built into the
compiler.

Rust unit testing is just about the easiest testing I've ever used, right up
there with golang. I love that it's built into the language.

Also, the `cargo` package manager makes everything -- including unit testing
-- incredibly convenient. And I say this as someone who cringes every time a
language comes out with yet another package manager or build tool (ahem, .js).
But in the case of rust's cargo, it's incredibly worth it to use a new package
manager, and so much better than a Makefile (although it's quite easy to
integrate makesfiles with cargo).

1\. [http://doc.rust-lang.org/std/index.html](http://doc.rust-
lang.org/std/index.html)

~~~
steveklabnik
The guide has a whole section on this: [http://doc.rust-
lang.org/guide.html#testing](http://doc.rust-lang.org/guide.html#testing)

And we even have a full guide on testing, though I haven't checked it lately:
[http://doc.rust-lang.org/guide-testing.html](http://doc.rust-lang.org/guide-
testing.html) (it's on the todo list)

------
bmh100
These are really valuable projects. It's not only a nostalgic project to hack
on. It's also a learning tool for those interested in game programming,
idiomatic Rust, and C-to-Rust conversion. Even building complex software from
requirements. Thank you, Cristi Cobzarenco.

~~~
Bzomak
Indeed! Looking at projects like this and Piston are helping me get to grips
with the language in a much more useful manner than working through the
various guides/tutorials.

------
yen223
Stuff like that is the reason why I'm excited for Rust's future. It's really
an amazing language.

------
comex
This is sort of off topic, but the fact that every change to the source
requires (on my machine) 3-4 full seconds to recompile, _without_
optimization, is indicative of the compiler performance problems that remain
my main roadblock with Rust.

~~~
melling
Turbo Pascal and Delphi had incredibly fast compilers. Why can't we make fast
compilation a required feature today? We should never have to wait for the
compiler/linker.

[http://prog21.dadgum.com/47.html](http://prog21.dadgum.com/47.html)

~~~
pcwalton
They also didn't have the zero-cost memory safety abstractions that Rust has.
Nor did they do much optimization.

That said, we're working on compilation speed. The focus so far has been
getting the language in shape and runtime performance of the generated code,
not compilation speed (although we've picked most of the low-hanging fruit in
compilation speed anyway).

~~~
cageface
How optimistic are you that the compilation speed can be significantly
increased? Are there a lot of easy optimizations available or is this just the
price paid for extra compile time safety?

I'm not really a fan of Go but waiting for the compiler can be a pretty
significant productivity killer on larger projects. Their fast compilation
times are a pretty big selling point for what is (IMO) an otherwise
underwhelming language design.

~~~
pcwalton
> How optimistic are you that the compilation speed can be significantly
> increased? Are there a lot of easy optimizations available or is this just
> the price paid for extra compile time safety?

The vast majority of compile time for optimized builds (80%-90%) is spent in
code generation and optimization in LLVM.

For unoptimized builds, most of the compile time is spent in the typechecker
doing type unifications for method lookup. With some optimizations to quickly
reject method candidates I suspect this can be greatly improved.

Incremental compilation for the fast turnaround is being worked on and there
has been significant progress, to address comex' complaint.

> Their fast compilation times are a pretty big selling point for what is
> (IMO) an otherwise underwhelming language design.

Go 6g/8g also doesn't do much optimization by comparison to GCC/LLVM. (Rust
uses LLVM.)

~~~
pjmlp
> Go 6g/8g also doesn't do much optimization by comparison to GCC/LLVM. (Rust
> uses LLVM.)

You should compare with gccgo, though.

------
PuercoPop
A similar project, Quake 2 map renderer written with Julia
[https://github.com/jayschwa/Quake2.jl](https://github.com/jayschwa/Quake2.jl)

~~~
pjmlp
This is cool! Thanks for posting it.

------
aidos
OT but it's wonderful to see those screenshots again. It's been decades since
I played that game and I can still remember the hidden tricks in those rooms.

------
Jemaclus
This is awesome. Would you be interested in writing sort of a tutorial on
building something like this? (Obviously much more basic, but still...)

------
shmerl
How does it interact with OpenGL? Using C bindings?

~~~
bjz_
We have a syntax extension that uses kronos' xml registry
([https://www.opengl.org/registry/#specfiles](https://www.opengl.org/registry/#specfiles))
to generate symbol a loader (somewhat like GLEW) at compile time.
[https://github.com/bjz/gl-rs](https://github.com/bjz/gl-rs)

~~~
shmerl
Thanks for the pointer!

------
TIHan
This is very cool. Really love seeing devs doing stuff like this.

------
Alupis
why do these post's titles keep getting moderated?

"Doom I/II written in Rust" is a fine title for what this is.

~~~
mercurial
The new title is more accurate. I sometimes disagree with moderated titles,
but in this case it's not an issue.

