loafty_loafey

joined 1 year ago
[–] [email protected] 4 points 3 months ago (1 children)

Kinda mean of you calling Billy precancerous masses like that smh

[–] [email protected] 23 points 7 months ago

Late response and you might have already gotten an answer, but what you wrote is exactly the same as:

// Define our player struct 
struct Player {
     x: f32,
     y: f32,
     rotation: f32
}
// Define the methods available to the player struct 
impl Player {
     pub fn move(&mut self, x: f32, y: f32) {
          self.x += x;
          self.y += y;
     }

     pub fn rotate(&mut self, by: f32) {
           self.rotation += by;
     }
}

fn main() {
    let mut player = Player { x: 0.0, y: 0.0, rotation: 0.0 };
    player.move(10.0, 10.0);
    player.rotation(180.0);
}

The code example you wrote does not use anything that is exclusive to OOP languages as you are simply encapsulating values in a class (struct in the Rust case).

Unlike C++, the biggest difference you will find is that Rust does not have the same kind of inheritance. In Rust you can only inherit from traits (think interfaces in Java/C# or type classes if you have ever used Haskell), whereas in C++ and other OOP languages you can also inherit from other classes. In a lot of cases just using traits will suffice when you need inheritance. :)

So in conclusion, no global functions! You still have the same name spacing and scoping as you would in C++ etc!

Ps. I use VScode because it rocks with Rust, and while Rust is heavily inspired by functional programming languages, it is not a pure functional programming language (nor is C) but that is another can of worms.

[–] [email protected] 3 points 8 months ago

From my experience it happens with any XWayland window that fails to hit your display refresh rate. Makes programs such as vscode or element almost impossible to use on high Hz screens, as their max fps is locked to 60.

[–] [email protected] 2 points 11 months ago

The original Dusk was written in Unity and just used the same map format as Quake. I would assume those aspects are still true for the rewrite, but I could be mistaken.

[–] [email protected] 2 points 1 year ago

Ohhh I must be confusing the two! But yea, Regex is just NDAs in text form! The course I have had on it is one of my favorites! Really fun stuff

[–] [email protected] 3 points 1 year ago (2 children)

You are probably thinking of Temporal logic which allows us to model if algorithms and programs terminate etc! It can be represented by using state machines tho!

[–] [email protected] 20 points 1 year ago

Regex is actually just a way to write (Epsilon) non determistic state automata(ε-NDA) using text! ε-NDA comes from automata theory and they are just a somewhat powerful way to describe state machines! They can kind of be seen as a stepping stone to things like Context-Free Grammars which is what language parsers use to define their language/parsers, and Turing machines! Regex is a fundamental part of computer science, and they are of course incredibly useful in string validation due to their expressive power! If you study at uni and get the chance to take a course in automata theory I recommend it! Personal favorite subject :)