How many times did you spot the cat? 🧐 Also you can try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/TheCherno . You’ll also get 20% off an annual premium subscription!
another reason for the struct. Fetching data only once and stuffing as much as you can into a single cache line. "I like that it's not forced into OOP design for the sake of it" 20 minutes later "If I did it myself I would make it all OOP" Old habits die hard.
I think it depends oop is very efficient for writing applications with different components and reusing them. But you don't want to overdo it, always prefer composition instead of inheritance and try to have your classes as immuatable as possible and limits to the maximum modification of objects outside of their own classes : object should handle themselves. Mixing with functionnal is also a good idea because of immuatability. Making module for utility makes sense it avoid the verbosity of oop. And honestly it also depends on what langage you use, certains are better in other aspects than other
The moment I saw the code, I immediately thought: Class, RAII, Destructor. Which is what he ended up doing. I won't pretend I'm a c++ expert. But I tend to use simple functions which mostly gather information for initializing objects. I did some c code in the past, and once I fully embraced OOP in c++, I never looked back. How miserable things were. OOP and RAII. I love it. But I don't work for a large programming company. It's mostly solo stuff. So I might lack exposure to other code. Why I like watching his videos.
Honestly very good code for what it does. Bad code is unnecessarily complicated code, with useless abstractions, obscure one liners and single character variable names
@@Cinarbayramictheres the idea of const as a promise. Essentially any time you create a function you const all inputs that you won't change. This means you can more easily understand how functions may impact data just by looking at the function def as const inputs won't change.
@@Cinarbayramici also found const to be completely useless concept that mostly obfuscates the code. I know what people say about const but i have never had any bug due to modifying something I shouldn't modify.
Maybe the code you said worst code made by 10 years old kid. When I was a kid, I made a ray tracing, and when I look back to the code when I'm an adult, I don't judge the code, I'm, just proud of my childhood.
About to send him the sidescrolling action-platformer I made when I was a teenager and didn't know what classes, interfaces, or lists were. The entire game takes place in a single update function with several hundred nested if statements. Every item and enemy is its own set of variables. It's made in Macromedia Flash MX. AlexIsCool321, you think bad code is your ally? I was born in it, *molded* by it.
I remember I did the same type of stuff with minecraft plugins when I was first learning, before java I only did batch and scratch, where in scratch that's kind of how I did everything, as scratch has no objects and I never really knew how to use lists appropriately. I was effectively doing everything with just variables and functions until I learned to use lists to make cooldowns, and then later learned how to properly use classes.
I’m getting a feeling that Cherno is self reporting with this one. This is 100% the first raytracer he made on an old usb stick he found while cleaning the garage.
Writing C++ with a functional style can be magical, too. I think as Cherno pointed out in previous videos, sometimes makese sense to have functions over classes
I understand what you mean but "functional" typically doesn't mean "mostly uses free functions". Instead it means code that uses higher-order functions.
@failgun higher order, yes. And an OOP minded might fall into the trap of using invariance, objects, and state. When instead a function doing a simple data transformation is all that is required
@@thewhitefalcon8539 they're not the same. procedural programming is a paradigm in which you structure your code as a series of control flow steps that operate on variables and bundle common step sequences into procedures (functions). functional programming is a paradigm in which you structure your code as compositions of functions. There's no control flow or variables -- you typically don't use any kinds of loops in FP, but instead write your programs recursively or as combinations of higher order functions like map, filter, fold, zip and join among others.
Const correctness is another thing that was missing completely. const float a, const float b etc. It does make a difference for the compiler and makes a huge difference when reading code, since you directly know what values cannot change in the function after being initialized.
One thing that is bothering me, and (I think) hasn't been mentioned, is how in SphereIntersect t0 and t1 are calculated for every pixel even though they are declared only in the scope of the function and not returned. So for every frame we have two operations with square roots which are fairly expensive performance-wise. In a regular raytracer we'd still calculate t0 and t1 for good reasons (which are mentioned in this video), but in this specific case there's no reason to.
"I didn't identify my member functions". Hungarian notation, one of the most pointless programming styles ever invented, particularly for strongly typed languages and especially C++ which allows you to create your variables where they are used. Plus it's 2024, every bit of information encoded into your complicated and confusing prefix is available from the IDE.
I did a game last year with a friend using SFML, a function has 56 arguments. Most functions have over 6 arguments. We were trying to finish everything fast. Help.
lol, I've been trying to teach myself C++/C#, on and off, for about 30 years. I'm sure I've written the worst code you've ever seen hundreds of times. Thanks for the channel.
I am sort of glad I was able to come up with a similar solution to improve his code, I was definitely coding like this a few years ago, global variables, singletons everywhere...
Also gripe about "code quality": It's very much scale dependent, and also dependent on the skills of the maintainers. Like the primary metric of code quality would be how quickly can you add a feature without any side effects, or how quickly you can onboard a new dev to make said changes. When you have a sub 1k line code base, almost nothing can be considered "bad". I have a few ~6k line files and those I would call bad code as it's the entire program in a single file and it starts to take a considerable amount of time just jumping around looking for specific things that you forgot the exact names of. You could make it "good code" by just splitting it up into different folders and files to compartmentalize what all of the different features/functions do, but that takes effort and I just never care enough to do it as I don't spend much time changing things these days.
The functions are doing the work, not the classes. The classes are organizing the code and making it more readable. Classes are not needed, but they can help. Classes can also get in the way of what you want to do. Deconstructing classes (moving functions out of classes) should be more commonplace.
I actually used the same GetDC trick for an image cat tool to view images in cmd. I no longer use it because I use the new windows terminal and it didn't work there.
@@user-sl6gn1ss8p I kinda wish that the new pseudoconsole subsystem would not eat arbitrary escape codes, so I could install a terminal that supports sixel, iterm2 or the kitty image protocol or some cool graphics like tektronix or regis. In linux you can just invent an escape code and implement support for it in a thirdparty terminal. You want audio escape codes, sure?, You want escape codes for app specific drag n drop, why not? you want escape code for tooltips/multiple fonts/popups/vsync/custom chraracters and icpns/...? I would have many bad ideas...
It seems like the best way to go is to start with just functions, then group them in classes as they make sense to you and which show to be useful. Another premature optimization improvement
The worst code I've ever seen was some React and NodeJS code at a previous employer. It was the worst example of over-engineering ever. Everything was so overly complex and difficult to do. Just changing a simple text label was complicated. I even argued with the tech lead about it more than once. I guess he thought the more complicated he made things , the smarter he felt as a developer. I think also it was his way of securing his job. By making the code super complicated, no one really understood it except him. But the code was very buggy, as you would expect, and just painful to work with. I eventually left after a few months.
16:06 I am not a programmer. Is there a reason that he writes b^2 as b*b? Is it a 'better' way to hand exponents? more performant? Easier to read? Easier to troubleshoot?
I agree that OO shouldn't be the only solution but rather a tool in the box, but in the case of a game or game engine, I feel like an object that separates out the functional bits of the program makes sense, especially when you consider that it makes it easier to run more than one at a time with ease. As for implementations of mathematical algorithms, I'd like to see some of the individual steps broken out into full-fledged functions marked as constexpr. However, I do agree on using a three piece vector to represent the data.
Regarding classes in C++: almost the entire STL is built of them, so I guess people in the standardization committee know what they are doing as well as STL implementers.
I just wanna say, I've been learning C++ more productively. Watching these videos are seriously amazing, especially the tutorials. I don't wanna sound like those idiotic bot comments, but seriously, thank you.
It's funny how you've done like 20 of these code reviews or whatever but you never seem to get much past their entrypoints lol... why not do a code review of AlmondCore?
6:08 I felt this :D I'm a university student and I started learning code from C. Then I studied OOP and now I literally cannot think about code without classes and objects. I am now learning C++ and I have some problems in using other paradigms (maybe because even outside of coding, my mind often structure concepts in a OOP way, don't know if it makes sense). Does someone have any tips or resources (preferably videos) to learn other ways to code, especially in C++?
he couldve also just implemented a vector multiplication function that takes to vectors to offload part of the math going on here. and if your really bothered with performance make it constexpr, static inline, or even a define do while 0 construct... one thing i dont think you did pick on is that the person has done all that math to calculate the points of intersection and then not do anything with them?!
@6:50 I only learned OOP about 3.500000001 years ago, but once I finally wrapped my head around it, I went absolutely balls-to-the-wall with it, and yeah, for at least 2 of those years: "everything had to be a class." Since then, I think I've begun to find a good balance with it. Many things I create are still classes and objects, because it just makes organizational sense in the right places, but I have gone back to a more "functional" form with other things. Usually, I find, that once I've started writing some convoluted inheritance nonsense to solve a problem, I have to take a beat and ask myself if this problem is best solved with OOP. Lots of times OOP really is the best option, but plenty of times, it's really is not.
It is not the topic but a few about premake: it looks like comfortable but it can't link static libs((( I tried it to build SFML-project with static libraries, and it returned me mistakes with wrong runtime between project and libs, while CMake linked this project successfully, and I couldn't find the solution (but the dynamic libs were linked and worked). Premake needs revision
How did you miss the fact that he calculates t0 and t1 in sphereIntersection and then never uses them at all? float t0 = ... float t1 = ... return true; He could have just calculated the discriminant of the quadratic equation and returned whether it was >= 0.
Well, I am a systems engineer so I really do have the worst code full of typos and no comments and duplicates and unused variables or obsolete functions... Unnecessary design patterns and non useful logs. I have them all. 😅
That was fun. I agree that that was not too bad. I have seen some HORRIBLE code!! I have asp code that I have to work with from time to time that is absolutely terrible!!!
The code is too boring to bother with. I wrote more complex programs on a TRS-80 with 4 KiB RAM in 1977, within days of using BASIC for the first time, when I was fifteen years old.
I appreciate that you don't get hung up on minor style things and focus on functionality. It's something that always bothers me way too much and I'm trying to stop 😂
THANK YOU. I had to scroll this far down the comment section to see that I was not the only one that noticed that. How could everyone miss it?!? This is the biggest flaw of all, IMO. People obsessed with y = y + 1 and then not noticing this unnecessary computation with unused variables. He would need these to determine the closest point of intersection if this was an actual ray tracer.
Technically they never really did create a temporary, even though they should have. But using the pre-increment/decrement operators is always preferable just to ensure that you're not relying on the optimiser to do its job. (And also you don't have to switch operators when using a more complex type where construction/destruction might have side effects that break optimisation.)
ammm quick question, i leaned (or am learning) how to code when i got 18 -19 before that it was just maths and science. now those who had done coding since they were without beards. and i had seen this pattern that after 2 decades since they started everyone becomes a greek dev (now i am 21 and hasn't beeen that much in this ape territory. i did know a bunch of languages but nothing to the degree to call myself a good one (i don't personally think i am a good programmer, other apes differ) anyway so well now i ma think of finally getting on and creating a project (give me tips like how do i actually start it- i might think of this feature and that , no i want to know how its done thanks) edit : > gawd dammmmmit, since when did youtube start to support markdown
How many times did you spot the cat? 🧐
Also you can try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/TheCherno . You’ll also get 20% off an annual premium subscription!
wasn’t ready for class Cat : public Animal 🤣🤣
Wait, she had other cameos, besides the "class Cat : public Animal" one at 6:50? 😳
kitty spotted at 22:36!
Is this... a competition?
It is now 😂
You have not seen what I have seen.
Such things have been done. For one example look up "harder drives".
@@steffenbendel6031 you have not seen what I have written
"We have such sights to show you" - Hellriser, Cube firmware division.
another reason for the struct. Fetching data only once and stuffing as much as you can into a single cache line.
"I like that it's not forced into OOP design for the sake of it" 20 minutes later "If I did it myself I would make it all OOP" Old habits die hard.
Or best practices die hard.
I think it depends oop is very efficient for writing applications with different components and reusing them. But you don't want to overdo it, always prefer composition instead of inheritance and try to have your classes as immuatable as possible and limits to the maximum modification of objects outside of their own classes : object should handle themselves. Mixing with functionnal is also a good idea because of immuatability. Making module for utility makes sense it avoid the verbosity of oop. And honestly it also depends on what langage you use, certains are better in other aspects than other
The moment I saw the code, I immediately thought: Class, RAII, Destructor. Which is what he ended up doing.
I won't pretend I'm a c++ expert. But I tend to use simple functions which mostly gather information for initializing objects.
I did some c code in the past, and once I fully embraced OOP in c++, I never looked back. How miserable things were. OOP and RAII. I love it.
But I don't work for a large programming company. It's mostly solo stuff. So I might lack exposure to other code. Why I like watching his videos.
7:00 Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function. - John Carmack
But method is a function right?
@@AdityaSharma-zn7hj A method is a function attached to an object. All methods are functions, but not vice versa.
@@thenonsequitur thanks
In c++ it's "member function", c++ doesn't have "methods", but everyone knows what it means.. just being pedantic for no reason
@@n00blamer I didn't know that about C++, but C++ is an oddball in that respect. They are called "methods" in most OOP languages.
Honestly very good code for what it does. Bad code is unnecessarily complicated code, with useless abstractions, obscure one liners and single character variable names
Well there were some of the latter. ^^
@irrelevant_noob true 😅 but it's found very commonly in this scenario
Maybe challenge that guy and send my code ?🤔
Well. I probobly can make it worse......
@@matsv201 You have to do it unintentionally otherwise it's no fun
@w花b well. Im a really bad programer. So that is really not an issue
I have some really horrific code, but it's in JS.
😂
There's a distinct lack of const in this code
Well i dont use const too, i dont know why people use it can you explain
@@Cinarbayramictheres the idea of const as a promise. Essentially any time you create a function you const all inputs that you won't change. This means you can more easily understand how functions may impact data just by looking at the function def as const inputs won't change.
@@Cinarbayramicthere are many benefits of using constants in c++. You should google it and read up on them.
@@Cinarbayramici also found const to be completely useless concept that mostly obfuscates the code. I know what people say about const but i have never had any bug due to modifying something I shouldn't modify.
@@nan0s500 It happens fairly rarely for your own code it's mostly for others using your code like on a team or in a library
Maybe the code you said worst code made by 10 years old kid. When I was a kid, I made a ray tracing, and when I look back to the code when I'm an adult, I don't judge the code, I'm, just proud of my childhood.
About to send him the sidescrolling action-platformer I made when I was a teenager and didn't know what classes, interfaces, or lists were.
The entire game takes place in a single update function with several hundred nested if statements. Every item and enemy is its own set of variables.
It's made in Macromedia Flash MX. AlexIsCool321, you think bad code is your ally? I was born in it, *molded* by it.
I remember I did the same type of stuff with minecraft plugins when I was first learning, before java I only did batch and scratch, where in scratch that's kind of how I did everything, as scratch has no objects and I never really knew how to use lists appropriately. I was effectively doing everything with just variables and functions until I learned to use lists to make cooldowns, and then later learned how to properly use classes.
I’m getting a feeling that Cherno is self reporting with this one. This is 100% the first raytracer he made on an old usb stick he found while cleaning the garage.
Impossible. The worst code is always the code I wrote yesterday, followed closely by the code I wrote a year ago.
Writing C++ with a functional style can be magical, too. I think as Cherno pointed out in previous videos, sometimes makese sense to have functions over classes
aka procedural
I understand what you mean but "functional" typically doesn't mean "mostly uses free functions". Instead it means code that uses higher-order functions.
@failgun higher order, yes. And an OOP minded might fall into the trap of using invariance, objects, and state. When instead a function doing a simple data transformation is all that is required
@@thewhitefalcon8539 they're not the same.
procedural programming is a paradigm in which you structure your code as a series of control flow steps that operate on variables and bundle common step sequences into procedures (functions).
functional programming is a paradigm in which you structure your code as compositions of functions. There's no control flow or variables -- you typically don't use any kinds of loops in FP, but instead write your programs recursively or as combinations of higher order functions like map, filter, fold, zip and join among others.
@@thewhitefalcon8539 unless you're using Pascal
t0 and t1 are never actually used !
yea xd as the code is one can just return discriminant >= 0; but probably the author left it unfinished and t0/t1 were meant to be used
@@twujstary1129 yeah those are usually intersection points, when ray intersects sphere there can be 0, 1 or 2.
Code quality is very scale dependent. At a small enough scale, no code that works can really be "bad".
On higher scale, any code that works, isn't definitely bad.
bro i watched your gaming programming video 12 years ago... glad to see you're still going strong!
"class Cat : public Animal" 🤣
Hello, Cherno. Could you please make videos about modern CPP features such as modules, constinit, reflection (?), std::println(), views, etc...
just watch the jason turner cpp weekly daily vids
Const correctness is another thing that was missing completely. const float a, const float b etc. It does make a difference for the compiler and makes a huge difference when reading code, since you directly know what values cannot change in the function after being initialized.
One thing that is bothering me, and (I think) hasn't been mentioned, is how in SphereIntersect t0 and t1 are calculated for every pixel even though they are declared only in the scope of the function and not returned. So for every frame we have two operations with square roots which are fairly expensive performance-wise. In a regular raytracer we'd still calculate t0 and t1 for good reasons (which are mentioned in this video), but in this specific case there's no reason to.
"I didn't identify my member functions". Hungarian notation, one of the most pointless programming styles ever invented, particularly for strongly typed languages and especially C++ which allows you to create your variables where they are used. Plus it's 2024, every bit of information encoded into your complicated and confusing prefix is available from the IDE.
I did a game last year with a friend using SFML, a function has 56 arguments. Most functions have over 6 arguments. We were trying to finish everything fast. Help.
That transition to the sponsor was very smooth
lol, I've been trying to teach myself C++/C#, on and off, for about 30 years. I'm sure I've written the worst code you've ever seen hundreds of times. Thanks for the channel.
I am sort of glad I was able to come up with a similar solution to improve his code, I was definitely coding like this a few years ago, global variables, singletons everywhere...
The math code is bad because all it is is written out vector dot products that should be extracted into a method in Vector3
Also gripe about "code quality": It's very much scale dependent, and also dependent on the skills of the maintainers.
Like the primary metric of code quality would be how quickly can you add a feature without any side effects, or how quickly you can onboard a new dev to make said changes.
When you have a sub 1k line code base, almost nothing can be considered "bad".
I have a few ~6k line files and those I would call bad code as it's the entire program in a single file and it starts to take a considerable amount of time just jumping around looking for specific things that you forgot the exact names of. You could make it "good code" by just splitting it up into different folders and files to compartmentalize what all of the different features/functions do, but that takes effort and I just never care enough to do it as I don't spend much time changing things these days.
The functions are doing the work, not the classes. The classes are organizing the code and making it more readable. Classes are not needed, but they can help. Classes can also get in the way of what you want to do.
Deconstructing classes (moving functions out of classes) should be more commonplace.
Phew, thought he'd got some of my code at first ...
I actually used the same GetDC trick for an image cat tool to view images in cmd. I no longer use it because I use the new windows terminal and it didn't work there.
I never knew you could do this, sounds fun
@@user-sl6gn1ss8p I kinda wish that the new pseudoconsole subsystem would not eat arbitrary escape codes, so I could install a terminal that supports sixel, iterm2 or the kitty image protocol or some cool graphics like tektronix or regis. In linux you can just invent an escape code and implement support for it in a thirdparty terminal. You want audio escape codes, sure?, You want escape codes for app specific drag n drop, why not? you want escape code for tooltips/multiple fonts/popups/vsync/custom chraracters and icpns/...? I would have many bad ideas...
@@theevilcottonball Yeah, it feels like that's what they should be for
I have never seen someone refer to dx, dy, and dz as direction... usually it's delta, though I guess direction is technically correct.
It seems like the best way to go is to start with just functions, then group them in classes as they make sense to you and which show to be useful. Another premature optimization improvement
If that's the worst code you've ever seen, then my code would literally melt you into your chair.
The worst code I've ever seen was some React and NodeJS code at a previous employer. It was the worst example of over-engineering ever. Everything was so overly complex and difficult to do. Just changing a simple text label was complicated. I even argued with the tech lead about it more than once. I guess he thought the more complicated he made things , the smarter he felt as a developer. I think also it was his way of securing his job. By making the code super complicated, no one really understood it except him. But the code was very buggy, as you would expect, and just painful to work with. I eventually left after a few months.
y = y + 1 was crazy.
Not if you are as old as I am and learned the fundamentals of programming on a Sinclair Spectrum.
16:06 I am not a programmer. Is there a reason that he writes b^2 as b*b? Is it a 'better' way to hand exponents? more performant? Easier to read? Easier to troubleshoot?
^ is not used for exponents. It is the bitwise exclusive or operator.
Any code you write becomes the worst code ever written when you come back tonit later
These review vids are great! Thx for taking the time and effort to share them! 😀
yeah he's amazing at stretching 100loc into a 25min video
I agree that OO shouldn't be the only solution but rather a tool in the box, but in the case of a game or game engine, I feel like an object that separates out the functional bits of the program makes sense, especially when you consider that it makes it easier to run more than one at a time with ease. As for implementations of mathematical algorithms, I'd like to see some of the individual steps broken out into full-fledged functions marked as constexpr. However, I do agree on using a three piece vector to represent the data.
This has so much instant fired energy in it you gotta love it. How common is it these days for people to do `using namespace Everything`?
Regarding classes in C++: almost the entire STL is built of them, so I guess people in the standardization committee know what they are doing as well as STL implementers.
I just wanna say, I've been learning C++ more productively. Watching these videos are seriously amazing, especially the tutorials. I don't wanna sound like those idiotic bot comments, but seriously, thank you.
It's funny how you've done like 20 of these code reviews or whatever but you never seem to get much past their entrypoints lol... why not do a code review of AlmondCore?
6:08 I felt this :D
I'm a university student and I started learning code from C. Then I studied OOP and now I literally cannot think about code without classes and objects. I am now learning C++ and I have some problems in using other paradigms (maybe because even outside of coding, my mind often structure concepts in a OOP way, don't know if it makes sense).
Does someone have any tips or resources (preferably videos) to learn other ways to code, especially in C++?
My nightmare is seeing a code review video about my code.
Oh, I could send the worst calculator ever that I wrote. I'd probably win this competition for the worst code
my minesweeper implementation would win that competition
how I can run metrix calculations on gpu ?
he couldve also just implemented a vector multiplication function that takes to vectors to offload part of the math going on here. and if your really bothered with performance make it constexpr, static inline, or even a define do while 0 construct...
one thing i dont think you did pick on is that the person has done all that math to calculate the points of intersection and then not do anything with them?!
Looks like a hacker rank challenge
C can use classes...
just put function pointers in the struct and pass the struct with a pointer named this :P
Function pointers in a struct for no reason are bad for performance.
Just use plain functions that take a pointer to the instance struct.
@@simonmaracine4721+1
classes aren't just function pointer containers. they have headers, vtable for inheritance...
@@doodocina u can kinda implement VTables in C, but i agree it's a pain. If you are going to do reimplement OOP, just use C++
@@doodocinainheritance is not a fundamental part of object oriented programming, it is an addition
So C is an OOP language
please make video like OOP vs Data oriented in c++
hey i have question, do you check other languages than c++? like c, rust, java etc
It is zoomit
I was pretty sure my code made it out in the wild when I read the title
@6:50 I only learned OOP about 3.500000001 years ago, but once I finally wrapped my head around it, I went absolutely balls-to-the-wall with it, and yeah, for at least 2 of those years: "everything had to be a class."
Since then, I think I've begun to find a good balance with it. Many things I create are still classes and objects, because it just makes organizational sense in the right places, but I have gone back to a more "functional" form with other things. Usually, I find, that once I've started writing some convoluted inheritance nonsense to solve a problem, I have to take a beat and ask myself if this problem is best solved with OOP. Lots of times OOP really is the best option, but plenty of times, it's really is not.
The worst code he's seen? He apparently never heard of Yanderedev before.
Pre-Increment vs. Post-Increment Operators in For loops preference??
It is not the topic but a few about premake:
it looks like comfortable but it can't link static libs((( I tried it to build SFML-project with static libraries, and it returned me mistakes with wrong runtime between project and libs, while CMake linked this project successfully, and I couldn't find the solution (but the dynamic libs were linked and worked). Premake needs revision
If that's the worst code you've ever seen. You haven't looked hard enough
Can someone remind me of the name of the application he's using for drawing stuff/taking notes on the screen?
6:50 оливка jumpscare
0:09 This would've been the funniest segue into a sponsorship from that anti-balding company that everyone was sponsored by a while ago
You mean Keeps?
@CoolModderJaydonX Yeah that was it
Not the worst C++ code i have seen by any stretch, i see my own code daily
Actually it would be an interesting video, at least for me, to see on how to make this multiplatform
16:16 he doesn't use intersection points anywhere else
when everything is a class, its awesome. love classes
hahaha - he clearly hasn't seen my code yet
How do you navigate so quickly?!
No where close to the worst code I have ever seen. I've written worse code than that. Granted, it was almost 50 years ago when I was in high school.
quite interesting video, liked it
16:05 You underestimate the failure of the American education system
How did you miss the fact that he calculates t0 and t1 in sphereIntersection and then never uses them at all?
float t0 = ...
float t1 = ...
return true;
He could have just calculated the discriminant of the quadratic equation and returned whether it was >= 0.
Where is the RayTracing series... :c
What happened to the raytracing tutorial series? D:
Putting the opening brace on the same line and then a completely blank line after it is so cringe.
somehow thought he looked at my code, or this is a sign from youtube
isn't dx dy and dz a derivative?
12:05 y = y + 1 is wild... Time to do y -= -1 for my next project.
y = y % 2 ? (y + 2) & -2 : y | 1;
Well, I am a systems engineer so I really do have the worst code full of typos and no comments and duplicates and unused variables or obsolete functions... Unnecessary design patterns and non useful logs.
I have them all. 😅
Imagine thinking this is the worst code you've ever seen. My code is at least 1 billion times worse than this.
End(); // "I don't think this even gets called 🙂🙂🙂🙂🙂
I give him credit... he does have a hell of a good sense of humor!!!
That was fun. I agree that that was not too bad. I have seen some HORRIBLE code!! I have asp code that I have to work with from time to time that is absolutely terrible!!!
At least he made something, better than me 😅
Worst code you've ever seen? Hold my 🍺 😅
Did you really not notice that this person is using a *console window* for *graphics output*, as a cheap way to not have to make an actual window?!
he did notice. It's just not _that_ bad
Finally I can tell my maths teacher i used the discriminate in real life 🎉
Does anyone the theme cherno is using?
The code is too boring to bother with. I wrote more complex programs on a TRS-80 with 4 KiB RAM in 1977, within days of using BASIC for the first time, when I was fifteen years old.
I appreciate that you don't get hung up on minor style things and focus on functionality. It's something that always bothers me way too much and I'm trying to stop 😂
Not the worst code ever. Not enough code to even qualify for the worst code.
All the worst code I have seen is proprietary. X_X
Not working on windows 11 :/
I don't know if its the worst code you've ever seen and I'm not about to stick around for 20 mins to find out, I prefer less bait titles
Thanks for letting us know
Is anyone going to mention the fact this that isn't ray tracing?????????? this is just normal rendering......
it is ray tracing. It traces rays to render the image. Normal rendering would be rasterizing triangles.
He did not get the point, that there is not point calculating intersection points, if you do not use the points.
THANK YOU. I had to scroll this far down the comment section to see that I was not the only one that noticed that. How could everyone miss it?!? This is the biggest flaw of all, IMO. People obsessed with y = y + 1 and then not noticing this unnecessary computation with unused variables. He would need these to determine the closest point of intersection if this was an actual ray tracer.
Please continue the ray tracing series
y++?!?!?! Wait, your telling me that modern compilers don't waste temporary doing that anymore and I can stop writing ++y? :)
Technically they never really did create a temporary, even though they should have. But using the pre-increment/decrement operators is always preferable just to ensure that you're not relying on the optimiser to do its job. (And also you don't have to switch operators when using a more complex type where construction/destruction might have side effects that break optimisation.)
It is not as bad if you compare it with source code of Unity or any google project.
can you not tell that he pushed up the code to github just for you to see , git commit messages and timestamps are irrelevant.
The reason to define variables outside of main is to have effectively immutable global state.
ammm quick question, i leaned (or am learning) how to code when i got 18 -19 before that it was just maths and science. now those who had done coding since they were without beards. and i had seen this pattern that after 2 decades since they started everyone becomes a greek dev (now i am 21 and hasn't beeen that much in this ape territory. i did know a bunch of languages but nothing to the degree to call myself a good one (i don't personally think i am a good programmer, other apes differ) anyway so well now i ma think of finally getting on and creating a project (give me tips like how do i actually start it- i might think of this feature and that , no i want to know how its done thanks)
edit :
> gawd dammmmmit, since when did youtube start to support markdown
*since* _forever,_ as far as I know. But it's a very limited markdown.
Is it possible to send you some code for auditing?? )))
No matter how bad your code is, mine's worse 😅