Due to potential new direction of D, I’m looking for some escape route just in case. I’m primarily a gamedev, so no functional programming languages like Rust or Haskell. Also one of the features I dislike the most in C/C++ is the super slow and super obsolete precompiler with its header files, so no zig, I don’t want to open two files for editing the same class/struct. Memory safety is nice to have, but not a requirement, at worst case scenario I’ll just create struct SafeArray<Type>. Also I need optional OOP features instead of reinventing OOP with all kinds of hacks many do when I would need it.

Yes I know about OpenD, and could be a candidate for such things, just looking into alternatives.

          • ZILtoid1991@lemmy.worldOP
            link
            fedilink
            arrow-up
            0
            ·
            13 days ago

            Classes can be useful for abstraction. Just because they often overused doesn’t mean they’re bad.

            Without an explicit class, I would either:

            • had to reimplement them in a language without them (which looks extremely ugly and can be unsafe),
            • create an “omnistruct” that keeps track of all posssible field (only looks a bit ugly),
            • use uglier virtual functions for cases when I would need local states (doStuff(cast(void*)&localstate, values) vs localstate.doStuff(values)).

            While structured programming was a godsend to the chaos preceding it, newer programming paradigms should have been instead seen as tools rather than the next dogma. OOP got its bad name from languages that disallowed its users to develop without classes, and enterprise settings making its devs to implement things that could have been simple functions as classes, sometimes complete with factories.

            Same is with functional programming. There’s clearly a usecase for it, but isn’t a Swiss-army knife solution for all problems of programming.

            • MajorHavoc@programming.dev
              link
              fedilink
              arrow-up
              0
              ·
              edit-2
              13 days ago

              Well said.

              Here I am trying to wind people up and you’re responding with thoughtful nuanced consideration.

              You make some great points.

              I’ll add - for folks reading along - I do think a class is still almost always an anti-pattern, even with all the OOP class function and factory pattern stuff removed.

              I also feel (as you referenced):

              • Functions being forced to reside inside objects is just stupid.
              • Factory patterns are horrible, because they mix config into program code, maximizing uncertainty when debugging

              And also:

              • Inheritance is almost always a worse idea than an interface.
              • classes tend to have additional fancy tooling to make it easier to carry state data around - which is usually a bad idea

              State data is a necessary evil in most programs.

              I’ve found that most advanced class object implementations treat program state data more like a pet than a threat.

              Sorry for the long response - I know you don’t need it - you know what kind of tool you’re looking for.

              I figure they extra detail above might provide food for thought for folks reading along who are surprised there’s even contrasting opinions on classes.

              (And I feel a little bad for not really posting anything very useful earlier in the thread.)

              • seth@lemmy.world
                link
                fedilink
                arrow-up
                0
                ·
                12 days ago

                Factory patterns are horrible, because they mix config into program code, maximizing uncertainty when debugging

                I’ve always hated factory patterns because I find them unintuitive, but I couldn’t articulate why I find them that way or even organize the reasons why in my head. I just recognized them as a frequent source of annoying debug sessions. I envy your ability to concisely convey something like this.

            • BatmanAoD@programming.dev
              link
              fedilink
              arrow-up
              0
              ·
              13 days ago

              You don’t need to do any of those things with Go or Rust. Interfaces/traits provide the capability for dynamic dispatch.

            • SorteKanin@feddit.dk
              link
              fedilink
              arrow-up
              0
              ·
              edit-2
              13 days ago

              The problem with classes is inheritance. Inheritance is just a bad idea and a bad way to structure stuff if you ask me.

              Rust fixes this neatly with traits that basically provide the same benefits as classes without any of the downsides.

        • calcopiritus@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          13 days ago

          Interfaces (traits in rust) are the best imo. Way better than raw structs in C or the mess that is inheritance.

          What I don’t like about go’s interfaces is that they’re implemented implicitly. I much prefer java’s and Rust’s way to implicitly say which classes/structs extend/implement which interfaces.

      • BatmanAoD@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        13 days ago

        These are extremely superficial observations. You should learn more about each of these languages before dismissing them; Go is especially easy to learn.

        (I quite dislike Go, actually, but “it has no classes” is nowhere near a valid reason not to learn a language.)