I lived in a perfect OOP bubble for my entire life. Everything was peaceful and it worked perfectly. When I wanted to move that player, I do player.move(10.0, 0.0); When I want to collect a coin, I go GameMan -> collect_coin(); And when I really need a global method, so be it. I love my C++, I love my python and yes, I also love my GDScript (Godot Game Engine). They all work with classes and objects and it all works perfectly for me.

But oh no! I wanted to learn Rust recently and I really liked how values are non-mutable by defualt and such, but it doesn’t have classes!? What’s going on? How do you even move a player? Do you just HAVE to have a global method for everything? like move_player(); rotate_player(); player_collect_coin(); But no! Even worse! How do you even know which player is meant? Do you just HAVE to pass the player (which is a struct probably) like this? move(player); rotate(player); collect_coin(player, coin); I do not want to live in a world where everything has to be global! I want my data to be organized and to be able to call my methods WHERE I need them, not where they just lie there, waiting to be used in the global scope.

So please, dear C, Rust and… other non OOP language users! Tell me, what makes you stay with these languages? And what is that coding style even called? Is that the “pure functional style” I heard about some time?

Also what text editor do you use (non judgemental)? Vim user here

  • Wyre@lemmy.world
    link
    fedilink
    English
    arrow-up
    13
    ·
    8 months ago

    Your OO languages at their core just abstract patterns like using a *this pointer. OO is possible in any language once you understand how it works. You should just go back to C++ or whatever you’re comfortable with.

    • hydroptic@sopuli.xyz
      link
      fedilink
      arrow-up
      18
      ·
      edit-2
      8 months ago

      You should just go back to C++ or whatever you’re comfortable with.

      I wouldn’t want to discourage people from learning new languages

        • Wyre@lemmy.world
          link
          fedilink
          English
          arrow-up
          2
          ·
          8 months ago

          You should of course do as you like. It’s just that if OO is a real feature you require then you should choose a language with that feature. But tbh you should chose a real OO language like Ruby.

          • Smorty [she/her]@lemmy.blahaj.zoneOP
            link
            fedilink
            arrow-up
            4
            ·
            8 months ago

            What’s not real about C++? I do want to use a compiled language for now, as I have toyed around with python and GDScript for a bit too long now. I wanna write some faaast code so I can do things unneccesarily quickly.

            • Wyre@lemmy.world
              link
              fedilink
              English
              arrow-up
              3
              ·
              8 months ago

              It’s quite real but if you really wanted an OO experience you’d choose something like Ruby. Really check it out you may find you like it.

            • Riskable@programming.dev
              link
              fedilink
              English
              arrow-up
              3
              ·
              edit-2
              8 months ago

              You want speed? Rust is a good choice. Probably the best choice based on the objective benchmarks and more subjective things like ease of making your code multi-threaded.

              Also, many would argue that “Rust is the future.” Now that I know Rust, C and C++ seem like old, crufty things that annoy me if I’m forced to use them 🤷

    • Kairos
      link
      fedilink
      arrow-up
      15
      ·
      8 months ago

      Methods are just functions that take in a struct self pointer.

      • Smorty [she/her]@lemmy.blahaj.zoneOP
        link
        fedilink
        arrow-up
        3
        ·
        8 months ago

        Hm… Never though about it that way. I guess that really is how they work, don’t they?.. But it’s all cool and combined in OOP so it works so nicely and stuff.

        • Kairos
          link
          fedilink
          arrow-up
          2
          ·
          8 months ago

          That’s because Java and C don’t make it explicit. Python and Golang and others do.

        • Kairos
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          8 months ago

          It’s also how inheritance works.

          Because struct members are just offsets of a memory address, to add more member types, you (as in the compiler) just create a new struct with the same offset for the inherited types and new, further down offsets for new member types.