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/...
Excelente! Thank you for take the time to explain this.
Thanks!
Very cool and clean explanation. Keep it up!
The comparison to Java interfaces is incredibly useful as a reference point.
Thanks! I was hoping it would be helpful.
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!!!
@@sweep- thanks! Yeah. I haven't thought about that but it could be good to do one on zigs lack of a string type.
Great to see new vid man, thank you for sharing knowledge on Zig
This was an amazing video. Very informative.👏👏
@@uv42 thanks!
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)
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.
This is a great reference, thank you. Out of curiosity, what are you using to see Zig source definitions?
@@eliblaney I use the zig language server (zls) and go to definition
Cool: Hopefully you can do a powerpoint of this for C-lang ?
Or, maybe just post a code example in C ?
Do you mean a comparison between java and C or between zig and C?
@@calder-ty well, you were talking about creating "Zig Interfaces", so I was curious how you'd do that in C-lang: "C interfaces".
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
an comment