Learning Programming by Trying and Failing // Code Review

To try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/TheCherno. The first 200 of you will get 20% off Brilliant’s annual premium subscription!
Patreon ► / thecherno
Instagram ► / thecherno
Twitter ► / thecherno
Discord ► / discord
🌏 LINKS
How to Properly Setup C++ Projects ► • How to Properly Setup ...
Code ► github.com/jkatsanis/SpriteEn...
Send an email to chernoreview@gmail.com with your source code, a brief explanation, and what you need help with/want me to review and you could be in the next episode of my Code Review series! Also let me know if you would like to remain anonymous.
Hazel ► hazelengine.com
🕹️ Play our latest game FREE (made in Hazel!) ► studiocherno.itch.io/dichotomy
🌏 Need web hosting? ► hostinger.com/cherno
📚 CHAPTERS
0:00 - Hello
1:54 - Story time with Cherno
5:38 - Entity Component System (ECS)
💰 Links to stuff I use:
⌨ Keyboard ► geni.us/T2J7
🐭 Mouse ► geni.us/BuY7
💻 Monitors ► geni.us/wZFSwSK
This video is sponsored by Brilliant.

Пікірлер: 94

  • @TheCherno
    @TheCherno5 ай бұрын

    Thanks for watching! Don’t forget you can try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/TheCherno. The first 200 of you will get 20% off Brilliant’s annual premium subscription!

  • @wjrasmussen666

    @wjrasmussen666

    5 ай бұрын

    Sure, do another video on how you would refactor this code. Or, have you done a video on profiling?

  • @y4ni608

    @y4ni608

    5 ай бұрын

    @@wjrasmussen666 I have actually implemented all the stuff cherno advised me to do (build system, project strcture, scenehandler, and even the naming conventions) i just really hope he can create a last and final episode, i hope to get a review for that. And i didnt even really intent to create a ECS

  • @mobslicer1529

    @mobslicer1529

    5 ай бұрын

    did you see my email about my c game engine

  • @learningtoride1714
    @learningtoride17145 ай бұрын

    Failing to learn or failing, to learn.

  • @prakashraj4519

    @prakashraj4519

    5 ай бұрын

    I think it's the later

  • @user-sl6gn1ss8p

    @user-sl6gn1ss8p

    5 ай бұрын

    you should open a fortune cookie business

  • @BruceOnder

    @BruceOnder

    4 ай бұрын

    ​@@user-sl6gn1ss8p Or, should they open a fortune, cookie business?

  • @alexkhazov7264
    @alexkhazov72645 ай бұрын

    I don't think the object slicing remark is entirely correct. It has nothing to do with the objects being stack allocated. The issue would occur if you were to pass in a subclass type by value to a base class type. This could happen even with a heap allocated object if you were to dereference the subclass type when calling a function that takes a base type by value. The most important thing is everywhere where you take in a base class to take it in by pointer or reference... Which you should be doing normally anyways - don't make redundant copies :)

  • @Gastrostomi
    @Gastrostomi5 ай бұрын

    That was informative in a way I did not expect. I have never really thought about the deeper inner workings of how an ECS is structured and how it works.

  • @romainvincent7346
    @romainvincent73465 ай бұрын

    Yes! Possible solutions would be a great follow up!

  • @GB_Parametric
    @GB_Parametric5 ай бұрын

    Would love to see the implementation of ECS.

  • @whoshotdk

    @whoshotdk

    5 ай бұрын

    Me too, proper ECS is *hard*, for many of the memory reasons The Cherno stated. I've made a partial-ECS which works like "old" Unity does (Entity has Components) but trying to come up with something more efficient than that has beaten me many times so far!

  • @AnteP-dx4my

    @AnteP-dx4my

    3 ай бұрын

    SAME !!

  • @user-sl6gn1ss8p
    @user-sl6gn1ss8p5 ай бұрын

    I really like these reviews, but I do feel like in a multi-episode series like this one it would have been nice to see what the thing actually does and maybe skim a sample project.

  • @mariwanj5292
    @mariwanj52925 ай бұрын

    Please make a diagram design structure how all these parts should be designed and make it visual .. from entity, to requiremnets for each entity.

  • @ProGaming-kb9io

    @ProGaming-kb9io

    5 ай бұрын

    He already has the game engine series, there he does it in the right way

  • @mariwanj5292

    @mariwanj5292

    5 ай бұрын

    @@ProGaming-kb9io I know, but visualizing that in a structured diagram will help to understand better.

  • @gabrielbeaudin3546
    @gabrielbeaudin35465 ай бұрын

    After listening to your channel a bunch, I realised what I really wanted to build is an engine and not an editor. My "Compositions" should just be known at compile time because I won't use an editor to build them. I ended up not having a entity component system at all. I know my classes will be next to each other in memory and won't cache miss.

  • @lromaniuk
    @lromaniuk5 ай бұрын

    Weather members will be stack or heap allocated is determined how you allocate them, not where you put them in the code. There is nothing wrong with use of polimorphism to make an ECS - and still you can put derived classes in their seperate memory buckets - nothing stops you from doing so. Personally I would not put any functionality in components - just the data. All of this continious memory effort is useless if you have to process logic that requires multiple component types at the same time - basically you will be fetchind data from different buckets all the time causing a lot of cache misses - but its true that some systems (rendering) may benefit from such arrangement.

  • @natescode

    @natescode

    4 ай бұрын

    *whether

  • @the_gobbo
    @the_gobbo5 ай бұрын

    Really cool book reference! will definitely check it out!

  • @user-sl6gn1ss8p

    @user-sl6gn1ss8p

    5 ай бұрын

    it is a kinda dense book, but it is really, really good

  • @sirpalee
    @sirpalee4 ай бұрын

    Memory layout of components is an implementation detail of ECS, not a requirement for an ECS system.

  • @user-ib3gl6pj6h
    @user-ib3gl6pj6h5 ай бұрын

    Nice to see you again

  • @sinom
    @sinom5 ай бұрын

    Writing a custom arena allocator would be an interesting video topic

  • @Theawesomeking4444
    @Theawesomeking44445 ай бұрын

    the dev : please roast me the cherno : for each (lines of code) make a 30 minute video on why that line of code is bad

  • @maxrinehart4177

    @maxrinehart4177

    4 ай бұрын

    Every dev would be lucky to get roasted like this. learning new things, getting feedback on why their implementation is wrong, and how to fix it is by far the best kind of code roasting.

  • @gabrielciordas3369
    @gabrielciordas33695 ай бұрын

    Great video as always Cherno, you're like the Bob Ross of programming in c++

  • @gelis07

    @gelis07

    4 күн бұрын

    sebastian lague is the bob ross of programming

  • @R4t4n
    @R4t4n5 ай бұрын

    I actually have pure virtual base class in my current "ECS" I am building and I still store them in continuous memory for performance. Reasoning behind is that all our components have to have some common functionality and some required methods for template hell that is happening around. I am trying to shield colleagues from engine related things as we are not any close to gaming project and renderer is just a tool for us.

  • @_blank2123
    @_blank21234 ай бұрын

    Multi threaded design patterns would be a great because as we start to scale the applications by adding more features the applications start to get slow so please 🙏 do teach us by giving some suggestions and stuff...

  • @maarten9222
    @maarten92225 ай бұрын

    A lot of the things you mention I see in Rockstar's Rage engine although they love inheritance.

  • @tiagocerqueira9459
    @tiagocerqueira94595 ай бұрын

    If your child component need access to the parent and you store the parent pointer, it is usually a red flag.

  • @sub-harmonik

    @sub-harmonik

    5 ай бұрын

    how would you do that otherwise? store an index into some entities table?

  • @DeusExAstra

    @DeusExAstra

    5 ай бұрын

    I dont think that's necessarily the case. It depends on how things are structured and what the entities and components do.

  • @yesntpittzant4156

    @yesntpittzant4156

    5 ай бұрын

    ​@@sub-harmonikDepending on the situation, having a list of certain entities can be reasonable. But that's not the point. If you make an Entity Component System and your child components needs access to the parent, then it kinda defeats the whole purpose of having an ECS. Because ECS is "best" when you have a clear hierarchy and independent components. If the child component needs access to the parent, you might as well make it one component. Or restructure the components

  • @RigelOrionBeta

    @RigelOrionBeta

    5 ай бұрын

    An index is essentially a pointer. Just an offset to a memory address. Depends entirely on what that thing points to. Not necessarily a bad thing.

  • @MrHaggyy

    @MrHaggyy

    5 ай бұрын

    @sub-harmonik - just implement child in parent and not every object needs every method - try different data and function structures that avoid the problem by good design. - try a virtual class and propper VTable design. -put each object in a data structure and let the program code deal with seperaten, do not abstract in the class.

  • @rtc44
    @rtc445 ай бұрын

    1. Fields are not stack allocated. 2. Object slicing is not about allocation, it's about copying the object by assigning to somewhere, It's about static type. Sorry, can't resist)))

  • @Stroopwafe1

    @Stroopwafe1

    4 ай бұрын

    When the class/struct is stack allocated, its fields are stack allocated, when the class/struct is heap allocated, its fields are also heap allocated. Check it out in godbolt. Fields are just an offset from the first field

  • @gabetobias443
    @gabetobias4435 ай бұрын

    I would love to see you build a memory arena system but I'm also curious to see how you would go about creating a simple custom ECS system

  • @fappylp2574

    @fappylp2574

    5 ай бұрын

    Me too, i always get hung up on iterating over groups of components. Separating the component arrays into archetypes seems sensible, but how do you then access these separate arrays in a sorted manner (for example for forward rendering)?

  • @lromaniuk

    @lromaniuk

    4 ай бұрын

    @@fappylp2574 You dont, you just itarate over all renderables and submit work to your rendering system which sorts your rendering commands however you need and then you submit your sorted rendering commands to the rendering API. Decouple systems and keep their responsibilities isolated.

  • @CreativeSteve69
    @CreativeSteve695 ай бұрын

    I work with using python, when I start on a small scale project can I send it your way Cherno for a episode of this fun series in the future? or in css/html?

  • @Spirrwell
    @Spirrwell5 ай бұрын

    Man, with how hard you're tearing into this, you should do a code review of the Source SDK for Source Engine. This code here, while having some questionable design decisions, is not that bad.

  • @bluesillybeard

    @bluesillybeard

    5 ай бұрын

    If what I've heard is correct, the source engine is a (still fairly well optimized) mess and a half.

  • @Driver___
    @Driver___5 ай бұрын

    I actually have 2-3 other similar projects downloaded and opened from where I am learning to write my 2d-3d engine

  • @MasonDixonAutistic
    @MasonDixonAutistic5 ай бұрын

    The Game Engine Architecture(3rd edition) book is currently discounted on Routledge, so I've ordered it and can stop sucking and start failing...upwards.

  • @spaaske
    @spaaske5 ай бұрын

    Where can I find more elaborate information on keeping a flat structure rather than keeping a hierarchy?

  • @informagico6331
    @informagico63315 ай бұрын

    It is simply about to study enough to get the knowledge that boosts your project, and to practice enough to learn, get results, and not to get frustrated becuse of the infnite available contents to study. I feel this the most difficult part of software engineering, to make the optimal solution acquiring enough knowledge to reach it. Do not just study programming and do not just make programs, find the optimal way to get things done.

  • @MrHaggyy

    @MrHaggyy

    5 ай бұрын

    And once you are decent with your study start and keep breaking and fixing larger and larger systems. If you know how an problem or issue is made in a small scale it much more likely that you catch it in a big system.

  • @zanagi
    @zanagi5 ай бұрын

    Would want to see young Cherno code

  • @gsestream
    @gsestream5 ай бұрын

    learning is not copying, by instructors commands, as you said its more 1st hand experiencing (the why's rather than 2nd hand copying like a machine). why do you have to call something ecs or something btw, thats the teachers dictation. the term definition or even dictating of using those terms will nuke a learner into a copy machine. get rid of pointers and all complexity as fast as you can. not productive, its an inhibitor. first solve figure out the memory pointers issue, to make a base system to build on, so that the future building is more simply constructed, you would not re-solve making a building block each time, but solve it once, then use the same mold for all the other less custom blocks. iterating versions of the same program, prototypes is no shame or detriment, its the actual learning, by you, not someone else. you should design and rewrite your stuff many times, after writing it for the n previous times lol.

  • @rmt3589
    @rmt35895 ай бұрын

    Yes! Please show us how to solve these issues. I just, in this video, found out you can have hierarchy in ECS, which I thought was a defining thing in OOP besides classes and subclasses.

  • @andreirusei2466
    @andreirusei24665 ай бұрын

    What theme are you using for visual studio?

  • @lalishansh

    @lalishansh

    5 ай бұрын

    Dark theme and visual assist color scheme, though if you are student i would recommend JetBrains IDE's (Rider for Visual Studio Solution based), they are faster and more accurate than `Visual Studio + Visual assist` (they just took time indexing symbols, after that they blaze through)

  • @mad_circuits
    @mad_circuits5 ай бұрын

    1:35 It is not possible to "just build, not learning". My opinion.

  • @meistrimeez
    @meistrimeez5 ай бұрын

    There is always the dilemma when choosing between composition and inheritance. I don't think there is right and wrong here. It's just the experience or history of the individual developer.

  • @tematoscybersage5626
    @tematoscybersage56265 ай бұрын

    I think that iterating contiguous memory gives benefits, because in that cases computer knows start and end point of data that need to be computed and can activate assembler feature called DMA(Direct Memory Access). I used this feature when I was making game for NES to draw background of level in fast way. But I am not sure does C++ uses that same feature with contiguous data.

  • @whoshotdk

    @whoshotdk

    5 ай бұрын

    Its been such a long time since I did NES ASM but "STA $2007" rings a faint bell :P Did you ever finish and release any games? I'd be interested in seeing them. I started several myself (including a version of Stardew Valley lol) but never got round to completing lol.

  • @tematoscybersage5626

    @tematoscybersage5626

    5 ай бұрын

    @@whoshotdk I just made simple side-scroller with easy boss fight. It was the beginning of my gameDev path. Yes, I released more then one project, but not for NES. For example Dreamcast remake of Textorcist. If you want, I can send you my game and also sources for it;) but I need to correct it a bit, because it was made as a present for person that I don't like to be in a game anymore😄so if you want, after correction I will send it;) P.S. the only one thing that I didn't get my hands on it was sound, when I understand complexity, I understood that there is not much free time left, to implement that

  • @whoshotdk

    @whoshotdk

    5 ай бұрын

    ​@@tematoscybersage5626That sounds really good! I remember how hard it was to implement decent platformer physics. Don't go out of your way to correct your game just to show me. But if you ever decide to upload to Github or somewhere like that, do send me a link!

  • @tematoscybersage5626

    @tematoscybersage5626

    5 ай бұрын

    @@whoshotdk Ok, so I will do that. Will notify you here when it will be ready

  • @sub-harmonik

    @sub-harmonik

    5 ай бұрын

    these days it has a lot to do with cache and ram locality. (the caches will read 'cache lines' into faster locations closer to the registers, so when you get data that's next to itself it's way faster because it will already be read into the cache as part of the same cache line)

  • @vcv6560
    @vcv65605 ай бұрын

    Success or failure, its all yours. Try, fail, correct, continue. I'm nearly 60 and this remains a truism in my life. Its the only thing that works. For the next I'll quote Calvin Colliage (President of the United States in the 20s): “Nothing in this world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. The slogan 'Press On!' has solved and always will solve the problems of the human race.”

  • @rishavgaming8662
    @rishavgaming86624 ай бұрын

    I was thinking that can dani have comeback but not with unity but with Hazel make video like back then

  • @Nhurgle
    @Nhurgle5 ай бұрын

    If you are on a budget, Game Engine Architecture can be read on the Internet Archive ;)

  • @bekdev564
    @bekdev5645 ай бұрын

    I'd love to see your reaction on GTA VI trailer just like your Unreal Engine 5 reaction video!

  • @TheMrTka4
    @TheMrTka45 ай бұрын

    I think a lot of things have been said over the course of all these videos. The code author can begin to correct or rework the project at this stage. Everyone needs a little refresher, different code, different author.

  • @y4ni608

    @y4ni608

    5 ай бұрын

    Yeah i did spent alot of time rewriting it and im really happy now. I hope he reviews the newly written code + project structure

  • @powerclan1910

    @powerclan1910

    5 ай бұрын

    @@y4ni608 let's hope @The Cherno gets to see this

  • @ev3rybodygets177
    @ev3rybodygets1772 ай бұрын

    lol every time i watch one of these reviews i always walk away thinking there are more issues with the underlying language c++ than the actual code....

  • @gower1973
    @gower19735 ай бұрын

    He also spelt physicsbody wrong in the typename

  • @krids3546
    @krids35465 ай бұрын

    Black myth wukong,i need reaction from u,please❤

  • @scoliossis
    @scoliossis5 ай бұрын

    happy birthday for 5 days ago i think

  • @n8style
    @n8style5 ай бұрын

    love a Ph *s* ysicsBody, much better than a PhysicsBody lol

  • @skeleton_craftGaming
    @skeleton_craftGaming5 ай бұрын

    Java code is always horrible... (saying this makes me happy) though no its not Java. All code written in any true OOL* (ie java, JavaScript) . I think that true OOP generates messy code as a necessity *to be a true OOL at least two things have to be the case 1) the smallest exposed unit in a translation layer has to be an object 2) all classes [either directly or indirectly] have to inherit from one single base class [most of the time named Object]

  • @nathbarbosa83
    @nathbarbosa834 ай бұрын

    I love your videos, but for some reason they give me headaches

  • @leshommesdupilly
    @leshommesdupilly5 ай бұрын

    Did the same lol

  • @mjthebest7294
    @mjthebest72945 ай бұрын

    Where is the raytracing series? :/

  • @Mempler

    @Mempler

    5 ай бұрын

    ive eaten it.

  • @easyBob100
    @easyBob1005 ай бұрын

    Over complicated IMO.

  • @sakithanavod9289
    @sakithanavod92895 ай бұрын

    First ❤

  • @mehmedcavas3069
    @mehmedcavas30695 ай бұрын

    24 sec ago :O

  • @OwnerZBAT
    @OwnerZBAT5 ай бұрын

    second

  • @leshommesdupilly
    @leshommesdupilly5 ай бұрын

    Moral of the story kids: std::vector

  • @MrHuman-iy5lw
    @MrHuman-iy5lw5 ай бұрын

    I think we had enough of this repo

Келесі