Announcement

Collapse
No announcement yet.

Rust for UE ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Now all you need is an ARMY of programmers to port Unreal's code to Rust language
    Related question.... Can 'Magic Nodes' ever be extended to support simpler scripting languages?

    Comment


      #17
      In theory yes.
      In practice I would need funding to do that, because that would become a full-time job for me.

      ______

      Also, what exactly do you mean with "simpler"?
      My first programming language I ever used was BlitzBasic, and I still love the way it was structured.
      Do you mean THAT simple or you mean "simple like C# and Java"?! ( those aren't simple, they just hide complexity)

      https://en.m.wikipedia.org/wiki/Blitz_BASIC#Sample_code
      | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

      Comment


        #18
        BrUnO XaVIeR
        Originally posted by BrUnO XaVIeR View Post
        In theory yes. In practice I would need funding to do that, because that would become a full-time job for me.
        Good to know, cheers for the confirm. Will you create a forum thread or blog post about this feature sometime?
        (Something specific for the community to rally behind, especially if Sweeney's reddit turns out to be vaporware)...

        Originally posted by BrUnO XaVIeR View Post
        Also, what exactly do you mean with "simpler"?
        By simpler I mean BlitzBasic / OfficeVBA / LUA. While Java / C# are easier vs C++, neither are simple as BP.
        Question: If you got funding, could 'Magic Nodes' ever be used to expose parts of the engine to Blueprints etc?
        Last edited by EntrpriseCustomr; 12-30-2019, 09:03 AM.

        Comment


          #19
          I have no idea...
          I can't drop my job to do it, so what I am saying is it's probably not going to happen anytime soon.
          I wouldn't encourage anyone to wait for it. Can be done, but I won't even talk about 'whens' and 'ifs'... right now I only tinker with these things on weekends.
          | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

          Comment


            #20
            Originally posted by BrUnO XaVIeR View Post
            I went over a small test just to see if Unreal would allow this or if it would complain...
            Turns out it's possible to make it work indeed:


            Now all you need is an ARMY of programmers to port Unreal's code to Rust language
            Good luck lol
            I'm not familiar with Rust's FFI stuff, how much work would it be to transfer more than primitive data types across the boundary? Would it just require doing the mapping into structs on Rust side and annotating them with #[repr(C)]? What about C++ side?

            Comment


              #21
              I'm not familiar either, but I think Rust has a "Box" (it's literally called box) mechanism which you can use to collect C data such as complex structs and then manipulate them within an unsafe block.
              I think it can also share pointer addresses with C code, but I'm not sure how that works either.



              Their docs have this example, calling C function from Rust side:

              Code:
              extern "C" {
              ​​​​​​ fn abs(input: i32) -> i32;
              }
              
              fn main() {
                  unsafe {
                      println!("Absolute value of -3 according to C: {}", abs(-3));
                  }
              }
              | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

              Comment


                #22
                Originally posted by BrUnO XaVIeR View Post
                I'm not familiar either, but I think Rust has a "Box" (it's literally called box) mechanism which you can use to collect C data such as complex structs and then manipulate them within an unsafe block.
                I think it can also share pointer addresses with C code, but I'm not sure how that works either.
                Box is just used for managing the ownership of heap allocated data, I don't think it's required here (not sure how trait objects would work here, if at all).

                Comment


                  #23
                  Btw, I've found something very useful I didn't know existed:

                  https://rust-lang.github.io/rust-bindgen/
                  | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                  Comment


                    #24
                    I would reconsider UE4/5 over Unity if it had Rust. Especially since Unity may never support Rust. While I could live with C#, it's not as ideal for games as Rust because of its GC.

                    The thing with Rust is that it is intended to replace C/C++ in the entire industry altogether, not just in game development. And it is getting very close to that goal.

                    It's voted 4 times(if I recall) in a row as the Github favorite.

                    It is almost as accessible as C# but as fast as C/C++.

                    It's even as a "system language" a safe language. No seg faults, no dangling pointers, no nulls, no headers, and it got safe threads. Data Oriented design over the OOP non-sense.

                    It's eventually going to be fully embraced by Microsoft. According to them, C/C++ is not a valid choice anymore. 70% of their security flaws could have been avoided with Rust. Security may not be an issue with games, at least offline games, but when Microsoft makes the final move to fully embrace it. Rust obviously will come to Visual Studio and the entire MS ecosystem, including DirectX. A COM Rust binding generator is already in the works by MS.

                    As somebody who comes from C -> C# -> F#. I got zero regrets so far with Rust. I'm still amazed that a "system language" could be designed in such an accessible way, almost as if it was something like managed code C#/F#.

                    Originally posted by BrUnO XaVIeR View Post
                    Now all you need is an ARMY of programmers to port Unreal's code to Rust language
                    Good luck lol
                    As somebody who follows not too closely, bot close enough the evolution of AI these days. And witnessed the super human genius of AI. It wouldn't come as a surprise to me if somebody like MS could come up with a AI based translator that can convert full C/C++ code to idiomatic Rust. No need to waste time on mere bindings for UE. Convert the entire engine.

                    For all we know UE5 could be already on a road map for such a full conversion to Rust. Like I said, Rust is meant to replace C/C++ not just to compete with it as yet another language. And so far the signs show that it does a very good job at it. Not to mention that such a converter would be a huge use outside of MS as well. There is certainly need for that.

                    Comment


                      #25
                      Unreal is 20+ years of C++; not happening.
                      | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

                      Comment


                        #26

                        Originally posted by NickelCoating View Post
                        It's eventually going to be fully embraced by Microsoft. According to them, C/C++ is not a valid choice anymore. 70% of their security flaws could have been avoided with Rust. Security may not be an issue with games, at least offline games, but when Microsoft makes the final move to fully embrace it. Rust obviously will come to Visual Studio and the entire MS ecosystem, including DirectX. A COM Rust binding generator is already in the works by MS.
                        Divisive topic, but I'm not sure I'd expect anything that innovative from Microsoft...
                        Its more like Facebook or Google etc would work on something in that area imo.

                        Originally posted by NickelCoating View Post
                        No seg faults, no dangling pointers, no nulls, no headers, and it got safe threads. Data Oriented design over the OOP non-sense.
                        Interesting, I'd like to learn more, as I had thought Rust still had C++ level of complexity.
                        When coding with complex languages, its best to keep the problem simple - if possible.
                        But in game dev the API is rarely simple and neither is the problem, that's the problem!

                        Comment


                          #27
                          Ah, yes, Rust ... another in a long line of languages created to replace C++. Who remembers Vala, D, Limbo, ...
                          "I have harnessed the shadows that stride from world to world to sow death and madness."

                          Comment


                            #28
                            Originally posted by EntrpriseCustomr View Post
                            Interesting, I'd like to learn more, as I had thought Rust still had C++ level of complexity.
                            When coding with complex languages, its best to keep the problem simple - if possible.
                            But in game dev the API is rarely simple and neither is the problem, that's the problem!
                            I'm still learning Rust myself. But in general it's less complex compared with C++ and OOP. Though, for the record, aside C#/F#, I know way more about C than C++.

                            Rust is more like C, plus functional programming and polymorphism via interfaces called "traits". When I first saw Rust I actually confused it with MS's F#. Both are derived from ML and OCaml, etc, too. But to be clear for those who don't know yet, rust is native code, not managed. It's a "system language" used for anything really, game engines, embedded, and even operating systems.

                            All variables are immutable by default. There are no classes in Rust. You only get structs and enums. And enums can hold data. No headers.

                            Yes, you can define methods/member functions even with structs. Every "implementation" lets you define a bunch of methods for a struct as if it was a class. "Trait" definitions are like interfaces, and define method signatures that can be shared across structs implementations.

                            Yeah, it looks like the best of OOP but without the worst of OOP like inheritance. Class types may not be the worst, but they are totally useless as Rust proves it that mere structs work, too, when you "separate data from behavior". Yes, you can do a more data oriented approach in C++, too, but Rust does that naturally.

                            Some say that C++ got a bad reputation not because it is so bad, but because new programmers abuse it that bad. Shows that C++ is more complex than Rust out of the box while doing the same thing. Rust wouldn't allow you to do any other way.

                            And of course we use pointers as usual, but they are checked at compile time with the "borrow checker" that defines boundaries and memory owner ship that can at run time be auto freed when out of scope. It's like a GC, but it's at compile time GC, which makes Rust virtually as fast as C++ without the GC hiccups at run time that you can find in C#/F# yet still being at the same memory safety levels as managed code languages.

                            Coupled with immutable values you get thread safety, but no undefined behavior, no dangling pointers, no seg faults, no buffer overflows, no memory leaks, etc. There are no nulls in Rust. So no run time exceptions because of that either. All this is the stuff of nightmares in C/C++ no matter how hard you try or skilled you are.

                            But, you can still go "C" in Rust with the "unsafe" keyword code block/functions that can be inside normal Rust code anywhere. Though, it's C when you use C APIs. Otherwise unsafe code is used to do very low, and specific hardware programming, or just some performance optimizations that allow you to use pointers in exotic ways but without the compiler throwing an error that would prevent your project form successfully building.

                            There are other features, too. You won't find silly C like:
                            Code:
                            for (int i; i < 100; i++)
                            Instead you do this.

                            Rust uses also "functional programming" paradigms, but that's not really new to C++ either. I just mention it because there is value in FP if done on a middle ground level. F# may go a bit overboard with FP. Even the signatures in F# are "->" math like single parameters that can make you wonder what the heck when you miss one parameter and the entire signatures changes as the compiler tries to infer the type. F# got the monad in its own way. And fanctors. So, F# got a bit too much of FP if you ask me. I'd rather use Rust that is more C like. But heck, F# is a very clean language. It's just too bad that it's also managed code like C#.

                            But for the record regarding managed code performance. The game Space Engineer was written fully in C#. It's not too bad, but I'm not under the impression that Rust is much harder than C#. So, why bother with C#? I see people using C/C++ for GUI, let that sink in...

                            Originally posted by EvilCleric View Post
                            Ah, yes, Rust ... another in a long line of languages created to replace C++. Who remembers Vala, D, Limbo, ...
                            Well, ideally it should have been C/C++ that should have evolved this much, and they do evolve but so slow that it always allowed yet another language to spawn in the first place.

                            C++ got rid off the headers only now. And it's still an unsafe language.

                            Rust got "editions". Current is 2018, seems Rust can introduce breaking features much faster than other languages because of that. Internally it got three intermediate layers. Any binary compiled in 2015 edition can mix with 2018 and so on.

                            The IDE can be shallow for Rust. I use CLion with a Rust plugin, but the IDE support got better. And currently there is a lot of push for IDE support because soonish VS 2021 may be here. And the Rust language team clearly understands that it needs the support of MS because it ain't just about the language itself. It's also about jobs, so programmers having access to that language on a professional basis. MS got a lot of jobs internally. So, this isn't just about VS supporting Rust either. I don't even user VS, I use CLion.

                            Comment


                              #29
                              The video below compares C++ vs Rust on Polymorphism. It's a bit older though, it doesn't include C++ 20.

                              In short, Rust is more compact and more accessible: https://www.youtube.com/watch?v=VSlB...&index=17&t=0s

                              C++ Rust
                              Overloading Traits
                              Templates Traits
                              Concepts Traits
                              Virtual Functions Trait Objects
                              Virtual Concepts Trait Objects
                              Variants Enums

                              Comment


                                #30
                                C++98, C++03, C++11, C++14, C++17, C++20, C++23, C++26, ...
                                C++ is constantly evolving, and the best of all: backwards compability.

                                Someone once said:

                                to go into a new language, the only possible alternative is to make it very slowly supporting, all the time, the past. Any violent transition is impossible..
                                Why Rust will never replace C++? Because Rust doesn't provide us with a slow and adaptive transition, like C -> C++.

                                And so, Rust will have the same fate as every other pretender.
                                Last edited by EvilCleric; 06-22-2020, 01:47 PM.
                                "I have harnessed the shadows that stride from world to world to sow death and madness."

                                Comment

                                Working...
                                X