[HN Gopher] Unreal Rust
       ___________________________________________________________________
        
       Unreal Rust
        
       Author : ibobev
       Score  : 125 points
       Date   : 2022-09-04 20:30 UTC (2 hours ago)
        
 (HTM) web link (maikklein.github.io)
 (TXT) w3m dump (maikklein.github.io)
        
       | Animats wrote:
       | _This is great, because Unreal is a C++ project that 's not so
       | easy to just Rewrite In Rust._
       | 
       | True. Although rewriting Nanite in Rust would be useful. Nanite
       | is a very clever data structure for meshes. It's brittle, and
       | full of internal relative addresses within the data item, so it's
       | very vulnerable to buffer overflows. If it becomes widely used
       | outside of UE, it might become something that gets supported in
       | GPU hardware.
        
         | RcouF1uZ4gsC wrote:
         | > It's brittle, and full of internal relative addresses within
         | the data item,
         | 
         | I am not sure how much you would gain by doing this.
         | 
         | Internal references are one of the things where it is very hard
         | to express in safe Rust what you want to do (see doubly linked
         | lists and graphs). You can get around that by using vectors and
         | indexes, but that is bypassing the borrow checker, and with it,
         | much of your safety and mutability checks.
        
           | amelius wrote:
           | Yes, Rust is great for tree-like data structures. Add one
           | non-tree edge to your graph and you're in big trouble.
           | 
           | This demonstrates the flexibility of GC'd languages, where
           | you don't paint yourself into a corner so easily.
        
           | oconnor663 wrote:
           | I always want to be careful with phrases like "bypassing
           | safety checks", because of course the Vec/index pattern is
           | 100% safe and (like any 100% safe Rust program) will
           | (approximately) never trigger undefined behavior. But it's
           | true that what was formerly undefined behavior will still be
           | a bug, where a stale index accidentally refers to a new
           | object that happens to get allocated in the same spot. You
           | can use slabs and generational indexes to catch these bugs,
           | but I don't know whether the performance cost of generational
           | indexes is acceptable in this case.
        
         | newpavlov wrote:
         | >Nanite is a very clever data structure for meshes. It's
         | brittle, and full of internal relative addresses within the
         | data item, so it's very vulnerable to buffer overflows.
         | 
         | Using bounds checking is likely to kill performance on such
         | data structures, while using `get_unchecked` or raw pointers
         | will keep the issues.
         | 
         | But even then, I would love to see Nanite implemented in Rust.
        
       | hertzrat wrote:
       | These discussions always remind me of some talks by Jonathan blow
       | where he argues rust doesn't solve the hard problems he needed it
       | to. There are podcast episodes with better discussions, but the
       | main one people link to seems to be this
       | 
       | I haven't used rust, but I sympathize with his problems with
       | pointers and learned a lot from the various ways people try to
       | solve them
       | 
       | https://m.youtube.com/watch?v=4t1K66dMhWk
        
         | [deleted]
        
       | Kukumber wrote:
       | Will it improve iteration time in Unreal?
       | 
       | Because C++ already is way too slow to compile wich hurts
       | iteration time, wich is why most people fall back to plain simple
       | blueprints, and even that can become quite heavy
       | 
       | Epic is working on a new scripting language that will improve
       | this
       | 
       | What Rust brings to game development and how it's better than
       | C/C++ in that regard?
       | 
       | Because you don't develop a game the same way, with the same
       | constraints as a driver for example
        
         | [deleted]
        
         | [deleted]
        
       | pornel wrote:
       | This is great, because Unreal is a C++ project that's not so easy
       | to just Rewrite In Rust.
       | 
       | It's also nice it uses bevy's ECS. It's made to fit Rust's type
       | system and borrow checking model, and is highly parallel. It's
       | really awesome how easy it is to distribute work across cores
       | with it, without risk of heisenbugs thanks to Rust's data-race-
       | safety guarantees.
       | 
       | I know game development sees traditional software best practices
       | as not applicable to them, but then games struggle with
       | showstopping bugs and single-core performance bottlenecks. I hope
       | someone will bet on Rust to show that things can be done
       | differently.
        
         | t8sr wrote:
         | Why do specifically Rust programmers think that people in every
         | domain are just misguided and waiting for someone to teach them
         | the right development practices? The sheer hubris...
         | 
         | The kind of bugs that games mostly struggle with these days
         | have nothing to do with the stuff Rust is targeting, like
         | memory safety. They are "business logic" problems with many
         | interacting systems resulting in unpredictable behavior, buggy
         | level geometry, or poorly scripted missions not accounting for
         | all player behavior. How exactly does Rust help with any of
         | that?
        
           | nynx wrote:
           | I mean, dude, I've seen the C++ written by organizations with
           | supposedly highly-competent programmers. I think maybe we
           | should let programmers get a little help from language
           | designers.
        
         | waboremo wrote:
         | Why would you think that? All of the game developers I've met
         | don't really view themselves as separate from traditional
         | software best practices, just that there's a lot more involved
         | in making a game than people are ever really aware of. They're
         | also among some of the most talented programmers, the stuff
         | they have to come up with is insanity sometimes, so it's
         | certainly not about them not caring about best practices.
         | 
         | Games aren't struggling because they're written in Unreal's
         | flavor of C++ (or whatever other currently existing engines and
         | their respective languages), there are insane deadlines always
         | being pushed. There is never enough time and never enough
         | money. Neither of these problems are solved with Rust, at least
         | not to a substantial degree.
        
           | Ygg2 wrote:
           | > there are insane deadlines always being pushed.
           | 
           | Higher compilations times aren't all bad
           | https://xkcd.com/303/
        
       | geenat wrote:
       | Also excited about the Python dialect coming to Unreal, which
       | should have a major effect on iteration time.
        
         | dagmx wrote:
         | Could you elaborate on Python dialect?
         | 
         | Unreal already supports full Python for some stuff. They do
         | also have a language called Verse in the works but I don't
         | believe that it has any relationship to Python
        
       | mrlonglong wrote:
       | And I was thinking this was referring to the unreal mode on the
       | 32 bit x86 processors which would have been very cool if it was
       | possible with Rust.
        
         | [deleted]
        
       | forrestthewoods wrote:
       | Neat!
       | 
       | I write a lot of C++ plugins that are used in both Unreal and
       | Unity. I like to think of them as "side loading". They can do
       | whatever they want, however they want. The API surface that
       | interacts with either engine is pretty minimal.
       | 
       | I think "use Unreal as a renderer" is underrated. You could
       | imagine writing your full simulation logic independent of the
       | AActor framework and then using Unreal just for rendering. For a
       | client/server game the server might not use Unreal at all!
       | 
       | I'm not sure how valuable it is to use Rust but also use Unreal's
       | framework and blueprints. Bevy + Unreal is a pretty fascinating
       | combo and how much lifting is done by each side can be done in
       | lots of ways.
        
       | vardump wrote:
       | I was almost certain this would be about running Rust under DOS
       | unreal mode, flat 32-bit address space in real mode.
       | 
       | https://en.wikipedia.org/wiki/Unreal_mode
        
         | [deleted]
        
       ___________________________________________________________________
       (page generated 2022-09-04 23:00 UTC)