Dylan Falconer
Dylan Falconer
  • 46
  • 476 683
Dynamic Arrays in C
Sorry about the nose-whistle. I'll have to wear one of those nose holder-opener-things next time I record.
➤ Substack: bytesbeneath.com/p/dynamic-arrays-in-c
➤ X: x.com/falconerd_
➤ GitHub: github.com/Falconerd
➤ Discord: discord.gg/MQEQZxP
Tools used for video:
Slides/Animations:
animotion.pages.dev
Editing:
github.com/WyattBlue/auto-editor
Shotcut
Audacity
Canva
Переглядів: 61 778

Відео

Unity Game Ended Themselves - A different take
Переглядів 4,3 тис.8 місяців тому
➤ Substack: bytesbeneath.com ➤ GitHub: github.com/Falconerd ➤ Discord: discord.gg/MQEQZxP #unity #unity3d #godot #gamedev #gamedevelopment #programming
Weapon System | C Game + Engine From Scratch 18
Переглядів 4,7 тис.11 місяців тому
➤ Website: dylanfalconer.com ➤ GitHub: github.com/Falconerd ➤ Discord: discord.gg/MQEQZxP
Enraged Enemies | C Game + Engine From Scratch 17
Переглядів 1,9 тис.Рік тому
➤ Support the channel: ko-fi.com/falconerd ➤ Website: dylanfalconer.com ➤ GitHub: github.com/Falconerd ➤ Discord: discord.gg/MQEQZxP Code used in recording: github.com/Falconerd/engine-from-scratch Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/ Background pixel art for this series is Kings and Pigs by Pixel Frog. Check it out here: pixelfr...
Spawning Enemies | C Game + Engine From Scratch 16
Переглядів 1,6 тис.Рік тому
Code used in recording: github.com/Falconerd/engine-from-scratch Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/ Background pixel art for this series is Kings and Pigs by Pixel Frog. Check it out here: pixelfrog-assets.itch.io/kings-and-pigs Music for this series is from Breezy's Mega Quest by RyanAvx. Check it out here: ryanavx.itch.io/bre...
How NOT to Develop a Game (A Gamedev Story)
Переглядів 3,5 тис.Рік тому
EDIT: This devlog contains almost nothing about the game, so I'm rebranding it and going to start the devlogs again with much higher quality. Apparently everyone (every indie gamedev, anyway) is making their "Dream Game". It's just marketing! Though, I do this game will be very cool and I have been thinking about it for ages. A reading of the article on my site: dylanfalconer.com/blog/dawnbreak...
Level Setup | C Game + Engine From Scratch 15
Переглядів 3,3 тис.Рік тому
Code used in recording: github.com/Falconerd/engine-from-scratch Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/ Background pixel art for this series is Kings and Pigs by Pixel Frog. Check it out here: pixelfrog-assets.itch.io/kings-and-pigs Music for this series is from Breezy's Mega Quest by RyanAvx. Check it out here: ryanavx.itch.io/bre...
Playing Audio | C Game + Engine From Scratch 14
Переглядів 2,6 тис.Рік тому
Code used in recording: github.com/Falconerd/engine-from-scratch Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/ Background pixel art for this series is Kings and Pigs by Pixel Frog. Check it out here: pixelfrog-assets.itch.io/kings-and-pigs Music for this series is from Breezy's Mega Quest by RyanAvx. Check it out here: ryanavx.itch.io/bre...
"Make a Game not an Engine" (Just use Unity/Unreal/Godot bro)
Переглядів 18 тис.Рік тому
"Make games, not engines" is often misunderstood to mean that one should not create games from scratch but rather use third party engines like Unity, Unreal, or Godot. I have a little rant about how building specific engines for games is the way to go. Once capabilities are created, they can be carried forward into your next project. Of course, all this assumes that one actually wants to be a g...
Trigger Events | C Game + Engine From Scratch 13
Переглядів 2 тис.Рік тому
Code used in recording: github.com/Falconerd/engine-from-scratch Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/ Background pixel art for this series is Kings and Pigs by Pixel Frog. Check it out here: pixelfrog-assets.itch.io/kings-and-pigs Music for this series is from Breezy's Mega Quest by RyanAvx. Check it out here: ryanavx.itch.io/bre...
Animated Sprites | C Game + Engine From Scratch 12
Переглядів 2,9 тис.Рік тому
Code used in recording: github.com/Falconerd/engine-from-scratch Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/ Background pixel art for this series is Kings and Pigs by Pixel Frog. Check it out here: pixelfrog-assets.itch.io/kings-and-pigs Music for this series is from Breezy's Mega Quest by RyanAvx. Check it out here: ryanavx.itch.io/bre...
I Made an Image Loader in 15 Lines for My Game Engine
Переглядів 4,2 тис.Рік тому
Engine series: ua-cam.com/video/WficzyoTSsg/v-deo.html ➤ Website: dylanfalconer.com ➤ GitHub: github.com/Falconerd ➤ Discord: discord.gg/MQEQZxP
Batch Rendering Sprite Sheets | C Game + Engine From Scratch 11
Переглядів 7 тис.Рік тому
Grab the player.png from the repo below. Code used in recording: github.com/Falconerd/engine-from-scratch Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/ Background pixel art for this series is Kings and Pigs by Pixel Frog. Check it out here: pixelfrog-assets.itch.io/kings-and-pigs Music for this series is from Breezy's Mega Quest by RyanAv...
Entities and Collision Layers | C Game + Engine From Scratch 10
Переглядів 6 тис.Рік тому
ECS Video: ua-cam.com/video/s6TMa33niJo/v-deo.html Code used in recording: github.com/Falconerd/engine-from-scratch Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/ Background pixel art for this series is Kings and Pigs by Pixel Frog. Check it out here: pixelfrog-assets.itch.io/kings-and-pigs Music for this series is from Breezy's Mega Quest...
2D Collision Response | C Game + Engine From Scratch 09
Переглядів 10 тис.Рік тому
If you would like to know more, here are the sources I used in no particular order: * noonat.github.io/intersect * blog.hamaluik.ca/posts/simple-aabb-collision-using-minkowski-difference * github.com/pgkelley4/line-segments-intersect/blob/master/js/line-segments-intersect.js * ua-cam.com/video/_g8DLrNyVsQ/v-deo.html - Handmade Hero 50 * tavianator.com/2011/ray_box.html * tavianator.com/2015/ray...
Swept AABB Collision Detection | C Game + Engine From Scratch 08
Переглядів 12 тис.Рік тому
Swept AABB Collision Detection | C Game Engine From Scratch 08
AABB vs AABB Collision Detection | C Game + Engine From Scratch 07
Переглядів 7 тис.Рік тому
AABB vs AABB Collision Detection | C Game Engine From Scratch 07
Point vs AABB Collision Detection | C Game + Engine From Scratch 06
Переглядів 6 тис.Рік тому
Point vs AABB Collision Detection | C Game Engine From Scratch 06
Can Copilot build a library in C? Well...
Переглядів 3,5 тис.Рік тому
Can Copilot build a library in C? Well...
Physics: Integration | C Game + Engine From Scratch 05
Переглядів 10 тис.Рік тому
Physics: Integration | C Game Engine From Scratch 05
Input and Config | C Game + Engine From Scratch 04
Переглядів 11 тис.Рік тому
Input and Config | C Game Engine From Scratch 04
Shaders and Reading Files | C Game + Engine From Scratch 03
Переглядів 11 тис.Рік тому
Shaders and Reading Files | C Game Engine From Scratch 03
Rendering a Quad | C Game + Engine From Scratch 02
Переглядів 25 тис.Рік тому
Rendering a Quad | C Game Engine From Scratch 02
How to make a GAME ENGINE | SDL2 Setup and Window | C Game + Engine From Scratch 01
Переглядів 97 тис.Рік тому
How to make a GAME ENGINE | SDL2 Setup and Window | C Game Engine From Scratch 01
A to Zig | 03 Arrays
Переглядів 2,1 тис.Рік тому
A to Zig | 03 Arrays
A to Zig | 02 Values
Переглядів 2,5 тис.Рік тому
A to Zig | 02 Values
A to Zig | 01 Hello World
Переглядів 11 тис.Рік тому
A to Zig | 01 Hello World
I got stuck in development hell
Переглядів 2,7 тис.2 роки тому
I got stuck in development hell
Poisson Disc Sampling (Blue Noise) - Procedural Terrain Generation #1
Переглядів 2 тис.3 роки тому
Poisson Disc Sampling (Blue Noise) - Procedural Terrain Generation #1
Entity Component System (ECS) - Definition and Simple Implementation
Переглядів 44 тис.3 роки тому
Entity Component System (ECS) - Definition and Simple Implementation

