Revolutionize Your Unity Game with Optionals and Monads

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 พ.ย. 2024

ความคิดเห็น • 38

  • @git-amend
    @git-amend  6 ชั่วโมงที่ผ่านมา +6

    Happy Sunday! Hit the LIKE button if you learn something new today! 👍

    • @puntalic
      @puntalic 6 ชั่วโมงที่ผ่านมา +1

      Keep hitting that like button, since i learn somthing every Sunday. Thanks!

    • @git-amend
      @git-amend  6 ชั่วโมงที่ผ่านมา

      Nice! You're welcome!

    • @hop3studio511
      @hop3studio511 5 ชั่วโมงที่ผ่านมา

      With this kind of tutorial, pressing like is so cheap price, keep it up sensei

  • @RogueWolf_Dev
    @RogueWolf_Dev 3 ชั่วโมงที่ผ่านมา +5

    I absolutely love your tutorials, it's like getting 1 year of experience in less than 20 minutes.
    I'm very much using null values as a caveman right now as I tried using the nullables from C# with Unity but ran into all kinds of weird problems like having to have preprocessor directives all over the place and I think in the end it didn't even work so I just gave up.
    Coming from JS I sorely miss the ?. syntax which I'm still not sure how much it's supported or not in C# and Unity. Like Unity objects say not to do it, though it seems to work most of the time.
    These are really interesting techniques, especially getting two types out of a statically typed language in a clean way was something I always struggled with.
    Keep it up man, your videos are packed with insane value

    • @git-amend
      @git-amend  3 ชั่วโมงที่ผ่านมา

      Thanks for the awesome comment! Nulls with UntiyEngine.Object are a pain, especially with null coalescing operators. Check out the extension method we created to handle this, about 1/2 way through this video here: th-cam.com/video/Nk49EUf7yyU/w-d-xo.html
      The 'OrNull' extension method is in the Utility Library link in description. Cheers!

    • @CheddarGoblinDev
      @CheddarGoblinDev 34 นาทีที่ผ่านมา

      so true - it's always something new for me even with my 13+ years of experience. I really wonder where he gets his resourcen from. You can't tell me he is doing all those nify patterns and paradigms at regular work!

  • @Cryosimorgh
    @Cryosimorgh 5 ชั่วโมงที่ผ่านมา +2

    It was just last week that I had to bang my head against a brick wall to make Option myself lol.
    nice vid.
    Options are far better than they are given credit for

    • @git-amend
      @git-amend  5 ชั่วโมงที่ผ่านมา

      Nice, I agree!

  • @Luciphear
    @Luciphear 51 นาทีที่ผ่านมา

    Honestly, I've not been this excited to see a new upload since Brackeys, and I mean no disrespect towards Brackeys but I think your videos are so much more valuable and informative.
    I think you should keep making these informative/introductive, more isolated video explanations and demonstrations, but have you considered also making a series of sorts, short courses which span over a few videos, utilising several of the concepts and patterns you've made videos of in the past, to show the workflow and thought-process of how to tie things together?
    There's plenty of code-alongs and "how to make " out there, but I think the majority of them are detrimental even. There's been so many videos, especially when I was first starting out, that just left me more confused and feeling less knowledgeable than when I first started watching them, because they would keep introducing new terms, concept and patterns without properly teaching you the tools but just followed the "just-trust-me-bro-programming-pattern" (totally not a term I just made up).
    I honestly think your videos should even be sponsored/featured in the tutorial section of the Unity hub.
    It'd definitely be more planning and effort to make a tutorial-project, so I wouldn't blame you if you feel that it's too much of an undertaking, but I do believe that it'd be amongst, if not *the* most useful and informative learning sources for Unity available. (You also have a really good voice so it's easy to stay focused and listen!)

  • @bogoid
    @bogoid 25 นาทีที่ผ่านมา

    I'd like to add that a Monad is a monoid in the category of endofunctors

  • @marlonruvalcaba386
    @marlonruvalcaba386 2 ชั่วโมงที่ผ่านมา

    Thanks for sharing another great introduction tutorial.

    • @git-amend
      @git-amend  2 ชั่วโมงที่ผ่านมา

      My pleasure!

  • @jeffreyhersh908
    @jeffreyhersh908 5 ชั่วโมงที่ผ่านมา +2

    Interesting. Could this be used to implement Linq-like functionality on Native Collections within DOTS/ECS (since Linq does not work within DOTS)?

    • @git-amend
      @git-amend  5 ชั่วโมงที่ผ่านมา +3

      I haven’t tried it myself, but it might be possible to create a functional, chainable API that mimics LINQ while remaining DOTS-compliant, which might help safely manage and transform data within ECS systems. I think it might have to be quite a bit more involved than what's presented in this video, however.

    • @jeffreyhersh908
      @jeffreyhersh908 3 ชั่วโมงที่ผ่านมา

      @@git-amend yeah I figured it would be involved but seems like a good starting point 😊

  • @lonbpalmer
    @lonbpalmer 2 ชั่วโมงที่ผ่านมา

    Java's optional was a game changer when it was introduced.

    • @git-amend
      @git-amend  2 ชั่วโมงที่ผ่านมา

      Indeed. It seems like C# is always a little behind on these kinds of things.

    • @shuoyuanchen7800
      @shuoyuanchen7800 ชั่วโมงที่ผ่านมา

      Optional.ofNullable().orelse() was the best thing ever happened

  • @정동우-n2x
    @정동우-n2x 5 ชั่วโมงที่ผ่านมา +2

    The concept of FP Monad doesn't really touch me, do you have any books to recommend?
    I understood the basic concept, but I think I need an example as well.

    • @git-amend
      @git-amend  5 ชั่วโมงที่ผ่านมา

      Sure, you can read more here. The Maybe Monad is similar to Optional. softwarepatternslexicon.com/patterns-c-sharp/7/10/

  • @shun6284
    @shun6284 ชั่วโมงที่ผ่านมา

    Your tutorials are masterclass quality, thanks.

    • @git-amend
      @git-amend  ชั่วโมงที่ผ่านมา

      You're very welcome!

  • @shuoyuanchen7800
    @shuoyuanchen7800 ชั่วโมงที่ผ่านมา

    i have java background, I LOVE nullables.

    • @git-amend
      @git-amend  ชั่วโมงที่ผ่านมา

      Haha! 💯

  • @GameDevSimp
    @GameDevSimp 5 ชั่วโมงที่ผ่านมา +1

    In my inventory I declare the Null item as a type of Item (learned from Zoran's videos), and store it as a static field
    public record Item(int Id, ...) { public static NoItem NoItem = new(); };
    public record NoItem : Item { public NoItem() : base(-1, ...) { } }

    • @git-amend
      @git-amend  5 ชั่วโมงที่ผ่านมา +1

      Sounds just like the Null Object pattern, and a great way to keep things safe and predictable. I think that is so much better than using null values. I like the use of record too. Honestly, I think the pattern is underrated. I really like Zoran's channel, it's probably the best C# channel on TH-cam.

  • @Roockert
    @Roockert 6 ชั่วโมงที่ผ่านมา +1

    I like the idea of null object that do nothing, but im not too sure about making non-nullable types nullable

    • @git-amend
      @git-amend  5 ชั่วโมงที่ผ่านมา

      Unfortunately, Nullable doesn’t provide a functional way to handle computations with missing values. That’s where Monads like Optional and Either come in, offering powerful tools to safely chain operations and manage both missing values and branching logic.

    • @Roockert
      @Roockert 5 ชั่วโมงที่ผ่านมา

      ​@@git-amend so I've been looking closer at this and i dont remember seeing it in your video here but you can enable nullable in the .csproj file. This ensures that everything is non-nullable ensuring that any use of nullabe types are the only explicit times something can be null
      enable

    • @git-amend
      @git-amend  5 ชั่วโมงที่ผ่านมา

      That's true, but I believe that Unity regenerates .csproj and removes this line every time it compiles. This is also why you can't set the C# version this way.

    • @Roockert
      @Roockert 4 ชั่วโมงที่ผ่านมา

      ​​@@git-amendah.. that sucks. Though i saw you can add it to a setting in unity6 somewhere but then the issue is that unity's code is not implemented with this feature in mind giving you a thousand+ warnings

  • @dipyalov
    @dipyalov 4 ชั่วโมงที่ผ่านมา

    All this "nullable" stuff makes not very much sense since UnityEngine.Object has perverted null comparison and a non-null reference still can throw NullReferenceException.

    • @git-amend
      @git-amend  4 ชั่วโมงที่ผ่านมา +1

      If you are concerned about that, consider using the OrNull extension method: th-cam.com/video/Nk49EUf7yyU/w-d-xo.html