Live data from Hacker News

Making a Game in Rust

michaelfairley.com

21–30 of 125 posts

Re: Making a Game in Rust

#21
post #4
post #3

I wasn't even aware that you were allowed to ship Rust code in iOS apps, I thought that Apple had a whitelist of allowed languages? EDIT: And for those interested, you might want to check out Rust's recent inclusion in a AAA title: https://www.reddit.com/r/rust/comments/69s225/rust_makes_it_... :P

Really? How do they know what the representation of the object code was before compilation? Seems like if they had a whitelist it would be difficult to enforce.

The biggest problem I faced with Rust and macOS/iOS is related to Apple's requirement for bitcode on all submitted code to the App Store for Watch and appleTV applications.

This internal Rust discussion focuses on it for more details: https://github.com/rust-lang/rust/issues/35968

This gist is that Apple is requiring bitcode, but isn't giving easy access to the LLVM version they use for their own tools. This means there's not a path forward to support bitcode generation from Rust that would align with Apple's requirements. This currently only effects iOS on Watch and TV, meaning you can easily target macOS and iPhone without issue, but I fear that the writing is on the wall.

Re: Making a Game in Rust

#22

> I had two or three false-start attempts at learning Rust where I’d spend a few hours with it, not get anything done, and put it down until a few months later This sounds (sort of) encouraging. I was kind of expecting to learn it by putting in an hour here and there e.g. 2-4h/month. But I'm beginning to think that might not cut it...

Go is a language that you can absolutely learn like that, and it's pretty amazing. (Python, too) Rust ... isn't. I love Rust, but you do need to put some dedicated time into learning it. We're hoping to improve this!

Yeah I'm guessing it's a treshold you need to get over that requires at least a bit (a week, two weeks, a month) of doing it more than sporadically. Wish I had a week I could do 40h rust in, but that's sadly not the case. I'm doing baby steps with Rust now but it almost feels like the language is walking away faster :)

Re: Making a Game in Rust

#23
post #2

Great stuff, lines up a lot with what I'd care about as an ex-gamedev and spending a bit of time with Rust. One minor point: > First class code hot-loading support would be a huge boon for game developers. The majority of game code is not particularly amenable to automated testing, and lots of iteration is done by playing the game itself to observe changes. I’ve got something hacked up with dylib reloading, but it re…

Lua is great and generally the right tool for this sort of thing.

As an alternative, though, there are several Rust-based scripting languages that attempt to expose some of the power of the type system, etc., while being more amenable to dynamic loading, REPL, etc:

http://libs.rs/scripting/

Re: Making a Game in Rust

#25

> I had two or three false-start attempts at learning Rust where I’d spend a few hours with it, not get anything done, and put it down until a few months later This sounds (sort of) encouraging. I was kind of expecting to learn it by putting in an hour here and there e.g. 2-4h/month. But I'm beginning to think that might not cut it...

Go is a language that you can absolutely learn like that, and it's pretty amazing. (Python, too) Rust ... isn't. I love Rust, but you do need to put some dedicated time into learning it. We're hoping to improve this!

Whilst an easy start is nice, any language that you can pick up with no effort just means you're learning the same language + paradigm that you already know with a few differing features (in go's case CSP). Nothing wrong with that, CSP is awesome etc

I'm not a rust dev (definitely interested in picking it up though), but heavily into clojure and learning haskell slowly on the side. I hear this complaint a lot from people who think that because they learnt C#, Go, Java and Swift in a weekend that all languages will be just as quick to stick in their heads.

Re: Making a Game in Rust

#26
post #6

> The include_* macros are great for “packaging”. Being able to compile small assets directly into the binary and eschewing run time file loading is fantastic for a small game. For C/C++/etc devs looking for something similar, BFD objcopy supports an "-I binary". It will emit an object file with _binary_objfile_start, _binary_objfile_end and _binary_objfile_size symbols. But I have got to say that making it a languag…

That has also been a feature of Windows for quite some time, you have your IIRC .exe icon and various string resources packaged in the .exe itself. It's pretty useful on the whole.

Re: Making a Game in Rust

#27
post #2

Great stuff, lines up a lot with what I'd care about as an ex-gamedev and spending a bit of time with Rust. One minor point: > First class code hot-loading support would be a huge boon for game developers. The majority of game code is not particularly amenable to automated testing, and lots of iteration is done by playing the game itself to observe changes. I’ve got something hacked up with dylib reloading, but it re…

Lua is great and generally the right tool for this sort of thing. As an alternative, though, there are several Rust-based scripting languages that attempt to expose some of the power of the type system, etc., while being more amenable to dynamic loading, REPL, etc: http://libs.rs/scripting/

Dyon (from that link) looks very cool! I'd also like to add that JavaScript is another language used in this arena, and there is a crate with V8 bindings (https://crates.io/crates/v8). Even Garry Newman (creator of Garry's mod) wrote that he believes JS would have been better than Lua for scripting: https://garry.tv/2014/08/16/i-fell-out-of-love-with-lua/

Re: Making a Game in Rust

#28

Earlier quoted context omitted.

While I do agree that it is possible to do something like that, I think we can all agree that the following (available in Rust) is soooooo much nicer: let stuff = include_bytes!("my.file");

Now I have to rewrite my arcade game emulator in rust just so I can use that to load rom images...

include_bytes! is for compile-time inclusion of files though, not for runtime.

Re: Making a Game in Rust

#29
post #10
post #3

I wasn't even aware that you were allowed to ship Rust code in iOS apps, I thought that Apple had a whitelist of allowed languages? EDIT: And for those interested, you might want to check out Rust's recent inclusion in a AAA title: https://www.reddit.com/r/rust/comments/69s225/rust_makes_it_... :P

Rust as an art asset! The dimly lit room, the red glowing Rust code on the wall, the main character with a large gun and the commenter saying that requires and unsafe block. The Reddit comments are great. Edit - Could you tell me why you downvoted me. This wasn't even the slightest bit argumentative, so I am not sure who I angered.

I didn't downvote you, but I also don't understand what your comment even means. Dimly lit room... what? What Reddit discussion are you referring to? What does your comment have to do with writing games in Rust?

Re: Making a Game in Rust

#30

Earlier quoted context omitted.

Lua is great and generally the right tool for this sort of thing. As an alternative, though, there are several Rust-based scripting languages that attempt to expose some of the power of the type system, etc., while being more amenable to dynamic loading, REPL, etc: http://libs.rs/scripting/

Dyon (from that link) looks very cool! I'd also like to add that JavaScript is another language used in this arena, and there is a crate with V8 bindings ( https://crates.io/crates/v8 ). Even Garry Newman (creator of Garry's mod) wrote that he believes JS would have been better than Lua for scripting: https://garry.tv/2014/08/16/i-fell-out-of-love-with-lua/

Yeah, Lua certainly has it quirks. However binding to JS is a huge endeavor. For instance that v8 crate doesn't easily expose a way to call Rust from JS which is trivial in Lua.

Also the JS runtime is huge and the build system is complex. You can run Lua in ~400kb or less and LuaJIT tends to walk over any other jitted interpreted runtime.

Post reply on HN