КОМЕНТАРІ

  • @ameera999
    @ameera999 6 днів тому

    please convert that to javascript

  • @kaiweiyeo4279
    @kaiweiyeo4279 7 днів тому

    Hi Dylan, Thanks for explaining ECS. I tried using make on Cygwin. There's a strange error that I thought you would like to see. gcc -Wall -pedantic -ansi -I/usr/include -I./include -lglfw -lm -ldl -lfreetype -std=c89 main.c render.c gl_utils.c texture.c math_linear.c lib/glad.c ../src/array_stack.c ../src/ecs.c main.c: In function 'nk_tooltip_begin': main.c:235:1: internal compiler error: in rebuild_frequencies, at predict.c:3191 } ^ main.c:235:1: internal compiler error: Aborted gcc.exe: internal compiler error: Aborted (program cc1) Please submit a full bug report, with preprocessed source if appropriate. See <gcc.gnu.org/bugs.html> for instructions. make: *** [Makefile:8: out] Error 4

  • @viscarious1
    @viscarious1 14 днів тому

    Love this content. Have you played around with using the new input method with this code? I'm trying to work through it at the moment and convert it.

  • @matej538
    @matej538 23 дні тому

    how do you have your explorer compact like that?

  • @dandymcgee
    @dandymcgee 25 днів тому

    Hmm this is interesting. I like the Minkowski difference approach. I just implemented this using a different algorithm, which finds the entry/exit distance using edge pairs along each axis, converts them to a normalized time (or alpha value, if you prefer) by dividing them by the distance of the sweep, then finds the latest entry and earliest exit of any axis, and returns true if entryTime <= exitTime && entryTime <= 1.0 && exitTime >= 0.0. I'm not sure which is easier to understand, but they're both cool!

  • @samovar9349
    @samovar9349 27 днів тому

    When is the next episode?

  • @pushqrdx
    @pushqrdx 29 днів тому

    Is there a name for the color scheme you're using in this video? I find it very easy on my eyes and wish I can use it for code.

  • @CaoticLevel
    @CaoticLevel Місяць тому

    I liked the thumbnail.

  • @ryanlockhart5328
    @ryanlockhart5328 Місяць тому

    I may have calculated it wrong but I believe 20 MiB is 20,971,520 bytes, not 2,097,152.

  • @AntonioIvoDaSilvaGomes
    @AntonioIvoDaSilvaGomes Місяць тому

    Nice explanation. What font are you using in your terminal?!

  • @hawkbirdtree3660
    @hawkbirdtree3660 Місяць тому

    It's sad that corporations have convinced everyone that they are not capable of making a game, without their specific software. Many of those commercial game engines have tons of bloat that's not necessary for most games. Commercial game engines are convenient; up until that company decides to screw you over; trying to please their investors.

  • @arthurbotelhocosta
    @arthurbotelhocosta Місяць тому

    Just a quick question: I ran into an issue where my delta is always zero. Didnt figure out why.

  • @noahtoonscomedy
    @noahtoonscomedy Місяць тому

    LINK : fatal error LNK1561: entry point must be defined

  • @ggmh-gh7zx
    @ggmh-gh7zx 2 місяці тому

    when i try to run it using the x64 terminal it say R not defined return error etc cam you please give me a solution?

  • @anonimowelwiatko9811
    @anonimowelwiatko9811 2 місяці тому

    Cherno mentioned something really important. If you create entities that can have multiple components, store them as pointers or even worse, create them inside Entity, you will end up with high memory usage and in case of iterating through components and dealing with elements, it will become a huge mess with bad performance. Idea of having entity just as an ID or keep this connection to component but within systems, iterate over components, not entities itself is much more appealing and performant.

  • @aaronbrown3820
    @aaronbrown3820 2 місяці тому

    Hi Dylan, I am just relearning C, can you write out the implementation for the array_append function at 4:08? thank you

    • @DylanFalconer
      @DylanFalconer 2 місяці тому

      Hi Aaron, I have a full implementation available if you click the Substack link in the description. Cheers

  • @ebx
    @ebx 2 місяці тому

    Yep! It all comes down to what you want to do. Do you wanna make a game? Just use a game engine. Now, if you want to, or have fun, having control and doing everything by yourself, go for a game engine. But keep in mind that if you wanna build a game engine, it's because you want to build the ENGINE, and make games above that, not to JUST make games.

  • @SynthByte_
    @SynthByte_ 2 місяці тому

    I notice that most that say don't create a engine did so as a starter project even though it's a quite advanced project. You need to know how other engines work and even make games in them before getting to the point of making your own. It's like never watching a movie before and trying to make a big production movie for your first one. It won't work unless your willing to learn everything that comes with a game engine.

    • @DylanFalconer
      @DylanFalconer 2 місяці тому

      Yeah, there are some big caveats. I made this video at a time where the whole of gamedev social media was flooded with "Don't make games from scratch - it's a waste of time." I just wanted to provide some counter arguments for why you may want to consider it.

  • @SynthByte_
    @SynthByte_ 2 місяці тому

    Not a lot of people realise that maybe people just want to make tools instead of games. and I find it strange to discourage it because without these types of people you wouldn't have any type of game engines in general. when you build something yourself you know how to use the engine fully and it's easy to create what you want instead of having to learn a already pre-made engine. During a game jam this helps a lot because instead of having to learn the engine you can just focus on creating. also game jams are a good way to battle test your game engines it's good practice to make games with your engine so you know it does what you want otherwise you might be spending years on systems you might never use.

    • @DylanFalconer
      @DylanFalconer 2 місяці тому

      Yeah, there are a few people on the Discord server that just want to make tools and engines. +1 on game jams being a good proving ground.

  • @Burgo361
    @Burgo361 2 місяці тому

    Vectors were the primary reason I started using c++ instead of c I don't like the idea of hard coded limits all over the place, I will be giving this method a try I actually did assume that the optimisation of vectors would be hard to match

  • @VoyivodaFTW1
    @VoyivodaFTW1 2 місяці тому

    excellent video. what debugger was that at the end.

  • @alexdefoc6919
    @alexdefoc6919 2 місяці тому

    My extension of this take : make an arbitrary engine from the stuff you used a lot and frequently when you made your MANY games. This implies you in the first place, make many games without a game engine, but in your style. That's where a engine starts.

  • @ugurcan969
    @ugurcan969 2 місяці тому

    This is a bad example of ECS, go look for a better implementation.

    • @DylanFalconer
      @DylanFalconer 2 місяці тому

      Can you explain why it's bad? I bet you can't

  • @jlebrech
    @jlebrech 2 місяці тому

    Some engines do too much, you can use Raylib, MonoGame, Godot, Flax if it's a simple game, if you want something AAA you need Unreal possibly and also a whole team.

    • @jlebrech
      @jlebrech 2 місяці тому

      an engine written on top of Raylib would be nice, say a scene/map editor and other helpers.

  • @kishirisu1268
    @kishirisu1268 2 місяці тому

    Looks like same learning pet project I done for myself - dynamic arrays for 2d game objects. Every C++ user must do it once 😊

  • @mythacker4365
    @mythacker4365 2 місяці тому

    Thanks. Besides all debate happening in comment section, I learned something today. That's good 😊.

  • @Gunwoo_Gim
    @Gunwoo_Gim 2 місяці тому

    This comment is quite irrelevant because the video doesn't cover anything about big 128+ bit aligntment, but I have a question that I'm too lazy to benchmark myself and get the answer for, and would like to share some things you can consider when assigning data in memory: I wonder whether the AVX code that accesses 32-byte aligned data is significantly faster than the unaligned AVX code! I will personally use aligned data though until It's proven that there is no corner case where unaligned SIMD code will be significantly slower than the aligned one on a modern CPU. --And then I have another question: Which model is the last CPU on which unaligned SIMD code is significantly slower? I guess a simple C code that utilizes an array in function call stack can align the array with 16-byte alignment for SSE, and 32-byte alignment for AVX. --when given -ftree-vectorize or -O3 You have ___builtin_assume_aligned() and __attribute___ ((target ("avx"))) --Look them up if you're interested in letting the compiler know that the data in heap is aligned, and allowing the compiler to write AVX code for a specific function. Would you want data alignment in heap for SIMD instructions even when you write only in plain C without SIMD intrinsics or stuff? Yes, because compilers do use SIMD instructions sometimes. "Vectorization is enabled by the flag -ftree-vectorize and by default at -O3."; Again, I'm not sure if aligned SIMD code can be significantly faster than unaligned ones.

  • @faucar93
    @faucar93 2 місяці тому

    Why not using or comparing with the CDS library ?

  • @GeorgeTsiros
    @GeorgeTsiros 2 місяці тому

    congrats you re-implemented a worse std::vector. This is the kind of shit why c++ exists. If compilation speeds are what hold you back, think hard about _why_ that is.

  • @SibbeeeGold
    @SibbeeeGold 3 місяці тому

    General Kenobi

  • @Bolpat
    @Bolpat 3 місяці тому

    1:10 Undefined behavior (UB) is one big source of C’s incredibile performance. All really fast languages have UB, such as C++, D, and Rust; some of them hide them behind special constructs so that you enter the territory with UB traps knowingly and willingly with hopefully the necessary knowledge and attention. When absolutely everything you can do in a language is well-defined, the compiler must produce machine instructions that work in every case, even really niche cases. With UB on its side, the compiler may assume that bad things just don’t happen (that’s essentially part of the definition of UB) and use that assumption to take shortcuts (a.k.a. optimizations) such as not actually checking if argument values are not allowed or that a potentially infinite loop eventually reaches the break statement. (An infinite loop without side-effects is UB in C.) A program with UB has a bug. Sometimes like in 1:10, the program provably has UB in every run, so the compiler need not even issue a printf call in the binary since before the printf call, you already put the program in an invalid state. But UB can even travel backwards in control-flow! Even if after the printf call you did the array shenanigans, the compiler can optimize away the printf call reasoning that after the printing, control-flow exerts UB, but that can’t happen, so the print can’t happen, so it eliminates what it proved to be the dead code”. If the program read the array index from user input and later does calculations on it, the compiler is free to assume the index was in array bounds. There are funny UB things like making a non-null pointer point to an address that’s not inside an array or exactly behind the last element of an array which are UB. Another is that in C, signed integer arithmetic can’t overflow (it’s UB), but unsigned integer arithmetic is modulo its bit size. Dividing by zero is UB (obvious) and dividing INT_MIN by −1 is also UB. In the example, you put 420 in a cell and read that cell. A smart optimizer might just use the value and not needlessly store and load the value. (It would be allowed to do that if the value isn’t read again, even if it were in bounds.)

  • @jonshouse1
    @jonshouse1 3 місяці тому

    You are confused. Undefined behavior is where the result of a set of operations may not be consistent, or where the language does not define the outcome of the operator. Accessing C arrays out of bounds in not undefined, it is just stack corruption. The fact that the stack size may accommodate the access does not make it undefined, it is just plain old corruption, illegal, wrong, faulty. It is an important distinction, as true undefined behaviour does exist, normally as a result of architecture specific details clashing with code generation. Faulty code seeming to work at runtime is not undefined, it is just unfortunate, and implementation specific - it may well crash instantly on some O/S Arch combination but run seeming without issues on others. This is why stack checkers exist, -fsanitize=address on gcc is good example and (I suspect, not tried it) would detect your example fault.

  • @kumboi
    @kumboi 3 місяці тому

    Sick video! I learned a lot

  • @juanandresnunez658
    @juanandresnunez658 3 місяці тому

    too advanced for me lmao

  • @charlescox290
    @charlescox290 3 місяці тому

    So, basically, you brought Ada arrays into C? Well, not quite. You don't have any type enforcement on the index.

  • @user-nt3rn8cd2g
    @user-nt3rn8cd2g 3 місяці тому

    That is not kinda stupid, init a value in a index that is too big for the array size actually allow the programmer this ability of writing to a memory that is not his, you can use it to kinda hack your program or do a lot of cool and weird things. C supposed to be super flexible for those purposed, thats why it so hard to be a good programmer in it

  • @mamertvonn
    @mamertvonn 3 місяці тому

    Implemented one of this before with excessive use of macros to replicate templating. So, I can easily implement an 8t, 16t, 32t and 64t dynamic array

  • @someuser828
    @someuser828 3 місяці тому

    Regarding the first example, I'd personally I'd use a zero size array rather than a void pointer then malloc/realloc sizeof(struct) + total size of array

  • @eddiebreeg3885
    @eddiebreeg3885 3 місяці тому

    I personally find the idea of dismissing C++ solely because of compilation times completely insane. Yes, compilation times matter, to an extent... but so do a lot of other factors, like language and standard library features, safety, ease of use... There a legitimate reasons why you'd want to use C over C++. There are also a lot of reasons why you'd want to use C++. The first and most obvious I can think of was actually mentionned: C++ has templates to handle type agnostic interfaces, C does not. But also: C++ allows you to handle resource ownership with classes, using RAII, move semantics etc. C does not, it is up to the user to handle copies, moves, destruction. This is much more error prone, and that's one of the reasons we still often go for C++, regardless of compilation times.

    • @teranyan
      @teranyan 3 місяці тому

      You find it insane because it is insane. The person who made this video clearly has no idea about business. Increased compile times will lose some amount of money to time, but you have the opportunity cost of using a much more primitive language. Which is not always worth it. I would argue that compile times could never possibly be a business reason to pick C over C++. Terrible video.

    • @eddiebreeg3885
      @eddiebreeg3885 3 місяці тому

      @@teranyan I wouldn't go as far as to say the video is terrible, to be fair, I find the idea interesting and useful for those who legitimately want C for a reason or another. I just wanted to point out this specific reason should absolutely not be it.

  • @clarencewashington7881
    @clarencewashington7881 3 місяці тому

    Vim user

  • @mariosshadow8533
    @mariosshadow8533 3 місяці тому

    I don't know what the pattern is called, but it is not uncommon; apparently computer networks use this to avoid sending more that one packet. You may also work with the type as if it was just a pointer, which means it fits in a register. You can then use a macro to add the size of the header to the original pointer, and then get the element from there. As pointed out by the pinned comment, the size is not item_size * capacity + sizeof (Array_Header). You forgot the padding. The Array_Header size might not be a multiple of the alignment of the element type. If using GNU's C dialect, you can declare your structure to have a zero sized array at the end, which will add the necessary padding to the structure. In C99, you could use an empty array at the end of the structure, but it does not include padding, making it redundant. And if your problem is that you like operator overloading: 1. That's a C++ feature. Trying to hack it into C is a bad idea. 2. you could make a function array_data_ptr(array*), but the lack of generics means it would be used like ((int*) array_data_ptr(array))[index]. Not pretty. For the less knowledgeable, the C++ example at 1:40 is incomplete. You can't vector::at with a random index. It has to be in range of the length, not the capacity. Otherwise the elements would not be contiguous. Opinion stuff: I've been viewing a lot of material on C and I'm just left thinking: why are we still using it? Like did not anybody think of replacements before Zig and Rust??????? C flatout makes your programs worse, no contest. void* is a horrible, HORRIBLE abstraction for general use. It's a pointer, not a value, meaning a value has to be stored somewhere that is not the array, deferring the objects lifetime management to something else. Some people store the objects on the heap, for some reason. No namespacing means that people do their namespacing, and when using namespaced stuff you can't remove the namespace, leading to overly verbose names. C could have just implemented them with emiting names with _, which is a valid character in everything I've ever seen. Wait, C actually has namespacing, but only for structs, enums and unions, with their respective keywords for some reason, leading to the rampant use of typedef. Macros are... just... copy... pasting... stuff???? might as well use automake. The C preprocessor is just a program unrelated to the compiler. This also leads to buffer overflows are too easy to trigger. Just pass a string without a null Null terminated strings were good in the 1970 for the PDP-11, and nothing else after that. string length is given in linear time. Nothing more to say, that's just bad. Assemblers nowadays can store a normal ASCII string and give you it's length at assembly time for you to store in the binary's data section. I don't even know why we call them strings, it's a character buffer without length and no invariance checking. Recently I had to help a poor soul whose problem was that the buffer he was reading to didn't store the null character. I recognised in 1 second (you would too), and my solution fixed the problem immediately. Oh, and strings can't include the null character, which actually has some uses. There's literally no way to define compile time constants (yet, C23 has constexpr). #define is not a solution, the preprocessor sucks, and forces the compiler to analyze the replaced values everywhere, leading to larger compilation times. The inline keyword exists, I guess. And no, it does not inline functions. Go figure. static inline is a valid combination too, when all it does is just static, completely ignoring inline. static is not the default. The default is extern, and you can prepend it to anything, but why would you? It's the default. It really only matters for global variables, which are discouraged, from other C files. Header files (which are copy-pasted recursively by the preprocessor) suck, no wonder languages that are not derived from C have never implemented them. Oh, and they increase compilation times by a considerable amount, as demonstrated by C++20 modules and, oh yeah, every other language ever. They are also read everytime they are included. I literally can't count the amount of times I've seen a linked list where a dynamic array would be more appropriate (because modern processors, memory efficiency, etc...), just because C does not provide data structures in it's standard library because it CAN'T due to the lack of generic types. No, _Generic is not a replacement, it literally matches on a static amount of types. True generics allow the compiler to emit code that is tailor made for that type. The lack of (monomorphised) generics promotes the use of void* (type-erased generics) without the safety of the type, or the safety of a garbage collector to manage the pointed-to-values, or the speed of implementations that use values rather that pointers. Error handling is a joke. Errors are propagated by a single sentinel return value, and then you have to go out of your way to check errno, a seamingly unrelated variable. I would rather use inline assembly than syscall wrapper functions, as the wrapper functions only return a single sentinel value and set errno, making me checking another, unrelated thing, where syscalls return both values and errors, meaning when I check if a returned value is valid, I also check what error it is. Apparently no one knows about unions, even less how to make tagged ones. No data hiding means that anyone can just overwrite the values on your struct or union, and then you can say goodbye to your invariance. No RAII patterns nor defer means that error handling, which is already verbose enough, is even more verbose. You either repeat code, which is discouraged, or store your return value and using labels, which are discouraged. I truly believe that if your first programming language is C, it will make you a worse programmer for longer than if you used anything else. BTW, At 4:28 your array_append call should pass a void*, but it got passed an int.

  • @ishaankapoor933
    @ishaankapoor933 3 місяці тому

    What are you using to make such videos. i.e. what software is that were you click around to minimize / maximize topics/headings.

  • @A404M
    @A404M 3 місяці тому

    my_array.at(69) is not equal to my_array[69] one has index check the other doesn't have so you can decide additional safety or additional performance

  • @AleksyGrabovski
    @AleksyGrabovski 3 місяці тому

    If you need a dynamic array just to have a growing string, then you don't need any structs and allocators and anything complex, you can just use regular old char* and write a function that will reallocate each time you add something to that string: `#define APPEND(Str, Fmt, ...) asprintf(&Str, "%s" Fmt, Str, __VA_ARGS__);`

  • @ryanc674
    @ryanc674 3 місяці тому

    is there any command that i can use to show the profiles of two programs at 2:56

  • @songersoft
    @songersoft 3 місяці тому

    I like the brackets too. Subbed

  • @hasanbaysal5526
    @hasanbaysal5526 3 місяці тому

    Did you mean linked list :)

  • @rebus_x5313
    @rebus_x5313 3 місяці тому

    Yep. Preserve software and compilers, folks. And make backups.

  • @yuan.pingchen3056
    @yuan.pingchen3056 3 місяці тому

    This is a pointless topic. The C language was used to design operating systems in the 1970s. It enforced structured data structures and pointer manipulation. Even if it allowed you to dynamically allocate memory to the operating system, that's not what it was. If you want to keep your investment in C language syntax, you should try to learn C++

    • @cheesepie4ever
      @cheesepie4ever 3 місяці тому

      Pure waffle 😂

    • @yuan.pingchen3056
      @yuan.pingchen3056 3 місяці тому

      @@cheesepie4ever Your metaphor is inappropriate, add dynamic array to C language just like add refrigerator function to your bed.

    • @DylanFalconer
      @DylanFalconer 2 місяці тому

      Sounds like you are jealous of C

  • @revealingfacts4all
    @revealingfacts4all 3 місяці тому

    I honestly don't understand why comparing C/C++ to things like Java or other managed languages. You have to understand that C++ and to a lesser extent C are lower level languages and they do not manage memory nor does the compiler and we like it that way. I don't want the compiler thinking for me. There is a myriad of reasons why too. The nice thing about C and C++ is you can use libraries that do manage memory for you or not; you don't have that option with managed languages std::vector is a library and not the language. SO MANY PEOPLE conflate things like std::map, std::vector, etc... as C++. C++ is simply the 'if', 'for', 'switch', 'class', 'template', etc... statements. I work both in desktop, rich GUI, environment as well as in embedded. The only thing that is common between those two worlds with regard to C/C++ is the C and C++ language - not the language support libraries. #define is also a pre-compiler language statement too. You don't need #define as you show in your video and many argue you shouldn't either. Scott Meyers, as one, who recommends to prefer the compiler over the pre-compiler. Finally, the whole dynamic memory topic - you should know you can, through operator overloading, make a C++ object appear or behave just like a managed language. The main take away for anyone reading this is C/C++ is vastly more powerful because it allows one to write code as close to the metal and do more yourself or as abstract as you want.