Cursed Coding: How the Void* Does Anything with Nothing
ฝัง
- เผยแพร่เมื่อ 29 พ.ค. 2024
- Why is my channel called Voidstar Lab?
Try Brilliant free for 30 days and get 20% off at brilliant.org/zackfreedman
Support me on Patreon! / zackfreedman
Support me on Thangs! thangs.com/zackfreedman
Meet me and make friends! / discord
Doomscroll me! x.com/zackfreedman
A PROGRAMMING EPISODE?! Egads! Gadzooks! It's a good one. C and C++ feature a bizarre keyword: void* represents a memory address whose data are unknown or totally absent. This meaningless map to nothing enables function pointers, universal memory management, and event-driven architecture - all practical ways to code cleaner, faster, and with fewer bugs.
This is an introductory programming video for beginners and intermediate coders. Advanced users have probably used tons of these already, but who knows? You might now know everything these five bizarre characters make possible.
Credits:
Interference SFX: Partners in Rhyme
Other SFX: zapsplat.com
Silly, silly stock footage: Storyblocks - วิทยาศาสตร์และเทคโนโลยี
Id like to think that this video was based off of my question at the meetup 😁
Edit:
OMG THAT WAS MY QUESTION
Wait what?
@@Andrew90046zero It seems they went to the AMA and asked why the channel was called Voidstar.
@@Andrew90046zeroIn other words, @goodboiadvsp3297 was pleasantly surprised to see themselves in this video, when a circle of superfans were doing a Q&A at the convention.
3:05 in the video at Open Sauce
@@flabort oh right, duh! XD
I'm in my first week of an introductory C++ class. Listening to this video is like swimming in the ocean and feeling something warm and very solid brush your foot. There's something there; you can vaguely apprehend its shape. But the unknown holds primarily terror.
I'd say it's more like peeing in your pants to keep warm in a blizzard
good luck! I did quite a bit of embedded C and never used this, but understanding pointers is a must
It's a shark, those pointy stars bite like hell, try to be smart
starting to learn c++ is like starting to learn to build a house from atoms, except you are in acid and the house exist only in your head until you compile and realize that the house is actually a 5 headed alien because you pointed some electron to the wrong galaxy
@@f3rny_66 agreed 👍
Now that C# is getting all the low-level niceties, and native C# IoT units are available, I'm starting to get rid of c/c++ knowledge
As a C programmer of 50 years I actually understood this topic perfectly... Until you tried to explain it. The best metaphor is no metaphor at all.
that's... a revelation to me
i have had that exact experience before but you put it into words
As a non-programmer for whatever years I felt the same. Except I didn't understood it before and don't understand it now either.
So, that's a metaphor* ?
I never really understood pointers when I had a class in C++, now I'm scared of their power.
Golden rule of engineering
I use "void*" for a lot of things:
* Data Hiding
* Polymorphism
* Generic memory operations
I seldom use objects of "void*" to hold the address of functions because it bypasses argument validation and conversion. I use typedefs for callback function pointers and use "union" when I need a single function pointer to call functions with different interfaces depending on context. The generic button press would be "typedef void (* buttonPressedCallback_t)(void);" - No arguments/parameters, etc.
Disclaimer: I'm a prehistoric C programmer from before the ANSI standard and C++ and lived through the C standard library "char*" to "void*" cataclysm.
you are a true wizard
I use void* for function pointers, because I don't actually write C myself - I decompile it. void* is lovely for function pointers when you don't have a clue what their signature is! lmao
Polymorphism is a blessing to modern programming.
"...and lived through the C standard library "char*" to "void*" cataclysm."
Could you please elaborate?
It seems interesting and my googlefu hasn't returned anything.
@@guigs4467long story, but long ago in the times of yore "void" wasn't a thing, and the standard way to have an arbitrary pointer was instead a char*
As an embedded engineer, please do more of this, it's great.
As a former java developer, I am scared of this kind of programming.
> As an embedded engineer
Do you need help getting out?
@@littlefrank90As an c++ developer, help.
As an IT person who knows too little programming, this was awesome, do more!
@@Dent42 It is hard getting out, when I am embedded.
You possess a particularly potent proficiency for pinning us ADD people in place.
Usually i'm off to try (and fail) something half way through an explanation of it but i never miss a second of one your videos.
I know it's not a money maker but more coding when you can afford it would be awesome!
Me too!
ADHD gang represent 👊
Confirm here!
😂
AuAdhder reporting in, I second this!
I use void * a lot because I do firmware work in straight C. Super useful. But the biggest downside is that you almost immediately lose any of the mediocre type safety that the compiler provides. I use function pointers a lot too, they're pretty handy and retain type safety.
Zack, you are not known for making videos that typically bring tears to the eyes (unless you purposefully mispronounce something to trigger the comment trolls), but at the end of your video, where you talked about isekai elf mahiro-chan ~desuyone~, I was reminded of two of my own Patreon supporters who passed away and cried a little. Both of them were in my Discord server, and I couldn't bring myself to kick their accounts that their families never had the thought to delete after their passing, so I made a new role specially for them. They are now the server's Guardian Angels (I'm TheDarkPreacher, everything is kinda religion themed). One passed away so suddenly that I only found out he had been sick when I got a message on Patreon for an exit survey that simply said "He died." The other was the mom of one of my wife's friends, and we knew she was in poor health. It was very touching that you included isekai elf mahiro-chan ~desuyone~ in one last video before their patreon ran out. Here's hoping they are enjoying their life in a fantasy world and take any knowledge they gained from your videos to become an OP character that ends up ruling the world. Or at least, they are resting in peace.
After my wife died, it was kinda hard to cancel her Patreon subscriptions. After a certain point, I did have to make some budgetary changes (I got laid off after she died, and the job I got after that paid drastically less, plus going to a single income while still having about the same expenses can be hard. Like did you know car insurance for one person actually cost more than for a married couple combined?). What I ended up doing, was setting her name to reflect her passing by adding "RIP (1982-2021)" and running that for a few months before ending her subscription. I've not checked to see if anyone has done anything in honor of her (some of them I wasn't able to, because I don't have access to all of her accounts), but I hope they did.
Welp, now I cried. Thanks for that. Lost my best friend in November and it still hurts like hell. Loss is weird, comes in waves, and life is more fragile than we think.
So sad and very nice of him to mention.
I'm pretty sure parent class methods are supposed so work like how you describe void*, where classes inheriting from the parent promise to implement specific methods that are then called somewhere else regardless of what class it is; as long as it inherits from that specific parent.
That's what I was thinking. Inheritance should exist in C++, but maybe the complication was identifying the cartridge type, instantiating, and firing the method since no code is on them.
Yeah... I'm not sure exactly why he found dependency injection to be so much simpler than OOP for this. The described situation is practically exactly what OOP is for. It could be that the program was badly structured from the outset, and any refactor would have greatly improved it. It could be that he just isn't very good at OOP - he's admittedly not a programmer by trade, and OOP can be a bit daunting and it's easy to mess up. Functional programming is probably easier in this case, though I think a well designed object oriented approach would still be better and MUCH simpler for other people to use if you're going to share it.
Truly, the greatest strength of OOP is in creating code that you intend for OTHER people to use. Abstraction, encapsulation, polymorphism. All that stuff is really important when you want to have code that you can make improvements to later without massively breaking stuff other people used it for, and it's much simpler for someone else to actually interact with as they only need to understand the interface.
For your own personal code, or for core application code, it's usually too much overhead. But for a library or API? There's a reason that most popular modern programming language have OOP features, even if they aren't the star of the show.
@@Lord_zeel i was thinking much the same thing.
As a non-programmer who is just interested in making and 3d printing, this was so informative and held my attention the whole way through! Congrats on taking a leap to branch out while working on larger projects
Zack doesn't want to be... _typecast_ 😎
@@SeanCMonahanI see what you did there.
Yo rest in peace, isekai elf mahiro-chan. The voidstar patreon list will never be the same without you.
Zach, I think your show has been at its strongest when you’re teaching. My favorite episodes have consistently been the ones where you’re describing how tech concepts work, like the pick-and-place robot and the Diamond tip episodes. Would love to see more of this kind of thing!
It never occurred to me that void star meant void pointer lol
Same, I thought it was a pretentious name for a black hole.
😅@@namAehT yeah, I've always pronounced these as "pointers" not "star". (Or depending on what you're doing, you're talking about "address", "take the address of", "dereference", etc.)
I've also heard people pronouncing * as splat before. Void Splat Labs doesn't have the same ring to it.
@@ethanjennings6442not the same ring, but certainly *a* ring
@@namAehT tapped on this video from my recommendations expecting a physics video lol
As someone who uses C# a lot, that joke murdered me. I'm now a Java Fanfic coder. Updating Resume.
As a python developer I removed any reference to programmer from mine
@@GreenlandRobot brutal.
Lol. Yeah, loved that line.
void* in c is like duck-typing in python : it allows you to treat data however you please without explicit interfaces / inheritance.
It does make the code less legible though, since the 'contract' you hold with said data is implicit.
Blender's source code is actually is full of voidstars and it is a mess to work with.
10/10 for more programming based content. That’s the kind of content I’ve wanted to watch for a while.
C++ was the first language i learned . I havent touched it in years except modifying some stuff in marlin. Im rather surprised you did this video. I would like to know more . Keep up the good work!
i just imagined i was a delivery driver... worst day of my life
There's worse jobs out there so consider yourself blessed. I delivered pizza as a second job for a while and audio books are a game changer in that field.
I worked for Amazon. They could not manage delivery.
I am a food courier...whatever you imagine can't come close to how bad it can get.
You explained the utility of using pointers so nicely. Thank you!
this was the most interesting programming video i’ve ever seen. your enthusiasm for conveying the quirkiness of void* is a great example of what i love about this channel
I’ll admit, I don’t really understand or follow a lot of the programming stuff you do, but I love the way you present it so I really enjoy videos like this :)
I don't think void* for callbacks is a great idea, but for passing data through callbacks it's pretty much the only thing available. E.g. a download function also gets a void* provided by the caller, and in the callback you can cast it back to your own type and check e.g. what the download URL was, when it was started or whatever else you want to store in there.
"I love to learn, but hate being taught" such a simple concept, but one that had never crossed my mind before. 100% relatable
Hey! Please do more of this! Way too many of my favorite creators like you skip over the programming because they're worried that people will find it boring. Maybe some do, but the rest of us ate fascinated and need more!
i actually liked this episode a lot. im down for topics that are tangential to your 'norm' but still relevant to the norm, and in your classic hilarious style. great job
Holy fuck I was just re-watching random old videos looking for that sweet Voidstar dopamine hit.
[slaps side of compiler] This no-thing can do SO MUCH any-thing - [quietly] but, mostly, it's just SIGSEGVs.
But seriously, this is great! I love this :D
I actually really enjoy these types of videos from you ! As well as your editing style, it helps my shirt attention span lol
Shirt attention span? Mine has to be a napkin then...
@@tdgchan 😂😅 I definitely meant short* but your reply is too awesome, I won't fix my typo
@@strelkomania I took "shirt" attention span as an intentionally ambiguous typo of "short" or "shit"
@@collectorguy3919 😂i love that
Omfg please more of these videos. You make programming actually make sense. You have no idea how valuable you are to people wanting to learn.
😂 as a hobbyist c# programmer. "cup of error" just makes me crack. I need a cup of error for my computer desk now.
Loved the vid. The void* is great for prototyping, but I shudder to think of it being used in large production code bases, lol. I've become a fan of C# in my dotage, and some of the constructs like interfaces to allow for polymorphism without baroque class inheritance trees.
Keep on keeping on. Love your stuff.
Zach, I haven't written any code in over 20 years. Even so, you're such a great teacher, I understood everything you said. Have you ever considered a "Learn Programming From Scratch" series where you do your own take on Dave Mark's classic books "Learn C On the Mac" and "Learn C on the PC"? For those not familiar, Mark's books were famous for taking someone with zero knowledge of programming and getting them proficient in C in an easily understood way.
As I said, you're such a great teacher, you could take someone that has never done a "Hello World" and have them competent in C in short order. And since Dave Mark hasn't updated his books in years, he has left a *Void* to fill.
I'd even pry open my wallet to take such courses from you.
Fun fact: int `*foo; (ignore the ` - youtube has no escape sequences) is technically more correct because the star is associated with the name, not the type. You can see this more clearly when you declare multiple pointer variables: int `*foo, `*bar, baz; (baz here is an ordinary int). The idea is that the value of that variable *dereferenced* is int.
I prefer to think of it as "the type of 'foo' is 'pointer to an int'" - the actual value at foo is the address of something, so the data type of foo is pointer. Thus just as 'int foo' is an int, 'int* foo' is a pointer to an int. Saying 'int *foo' seems nonsensical to me.
@@Lord_zeelthe problem is that int* does not cause all following declared variables to be int pointers: `int* var1, var2, var3;` is a common trap in C/C++ exactly because of that. You may think var2 and var3 are pointers, but they're actually integers.
If you want var2 and var3 to be pointers in that line, you /must/ write it as `int *var1, *var2, *var3;`
@@Lord_zeel It actually is the only thing that makes any sense. Granted, it only makes sense because C's variable declaration syntax is absurd, but it does make sense. The idea is that "declaration follows use" -- the syntax for declaring a type mirrors how you use that type. So for example you declare an array like int a[3];, which is also how you index into it. Same goes for pointers, you write int *a; because a is a variable that, when dereferenced with *, will produce an int.
I think there's not a single person in the universe who in 2023 thinks this syntax was a good idea (including the original designers of C), but we're stuck with it. There's two choices from here: one is to reject this 'feature' of C and try to pretend it has a more normal declaration syntax. You'll have to make some house rules (like never declare more than one variable in the same statement), and it'll always carry some residual wonkiness, but you can do it. This is where you write int* a. The other choice is to embrace the suck and accept that this is the way the language was designed, and try to work with it instead of against it. You'll have to adjust your thinking, but you won't have to make any house rules, and it'll always work consistently. This is where you write int *a.
After dabbling in type theory, I now find Idris | Haskell | Rust 's Void much neater. It has this curious property that there's no expression that would be of this type. Useful for marking functions that do not return - that is loop or do jump somewhere but will never come back.
But when a function does return, just nothing of value, its return type can be Unit - which has exactly one possible value (like the 0-length tuple). Sort of a placeholder that roughly corresponds to the void return type of C-like languages.
And if you're doing theorem-proving, Void is an impossible proposition while Unit corresponds to something trivially true.
Yay. A person that uses a dependently typed language. There are dozens of us.
I recommend you checkout Lean 4 if you haven't already. The codebase of the language itself is quite fun to read as well since the compiler is (mostly I think) self hosted.
I'm not much too fussed with what a type is called, but I do have one gripe with how void works in C/C++, which is that it isn't a real type. You can't make a variable of type void and assign it the only possible value -- the language says that doesn't mean anything so clearly you would never want to do it. Except C++ also gives you templates to write code that works generically, and it would be damn convenient to treat void like any other type, the way Haskell's Unit works.
@@computationaltrinitarianis1451
Sadly YT has hid your comment (it's still invisible for me, unless I sort everything by 'newest').
As for Lean, it's on my radar, though I don't know much about it nor about Agda.
The first time I tried to learn Coq I didn't understand enough of how it works under the hood to really use it. I need to try again!
But recently a friend has told me about Natural Number Game which is built around Lean so that will likely be my next step.
Yeah my professors hated my coding style. I absolutely loved my array of void*'s how I'd loop over them changing data. Had one class where your graded on actual performance. Get your program to run in 10 minutes=70, 7.5min=80, 6min=90 and sub 5min was a 100. Me and the prof competed and I beat him in all but one project pushing sub 30 seconds. He said he hated my code with a passion but couldn't argue how efficient it was.
Beein studying computer science for 2 years now, and this Video opened my eyes on how Event driven Architecture works on C++. We only briefly discussed how it works in Java, but this video was a very useful addition! Thank you so much!
Now I'm _really_ concerned about how you managed to have a callback as a method devolve into chaos such that replacing it with a bare function solved your problems.
Can’t wait for the bigger project vids but love this content as well. Keep it coming!
For non-coders a pointer is very similar to how pronouns work. A pronoun doesn't describe a thing (the nouns and adjectives do that) a pronoun refers to the noun that describes the thing. The same reason they do it in coding is the same reason we do it in any language, describing a thing makes a new instance of that thing while referring to a thing does not. This makes it easier in both computation and on one's cognitive strain. For any confused about houses and such in Zach's description. A pointer is basically saying "Hey remember that thing that I previously established, often in detail? Yeah, talking about it again."
I just love learning this stuff. I'm a musician and love making my computer do math, but I have a tough time learning real programming skills, so this kind of thing really helps to open up my idea factory
As someone who taught themselves python and then ended up using it for college projects over the languages i had to pay to be taught, I do find it funny that this video starts with ragging on python and then goes on to explain a concept that is intrinsic and intuitive in python. I have replaced the built-in print function because i wrote a program and then later decided i wanted to do more with the logs than just output to stdout. I may have actually done this as part of my college homework so I could test it by outputting to stdout and then turn it in with it outputting to a file, as the professor wanted.
Void Star is also the name of my favorite book.
I think that was a relatively clear definition of what a void * does, but I don't know C all that well. All I kept thinking at first was, what's so special about that, we do all of that stuff all of the time in Javascript.
But thinking back of when I was doing Pascal and even for a short time some C, it would've been great to have known about this back then!
If you like both Python and very low level bare metal programming, you may like Nim. It looks like Python, it has many more features than Python (like generics, macros, function overloading, custom operators), it's as fast as C, and it compiles to C/C++ so you can use in about *anything* like obscure microcontrollers that only have a crappy C compiler. Using ARC as memory manager it inserts the mallocs/frees automatically where needed and it doesn't have GC pauses. It's very easy to interface with C, C++ and ObjC libraries. It also compiles to JS but in most cases it's much better to tell it to use emscripten.
You should’t use void* for function pointers. You should use actual function pointers ( the syntax is ret_type (*name)(args) ), that way the compiler and people reading the code will be able to tell what the callback function should look like.
It’s actually undefined behavior to cast function pointers to void*. This isn’t much of a problem in modern PC architectures, but void* is a type for _data_ pointers. You can imagine a machine where code is stored in ROM and data is stored in RAM that the types used to address them could be completely different, and of different sizes. This happens in IA-64 and 8086 16-bit real mode, apparently. It _is_ legal to convert function pointers to any other function pointer type, so if you want to store a pointer to any function, you can cast it to void (*)(void).
Great episode! Thank you for simultaneously melting my brain and making me feel less stupid for always struggling with OOP.
You mention that whole bit with the Quagsire, and the funny thing, Gamefreak did that very thing in Pokemon Sun and moon, using the same model fully duplicated for various scenes, a fully independent copy of the model, even though there was no real differences, rather then just one model they could reference and set a state too. According to twitter and some other places its to "Make it load faster." Since it was right there with everything else, rather then being something it had to pull from another location.
As an IT Professional for the last 20 years, and a recovering computer science student, I deeply enjoyed this video. I mean, most of them are pretty awesome, but this one hits different. 😸😹
Wow. Absolutely loved this video Zack! Would love to see more coding-oriented videos like this
I hadn’t connected the lab name, it’s pretty genius. I enjoyed this video, even if I am a python “programmer” 🐍
Thanks for reminding me why I prefer Rust over C/C++. In Rust basically every time you'd use a void* you can deal with it in a type-safe way.
C++ has type safe alternatives too.
Not only did you keep me hooked the whole time, I went back a second time to understand better. You're videos are incredible.
First, you did an awesome job explaining things at a high level, though I will admit that while I'm not a programmer, I have dabbled in scripting for my sys admin job so it was somewhat easy for me to get what you were putting down. Baller job!
Secondly, it might just be the fact that I'm working on building the magic system for my TTRPG, but your explanation also felt like you were explaining the inner workings of conceptual magic, and it was awesome. To an average non-magical (or non-technical) person, it probably would be like "those indeed are those spell-words. I understand the concept you explained, but still spell-words." Which is doubly awesome. Keep up the good work!
And if the algorithm permits (praise be), I wouldn't mind seeing more code in your future videos.
12:47 Zack, you know your audience is "special" enough they can detect a rickroll by the video-ID alone..
Please continue doing these type of teaching videos from time to time about whatever topics you choose.
This was great. I finally got an answer or two to the exact difference and use case for some terminology and things in code that I've been using for years now but never fully understood
On my studies we always joked that skill of the programmer / hardness of the program could be expressed with "star rating", i.e. maximum number of "stars" attached to any type (especially beloved void) in the program. Of course usage of such indirect reference must not be just for show, but have practical use. For now, 3 stars is all I've got.
wow the video was amazing! good job
Amazing you can watch a 21 minute video in under a minute
@@ShadowMaelstrom im just fast dw abt it
@@dip8 bet the ladies love you
@@ShadowMaelstrom lol
We want more of you explaining programming concepts ! (By the way I didn't know the power that void* has...)
I hope you get a good response to this because I love the passionate, practical way you explain stuff AND I want you to have time to work on bigger projects!
But also it's been a while since I've touched any C, so I'll definitely enjoy rewatching this
I started my career with C and C++. Hearing all of this brought back great horror memories! Keep doing what you do!
4:17 I already feel offended lol
I’ve never clicked on a notification so fast lmao
same 😂
The first 17 minutes really went in one ear and out the other. But then the example of the modular remote thingy really made it click. I love void stars now! Way easier than oob
I like how the video evolved into loose coupling, event driven architecture, and functional vs object oriented programming all from the void pointer.
I would definitely want to see more of the code in your project videos.
agreed !!
I like your funny words computer man.
I can't believe it. You finally explained pointers in a way that makes sense. I've struggled with this concept for five years, no explanation in any book, wiki, comment, stack overflow, chatGPT question has ever been able to do. I gave up on C because of this. Thank you. I will, perhaps, dip my toes hesitantly back in those waters.
Ok it took me a while to get exactly how the advantage manifests, but the bit that kicked it into my skull was the bit about the button being a dumb thing that doesn't have to know what it's referencing, it just calls the voidstar, and whatever is there is there.
better explanation of literally any cs concept than any of my tenured professors over the last 4 years
and this is why my degree was completed on the combined efforts of random internet people with strong accents and MIT OCW
and also why i graduated with a cs degree and immediately went into the field of art 😂
Just found your channel Zack, and i dont even 3D print, but i cant stop watching. You're a genuine joy to watch! Cant wait for the next one.
I am impressed. Who would have thought you can talk almost 22 minutes about such a simple thing as a void*
Dude you're expanding my mind right now and I didn't sign up for that. I had things to do today and now I'm thinking about Void*-mediated modularity in physical systems.
I noticed some slight inaccuracies in what you explained.
A function with the return type void returns no value.
While a function with a return type that isn't void has to return something.
Though a a function with a return type void * has to return something, specifically a pointer, but the data type for that pointer can be anything.
So with that you can do something like:
#include
void * return_stuff(uint32_t flag) {
switch (flag) {
case 0:
return malloc(sizeof(uint8_t));
break;
case 1:
return malloc(sizeof(uint16_t));
break;
case 2:
return malloc(sizeof(uint32_t));
break;
case 3:
return malloc(sizeof(uint64_t));
break;
default:
return NULL;
break;
}
}
This has been used a lot in the past, and has some use cases today, but it's a good idea to avoid it, and rather use existing types, or custom types.
For example you can make a struct with an union, and use an enum to say what it is. e.g.
#include
typedef struct {
enum {
KIND_U8,
KIND_U16,
KIND_U32,
KIND_U64,
KIND_NONE,
} kind;
union {
uint8_t* u8_ptr;
uint8_t* u16_ptr;
uint8_t* u32_ptr;
uint8_t* u64_ptr;
};
} Stuff;
and then you can use it like this:
#include
Stuff make_stuff(uint32_t flag) {
Stuff stuff;
switch (flag) {
case 0:
stuff.kind = KIND_U8;
stuff.u8_ptr = malloc(sizeof(uint8_t));
*stuff.u8_ptr = 0;
return stuff;
case 1:
stuff.kind = KIND_U16;
stuff.u16_ptr = malloc(sizeof(uint16_t));
*stuff.u16_ptr = 0;
return stuff;
case 2:
stuff.kind = KIND_U32;
stuff.u32_ptr = malloc(sizeof(uint32_t));
*stuff.u32_ptr = 0;
return stuff;
case 3:
stuff.kind = KIND_U64;
stuff.u64_ptr = malloc(sizeof(uint64_t));
*stuff.u64_ptr = 0;
return stuff;
default:
stuff.kind = KIND_NONE;
return stuff;
}
}
void* is available in C#, but it's only available in unsafe (unmanaged) sections of code. The managed equivalent is IntPtr, which refers to the pointer value itself and doesn't have any concept of what sits at that address.
During my 1,5 month long break from uni, this video was a nice reminder that I at least didn't forget the basics of programming lmao.
I now attach "on complete" conditions and output variables to the ends of some of my OOP code because of this video. any task can now start any other task, and more easily pass data between them. very helpful!
Zack, your writing & delivery is brilliant! I'll watch any video you make on any topic; code, 3d, cyborg, home renovation, anything!
One day I hope to hear my name in those credits
This vid was very fresh. I like when you talk concepts more than things, good job!
Been waiting on this. Thank you Zack.
It's funny because at my college nobody called it star we always referred to it as pointer. So despite 5 years of programming classes, long story, it never occurred to me your channel was name after a void pointer, hahaha. Even a ** was referred to as a pointer pointer. People did say star sometimes of course, but saying asterisk was more common by my recollection. Fun stuff.
I think this video had the least useful (but most entertaining) explanations of a void pointer I've ever heard :)
Would love more videos like this! Especially the devlog bits about your old prototypes are very cool
Great video! I recently have started to feel like I have a solid grasp of the object oriented programming style, now upon learning what EDP is its time to learn some more!
I was horrified when I recognised the trucks-polymorphism analogy at the start, but only because in C++ (which I like) it means void pointers and other filthiness to do it.
This is now my favorite video of yours. Please do more code videos!
This video was Fantastic. Please make more of these!
My favorite video of yours so far! More code videos 🙏🏻
I really enjoyed this type of video. Please do more of these.
This video was a thousand times more coherent than my first semester of C in college.
Yes! More code stuff! I never thought to assign a pointer void before, I'm going to try this out.
I'm an embedded firmware engineer by trade and I only just realized a couple weeks ago that Voidstar == (void*) while helping out a coworker with some C work, now this video comes along! Wild!
I coded in C/C++ for like 15 years, haven't used it in another 15 and now I totally forgot that void* even existed. Thanks for that blast from the past!
I hate that a lot of my favorite tech-adjacent people treat code like a vampire treats a crucifix. That's hugely entertaining to me. This one rocks, man. Keep doing the good stuff.
I cant believe I lived without this until now, cant wait to try using it and giving up after 5 mins
Please do more of videos like these where you teach and stuff I love them!
very good video, hated OOP in HS never really got the assignments but this explained why and a better alternative thanks a ton
One use for void* is to attach data to callbacks.
In Javascript if you write something like:
const x = 19;
function foo(y) {
return x+y;
}
function bar(f) {
console.log(f(23))
}
bar(foo);
Then the value of the function foo at runtime (called a closure) is not only a pointer to the code for foo, but also includes the value of x that it "captures".
In C, however you can't capture variables in functions the same way. References to functions only refer to the address of the code of the function. So you can do something like
#include
int foo(int y, void* x) {
return *(int*)x + y;
}
void bar(int (*f)(int, void*), void* data) {
printf("%d", f(23, data));
}
int main() {
int x = 19;
bar(&foo, &x);
}
iam a programing and software dev student and this is a best video ive seen on void* so far :D. Keep it up man. Thnx
It was great. Your delivery made it great.
Haven't touched C or microcontrollers for a long time, but videos like this get me itching to jump in again. Thanks for a lovely vid!
Dude, you're _killing it_ with the jokes in this one. I've lost track now of how many times I've had to pause/rewind because I was laughing and missed something, and I'm only just over halfway through!