Zig For the Uninitiated: Zig Interfaces

Поделиться
HTML-код
  • Опубликовано: 7 фев 2025
  • Here we discuss Zig interfaces, with particular attention to the Allocator interface in std.mem.
    If you have any questions, feel free to reach out in the comments, or at my discord: / discord
    Write up: calder-ty.com/...

Комментарии • 19

  • @Daniel-fl4si
    @Daniel-fl4si 19 дней назад +1

    Excelente! Thank you for take the time to explain this.

  • @guzmonne
    @guzmonne 21 день назад +2

    Very cool and clean explanation. Keep it up!

  • @andreasschobel5860
    @andreasschobel5860 Месяц назад +6

    The comparison to Java interfaces is incredibly useful as a reference point.

    • @calder-ty
      @calder-ty  Месяц назад

      Thanks! I was hoping it would be helpful.

  • @sweep-
    @sweep- 3 месяца назад +3

    I can’t wait until you get to a little more on strings. Ha. It took me forever to figure out how to pass string literals from a test, into a function param, and to have that function work with runtime strings…
    Thanks for adding more Zig content into this world!!!

    • @calder-ty
      @calder-ty  3 месяца назад

      @@sweep- thanks! Yeah. I haven't thought about that but it could be good to do one on zigs lack of a string type.

  • @Nt2311-vn
    @Nt2311-vn 3 месяца назад +1

    Great to see new vid man, thank you for sharing knowledge on Zig

  • @uv42
    @uv42 Месяц назад +2

    This was an amazing video. Very informative.👏👏

  • @nikolaikalashnikov4253
    @nikolaikalashnikov4253 24 дня назад +2

    Are there any disadvantages to using "syntactic sugar" ? Or, people just hate OOP so much that they're rejecting everything associated with it ? (like polymorphic behavior)

    • @calder-ty
      @calder-ty  24 дня назад +2

      The pros of first class language support for interfaces, are that it makes it easier to do, and provides some guard rails against doing it wrong. I don't think there is any "first-order disadvantage" from having the language support it with syntax. The argument, however, is that such support actively encourages the use of the pattern, and that the pattern itself is frequently harmful. With interfaces you are using Dynamic Dispatch, which means additional pointer derefrencing to get to the code. This can lead to performance hits. Sometimes that's a cost you are willing to bear, but Andrew Kelly thinks it's a choice that should be knowingly made, rather than hidden behind syntax.

  • @eliblaney
    @eliblaney 23 дня назад +1

    This is a great reference, thank you. Out of curiosity, what are you using to see Zig source definitions?

    • @calder-ty
      @calder-ty  23 дня назад +1

      @@eliblaney I use the zig language server (zls) and go to definition

  • @nikolaikalashnikov4253
    @nikolaikalashnikov4253 24 дня назад +1

    Cool: Hopefully you can do a powerpoint of this for C-lang ?
    Or, maybe just post a code example in C ?

    • @calder-ty
      @calder-ty  24 дня назад

      Do you mean a comparison between java and C or between zig and C?

    • @nikolaikalashnikov4253
      @nikolaikalashnikov4253 24 дня назад +1

      @@calder-ty well, you were talking about creating "Zig Interfaces", so I was curious how you'd do that in C-lang: "C interfaces".

  • @bartholomewjoyce
    @bartholomewjoyce Месяц назад +2

    Hey this is a great resource for learning Zig, and I appreciate it greatly, but can you please remove the {C:T} watermark (or place it somewhere else) from future videos? It really takes away from the legibility of your code

  • @oylesinebiri
    @oylesinebiri Месяц назад

    an comment