Why Refactor? Let’s Refactor the 3D Polygon Renderer. [c++20]

  Рет қаралды 42,837

Bisqwit

Bisqwit

Күн бұрын

Пікірлер: 214
@Bisqwit
@Bisqwit 4 жыл бұрын
As always, the source code is available here: iki.fi/bisqwit/jkp/polytut/ *A reminder: Do not reply to **_this post_** if you want me to see your comment. Post your words as a new comment, not as a reply, unless you are addressing the contents of **_this comment_** specifically. KZbin does not show creators new replies, it only shows new comments. If you reply here **_I will not see it_** unless I manually check for it.* If you are addressing a comment someone wrote, then you _should_ reply it, though.
@XArticSpartanX
@XArticSpartanX 4 жыл бұрын
Any reason you're not using github to also host your files? Either way your work is impressive and I appreciate it
@Bisqwit
@Bisqwit 4 жыл бұрын
My own server, the one linked in the comment yo replied to, is literally at my reach here at home. Putting stuff at a remote server is always some more work. I have used Github for many of my previous projects, but it is extra effort and requires more maintenance compared to just copying files over from a path to another path. Even if you argue it’s just a "git push", you also need to set it up, do README.mds and so on. More work. Also for a series under progress like this one I can limit which/when files are going to be visible to the audience. In Github everything that is pushed there is downloadable.
@Bisqwit
@Bisqwit 4 жыл бұрын
First
@deepudinesh2720
@deepudinesh2720 4 жыл бұрын
Bisquit after commenting first: "They called me a madman"
@deepudinesh2720
@deepudinesh2720 4 жыл бұрын
Would appreciate if you could make a video on PBR rendering or something of the sort, I've been using unity for a while and I'm interested in the behind the scenes working of it.
@ircitonod3674
@ircitonod3674 4 жыл бұрын
hey, that's not fair mr bisqwit
@bahathir_
@bahathir_ 4 жыл бұрын
I am suprised! You started with "Selamat pagi" :) Next, try Japanese.. Ohayou Gozaimas.
@madridx2010
@madridx2010 4 жыл бұрын
Second!
@bemo6434
@bemo6434 11 ай бұрын
This is my second favorite KZbin video of all time! Really inspiring stuff! 👍
@audiencebigg6302
@audiencebigg6302 4 жыл бұрын
it's really nice that you've explained about readability and maintainability of the codes, separate them into multiple header files, *and* using less dependencies while ensuring that it can be platform independent
@tsonez
@tsonez 4 жыл бұрын
Not sure if it was mentioned in the video but the book “Refactoring: Improving the Design of Existing Code” has a solid definition of refactoring - what it is, why it’s beneficial and what’s good design as the aim of refactoring. Another important (and perhaps more approachable) book is “The Pragmatic Programmer” (20th Anniversary Edition) which also handles refactoring as part of more general discussion on design and programming as a craft. Both books are highly recommended.
@duuqnd
@duuqnd 4 жыл бұрын
Eventually you won't have technical debt, but rather debtnical tech.
@izaac229
@izaac229 4 жыл бұрын
This is like a sort of crash course into Computer Graphics. Thank you so very much for the videos!
@ClaymorePT
@ClaymorePT 4 жыл бұрын
The only time that manager understands what Tech Debt is, is when they hire someone and that someone quits after spending one week looking at the codebase. When that happens, it's too late and the product fails.
@crafoo
@crafoo 4 жыл бұрын
The problem is software engineering is not a real engineering field, at least outside of aerospace. Engineering has well-tested methods for managing projects and addressing known issues. The issue with software is estimating real costs and schedules, and inexperienced managers/MBAs with expectations detached from reality.
@ClaymorePT
@ClaymorePT 4 жыл бұрын
@@crafoo That's not true. The problem with the field is that there's lots of programmers who do not take responsibility for the problems created by the software they design and implement. You have tons of software development fields which apply strong mathematical skills, from architecture going trough language design. That is why you can also study computer science. Because it is a science field on it's own.
@KuraIthys
@KuraIthys 4 жыл бұрын
@@ClaymorePT It's worse than that. There are some 'experts' deliberately creating a mess so that nobody else will understand it as some twisted form of ensuring job security. Priorities are messed up.
@monad_tcp
@monad_tcp 3 жыл бұрын
​@@crafoo "The issue with software is estimating real costs and schedules" You can't estimate what you never done before. And if you are using software to automate things properly, you are never doing things exactly the same ever again, because software can be infinitely replicated just by copying the executable. So, basically, each and every software product is more of a handcraft than anything engineered. Its more closer to writing a book than to an actual engineering field. And the schedule and cost is not even the real issue. The real issue is having predictable results, i.e., the software will work for the intended purpose and attain whatever is that you wanted from it. Computing is much more of a science than anything else, every software you write is an experiment, which is why you never, ever define the schedule or the cost, you only say what you are interested in investing, like X per month, and then we can see how far that will get you (you can pretty much see the progress as we use iterative methods [aka, "agile"], so you can see if you need to kill the project, invest more or go another direction, or think that's enough and just deploy and use what you got). Yes, its that risky, almost 80% of the software projects will fail. (while on civil engineering that's more like "only" 40%, if I'm not mistaken). Want something that you have a real cost and a schedule, buy a software that already exists, leave the creation of newer software for those who are adventurous venture capitalists that can afford to lose. The real issue is that MBAs/managers think they can manage a software development shop like a factory where you input coffee and out comes code, but that's not how it works. Its not a issue with software, its a issue with business management practices that don't work for creating software and were created for factories. In a car factory you are going to make that specific model of car 1000000 times. While software is more like designing an entire new car engine, frame, everything from scratch, every time, and then you hit a magical button and get a "print" of 1000000 cars, that button is called "compile", software is 99.99% design and 0.01% production (which is actually made by the machines themselves while the people drink their coffees). And yes, even with reusable parts (OO mostly largely failed at it), its hard to reuse a part of something in something else on software, software is much more complex, this is were the analogy breaks, you try to reuse a banana, but then you get the entire gorilla and the forest as a dependency, reuse never worked that well. The last job I quit, I left nine copies of the Mythical Man Month book, because I though with 9 copies they would read it much faster, 9 times faster (I wish they got the joke, which they will after they read the book).
@metallitech
@metallitech 4 жыл бұрын
Modern C++ template programming is hideous and hard IMO. Hats off to you.
@saultube44
@saultube44 4 жыл бұрын
Why? Have you done any efforts to influence the makers of this template to improve it? or you just limit yourself to complain?
@eagle2com
@eagle2com 4 жыл бұрын
@@saultube44 What. I think google translate has failed you.
@Maraus92
@Maraus92 4 жыл бұрын
@@eagle2com As much as I want to think that templates are a good idea, I just can wrap myself to like them. You can solve problems much better and more readable with other tools. Or I might be wrong and templates are a good solution.
@Caellyan
@Caellyan 4 жыл бұрын
@@Maraus92 Any type-safe language requires something like them. The alternative is storing type information with the objects, which doesn't work as well with native languages and makes all objects consume more memory without giving any choice to the programmer. They allow code to stay nice and compact. Besides, most of the template code gets optimized away anyway. Also, Lothbrok*
@aevus
@aevus 4 жыл бұрын
@@Caellyan thats not the point. The idea of template metaprograming is good, but the execution in c++ is just bad.
@ooze9808
@ooze9808 4 жыл бұрын
Nothing else on the internet releases as much dopamine as a new bisqwit video notification.
@petrosiuksline7013
@petrosiuksline7013 4 жыл бұрын
Doing work < refactoring the code I swear I refactor it more that I code up new one...
@iam-smza
@iam-smza 4 жыл бұрын
I am watching the video alone at 4 in the morning, and that demon voice at 4:06 scared the shit out of me.
@saultube44
@saultube44 4 жыл бұрын
LOL. He re is a great demon to help you code kzbin.info/www/bejne/hae4e6aratxrf7c
@igor-the-software-engineer
@igor-the-software-engineer 4 жыл бұрын
I'm a simple man: I see Bisqwit's video -- I press "like".
@travbrack
@travbrack 4 жыл бұрын
Thanks to Bisqwit, I'll always wonder if my coach driver is secretly a software engineering genius.
@bahathir_
@bahathir_ 4 жыл бұрын
Selamat pagi, Tuan. Good morning, Sir.
@shmuel-k
@shmuel-k 4 жыл бұрын
Thanks for extracting the hard-coded stuff into descriptive variables! I think this is the first time I (somewhat) successfully read your code!
@miguellama7618
@miguellama7618 4 жыл бұрын
After a year of learning c++ at university I can finally understand your code :)
@laharl2k
@laharl2k 4 жыл бұрын
But can you write it?
@haky2173
@haky2173 4 жыл бұрын
"In that sit st ss the lt s tht thss tht si" 12:42
@More_Row
@More_Row 4 жыл бұрын
Marek Hák ?
@SimGunther
@SimGunther 4 жыл бұрын
@@More_Row auto text replacement placeholders for the bot to change over time
@KuraIthys
@KuraIthys 4 жыл бұрын
It's funny. Everything you're doing right now is by and large the opposite of what I aim for when writing this kind of code. You've made the functionality increasingly generic and capable of more and more things in a small number of functions, where generally I would aim to break up anything complex into smaller and smaller chunks that do the simplest possible things that it's reasonable to do. Compare and contrast: Function that can render arbitrary convex polygons. vs. Function that splits an arbitrary convex polygon into triangles. Function that splits a triangle into flat top and flat bottom sections. Function that can draw flat top or flat bottom polygons. Ultimately I suppose this comes down to intention. I learnt coding in an era and context where performance was at such a premium (and compilers were not always that great) that you do anything you can to ensure that the code is fast, and this includes things which force more assumptions onto the programmer. If a particular vertex ordering improves performance, the code would demand the use of that format, and so on. To a certain extent this is a tradeoff, but again, it depends on your goals. 'clean' code is often written under the assumption that performance is free, or that computer performance improves quickly enough that you can justify the slower but more elegant code because it'll be fine in future, over the messier but faster code. Sometimes you can get both, but at some point, frequently you have to pick one. And you might say writing 'correct' code is better, but with that attitude we never would have had realtime 3d in the 90's... And you could also ask yourself why something like Microsoft office now uses 1000 times as much memory to do mostly the same tasks it used to do with considerably less memory... Part of it is just because absent those harsh hardware constraints, people are free to do bad things (from a performance perspective) if it makes the code easier to understand, faster to write, or so on... Optimisation is a tricky subject though. There are many ways to approach optimisation, and it's usually not wise to optimise too soon. (though of course, creating things which make optimisation more difficult is not helpful if you know performance is going to be a major consideration in the future.) One of the obvious problems with optimising too early is that you may waste a lot of time using really aggressive optimisation on stuff that doesn't need it because it hardly ever runs...
@theairaccumulator7144
@theairaccumulator7144 3 жыл бұрын
Your way of writing code is correct. Tbh almost everything after c++ 11 is worthless and serves as syntactic sugar that just makes code more inefficient and harder to read and mentain. Compare structs to tuples/named tuples for example.
@wijaksanapanji
@wijaksanapanji 4 жыл бұрын
The intro surprised me 😂
@accountNo0
@accountNo0 4 жыл бұрын
Much love for this series
@ioanniskoutsouris9944
@ioanniskoutsouris9944 4 жыл бұрын
Awesome content as usual 👏 Would be very insightful to share how you think of design patterns before/during developing a project
@undefined_cat
@undefined_cat 4 жыл бұрын
When I watch your videos I feel so dump xD
@ll_sch1zophr3ni4_ii9
@ll_sch1zophr3ni4_ii9 4 жыл бұрын
You need my bbc mati mati
@saultube44
@saultube44 4 жыл бұрын
You mean dumb, but that is good, a humble position is the right position to learn from a Master/Expert, a Master Programmer in this case, it's a good feeling, it should also makes you realize that you're in front of a wealth of knowledge and that you can learn a lot, so rewatch and read books, digital or physical, read a lot
@PeranMe
@PeranMe 4 жыл бұрын
Great stuff, looking forward to upcoming videos!
@telnobynoyator_6183
@telnobynoyator_6183 4 жыл бұрын
When I realized how important refactoring is, my (programming) life was changed forever !
@NonTwinBrothers
@NonTwinBrothers 10 ай бұрын
13:33 so glad mobile youtube allows pinch zooming now 👍
@tomkaiserfoto91
@tomkaiserfoto91 4 жыл бұрын
Thank you for your thoughts, Bisqwit! I love seeing (and hearing) you explain these projects. I would be interested in your opinion - do you feel it's important to read a lot of code before attempting to write your own? Have you read any modern C++ code recently that you liked the style of? How did you get your coding style?
@Bisqwit
@Bisqwit 4 жыл бұрын
I think it’s important to read a lot of code _in general._ I attribute it to a significant portion of my prowess. In the recent years though I have not done much reading. Pretty much the only pieces of modern C++, that I have read in the recent years that weren’t written by myself or that weren’t part of libstdc++, have been the sources of github.com/nlohmann/json and github.com/fmtlib/fmt .
@tomkaiserfoto91
@tomkaiserfoto91 4 жыл бұрын
@@Bisqwit That's some very good advice! I myself have not nearly done as much reading as I have writing code, and it shows in every project that I attempt. I'm starting a new project on image manipulation now, and I'll be sure to read a lot of code before writing the first line! Thanks!
@dariusduesentrieb
@dariusduesentrieb 4 жыл бұрын
I don't understand why there is still no simple mechanism for compile-time for loops (that provides an index that can be used for tuple access)
@metallitech
@metallitech 4 жыл бұрын
I think it's because compile-time doesn't have variables, and recursion is used instead.
@edino1981
@edino1981 4 жыл бұрын
There is for ...
@Darksoulmaster
@Darksoulmaster 4 жыл бұрын
Yay new video!
@positive_energy3131
@positive_energy3131 4 жыл бұрын
Thanks for saying "selamat pagi"
@roku1892
@roku1892 3 жыл бұрын
i am a NodeJS web programmer, when i see this, i started math for programmers
@davidmahbubi
@davidmahbubi 4 жыл бұрын
Selamat pagi juga, Mr. Bisqwit
@4yearsago
@4yearsago 2 жыл бұрын
Hi I'm your Indonesian fans "selamat pagi " You're great Bisqwit
@JamesHoughton
@JamesHoughton 4 жыл бұрын
I haven't noticed this in other videos, but the code edits in this video seem a little strange to me. For example, at 1:22, you write ditiional_t and I was very confused. Has something changed?
@Bisqwit
@Bisqwit 4 жыл бұрын
I am using a different input generator than before. It supports things the old input generator didn’t support, such as block indenting and rectangle-copies, but as it uses an algorithm that seeks to find a way to enter/modify lines with least number of inputs, sometimes it produces rather counter-intuitive results, and sometimes (nearly always) due to runtime constraints it gives up before finding the obvious solution. It works by treating the editor state as a graph and uses Dijkstra’s algorithm to test different inputs until it ends up with the desired target state, choosing the path with smallest penalty.
@JamesHoughton
@JamesHoughton 4 жыл бұрын
​@@Bisqwit Perhaps there's a way to bias towards more human-like solutions. Are cursor movements counted as inputs? Maybe they should have less weight. Weight could be added for other paths too, like ones that add to the middle of words for example. Just some ideas :)
@Bisqwit
@Bisqwit 4 жыл бұрын
Besides arrow keys it also uses home and end keys, and keys which move forwards and backwards by one word. These are considered cheap inputs because they are just single buttons. Successive arrow movements are considered more expensive.
@SpartanOdyssey
@SpartanOdyssey 4 жыл бұрын
​@@Bisqwit This makes so much sense. I was wondering what was going on after seeing the input generator write "he he he he he" at 12:30 only to then see the editor fill in the rest of the comment like magic. I think this behavior is actually really cool even if it isn't necessarily human-like.
@whythosenames
@whythosenames 4 жыл бұрын
6:30 In your explaination the blue numbers start from 0 and the green ones from 1
@Bisqwit
@Bisqwit 4 жыл бұрын
So it seems
@vapourmile
@vapourmile 4 жыл бұрын
I find refactoring is part of development. I develop and refactor. It isn't always truly possible to tell at the start of development where something will go, how it will be used, or how best to implement whatever it is you're trying to do. You tend to learn by doing. Every once in a while you can realise it would be better to change how it's written to make it more flexible or satisfy an unforeseen use case. It's also popular refactoring doesn't always make things better as such. It's possible to have several different versions of something better suited to various different tasks.
@telnobynoyator_6183
@telnobynoyator_6183 4 жыл бұрын
What text editor is that ? Looks a bit like vim...
@Bisqwit
@Bisqwit 4 жыл бұрын
Answered (almost indirectly) in: kzbin.info/www/bejne/kH6lgqCehJ1-p6s ˢʰᵒʳᵗˡʸ ᵗʰᵒᵘᵍʰ ⁻ ᴶᵒᵉ
@sankrantchaubey6731
@sankrantchaubey6731 4 жыл бұрын
Shalom! This series is awesome. Thank you so much Bisqwit! I would like to learn more about software rendering. Do you recommend any books for the topic?
@Bisqwit
@Bisqwit 4 жыл бұрын
I’m not a book person so I don’t really know. I have got just one graphics book that I bought years ago upon someone else’s recommendation. www.pbrt.org/ Should read it some day.
@treyquattro
@treyquattro 3 жыл бұрын
congrats on jumping into C++20 with concepts & templated lambdas (and a bunch of other stuff probably). What compiler are you using? I believe you're on Debian, and as everyone knows, Debian is many releases behind of the kernel, toolchains, etc. I tried to build Clang 11/12 but Debian Buster is too far behind with gcc or clang to build new projects (especially if they use filesystem)
@Bisqwit
@Bisqwit 3 жыл бұрын
I use Debian _Testing branch,_ which updates at a much faster cycle than the official releases.
@treyquattro
@treyquattro 3 жыл бұрын
@@Bisqwit thanks. That was the obvious guess :-)
@Milkybean
@Milkybean 4 жыл бұрын
I watch these videos so I can refresh how it felt to be in mathematics course in university
@manojshindetalks4365
@manojshindetalks4365 4 жыл бұрын
I am a big admirer of your programming work and skills. Not seen anyone like you. Please if possible answer the questions. 1. Why any of your videos do not talk about Visual C++, Borland Delphi or Any visual development tool? Is it by choice or any reason 2. Do you have a strong mathematical background? I see you are using it frequently with super ease. 3. I also do not see you talking about low level Android programming (not talking about regular apps). Please let me know. Really curious to know how you decide what to use and not use for development.
@Bisqwit
@Bisqwit 4 жыл бұрын
1. Visual C++ and Borland Delphi are both software that are entangled with products of Microsoft Corporation, particularly their operating system. I am not a customer of that company. As for UI development in general, not really something I am very familiar with it. 2. I used to be quite interested about math _in the elementary school._ My father taught me long multiplication years before I even went to school, and in school I liked to study things that were way beyond what the classes covered. Eventually that changed though. By the time I was in the vocational school, I only studied what I needed to study. Even today I only look up what I need, although I do spend much of my free time learning about stuff. What I do in my videos gives somewhat a biased view. I only talk about and do things that I know, and even much of that is specifically researched for that video or video series. If I don’t speak about something, it’s often because I don’t know about it. 3. I haven’t done any Android programming.
@manojshindetalks4365
@manojshindetalks4365 4 жыл бұрын
@@Bisqwit Thanks for the detailed answers. I have been programming mostly in visual basic, c# and delphi. I do it for living but I was always interested in doing system and graphics programming since DOS days.. I am 43 now. I learned advanced c and some assembly coding but I could never do something worthwhile in it. I hope to learn from your videos but somewhat difficult to understand as I do not know a lot of stuff the way you do. Learning is the only way ahead. 👍
@voxbine4005
@voxbine4005 4 жыл бұрын
For videogames like quake phisics and half life1 enviroment, wich laguaje programing will you choose?
@Bisqwit
@Bisqwit 4 жыл бұрын
In general, the best programming language is that which you know well. And for me, that is C++ for compiled code and PHP for interpreted code. For engine development you’ll want a language that can be compiled into highly efficient code. C, C++, Rust, Go, Haskell are among these languages. For non performance critical code, such as UI, any language will do including interpreted ones such as Python and lua.
@baltazarus3307
@baltazarus3307 4 жыл бұрын
Zdravo, Bisqwit! *Hello, Bisqwit!
@90hijacked
@90hijacked 4 жыл бұрын
20:20 wait, are you saying SDL applications can run under fbdev, without X11?
@Bisqwit
@Bisqwit 4 жыл бұрын
Yup
@90hijacked
@90hijacked 4 жыл бұрын
@@Bisqwit I've so far had no luck running either DF or CDDA using their SDL backends without launching X11, assumed it was impossible could just be the way they're implementing it, or maybe im missing something.. either way its def something to look into, thanks!
@Bisqwit
@Bisqwit 4 жыл бұрын
Maybe you need to enable it explicitly when compiling LibSDL itself.
@90hijacked
@90hijacked 4 жыл бұрын
@@Bisqwit I'll be giving it a try over the next couple days, any and all advice is much appreciated, I'm not a C++ programmer per say
@Svipers
@Svipers 4 жыл бұрын
Why dont use a ide??
@NonTwinBrothers
@NonTwinBrothers 2 жыл бұрын
6:22 Huh, I *REALLY* don't remember this part of the video
@udayanjoshi2691
@udayanjoshi2691 4 жыл бұрын
Is this even cpp? This doesn't even remotely resemble what I learned in college.
@saturdaysequalsyouth
@saturdaysequalsyouth 4 жыл бұрын
C++ has gone through a lot of changes.
@Bisqwit
@Bisqwit 4 жыл бұрын
Many schools only teach C++ like it was still 1997, when C++ still kind of sucked.
@udayanjoshi2691
@udayanjoshi2691 4 жыл бұрын
@@Bisqwit yeah. I basically program with c style in cpp. How does one even learn this?
@indrit66
@indrit66 4 жыл бұрын
@@udayanjoshi2691 by being a nerd bro he probably put thousands of hours in programming and being smart helps too look at hes geeky personality tho i think he dosent care about girls either so only programming
@quantummechanist1
@quantummechanist1 4 жыл бұрын
@Bisqwit how do you deal with a corporate programming job where management does not believe in refactoring? I'm looking to refactor my job since I'm not allowed to refactor code (it's a Finnish company to book)...
@SimGunther
@SimGunther 4 жыл бұрын
If an emotional appeal doesn't work, just think about working some place that'll allow refactoring in the first place. Not sure how great a code that company has in the first place if refactoring and basic code ethics/practices aren't allowed to flourish in the first place.
@tsonez
@tsonez 4 жыл бұрын
Not Bisqwit, but “The Pragmatic Programmer” has the suggestion try explain the need to the client/management in a plain simple way. Like, the code has a disease (design issue) that spreads unless operated (refactored). Or the code is an overgrown garden which needs cleaning and pruning. Or it’s perhaps a messy restaurant kitchen where it’s hard to get work done efficiently with required hygiene (quality)... Hope this helps.
@abab-ge2tu
@abab-ge2tu 3 жыл бұрын
Is it recommended to always keep output from logic by separate functions?
@Bisqwit
@Bisqwit 3 жыл бұрын
No guideline is absolute, but in general it is smart to keep user I/O and program logic separate, so that you are free to change either without affecting the other. Identify architectural components of your program and keep them separate, connected with as thin paths as possible.
@ne0komodo
@ne0komodo 4 жыл бұрын
Selamat pagi, semoga semuanya baik-baik saja 🌞 .
@cmdlp4178
@cmdlp4178 4 жыл бұрын
The View::Draw function is erroneous, because it captures variables by reference. Outside of the function those referenced local variables (here: the function parameters) are already out of scope, so the references are dangeling. You could be lucky if everything works as intended, but that is UB. You could use a [=] capture instead.
@Bisqwit
@Bisqwit 4 жыл бұрын
Considering that the only thing it captures by reference _is_ already a reference, I leave it up to you to prove to me with a testcase that the code commits a UB.
@cmdlp4178
@cmdlp4178 4 жыл бұрын
@@Bisqwit I looked into a draft of the standard (github.com/cplusplus/draft/blob/master/papers/n4835.pdf) and, you are right (On page 102 part 13): [QUOTE] An id-expression within the compound-statement of a lambda-expression that is an odr-use of a reference captured by reference refers to the entity to which the captured reference is bound and not to the captured reference. [/QUOTE] I personally think that something like return [&]... is a direct code smell and I often am explicit about "references" and use pointers instead, but only when lambdas are returned from a function.
@Bisqwit
@Bisqwit 4 жыл бұрын
It essentially returns to the caller the same reference that they themselves provided, and thus, falls to the same category as this code: const std::string& testfunc(const std::string& str) { return str; } This code is perfectly safe if used like this: std::string str(5, 'a'); auto& ref = testfunc(str); However, it is _not_ safe to be used like this: auto& ref = testfunc(std::string(5, 'a')); But it _is_ safe to use like this: std::cout
@BadPotat0
@BadPotat0 4 жыл бұрын
@Bisqwit What's about adding units tests? When refactoring, in particular, unit testing shouldn't be left unheard of. I known you aim to provide a one-screen format for your videos and the size of function is constraint by this goal, but I still believe there could be a workaround with this issue. What's great with unit testing is it help to document your code "as code" as well. If you do some refactor you can make sure to valid if behavior is the same as before and help to stay sane. You could even use TDD to think about your code will do beforehand. This can help to better structure your code. Now you may say it's a bit early to talk about unit testing as we can just manually test the result when running the program, but if you intend to revisit this project later your future self will thank you even if it require additional maintenance to keep the tests up-to-date and anyone trying to read your code will get a better hint about what's going on. Sometime to provide inspiration, you can be required to make a big project, if so, then you may need a solid base and that's where unit test come handy.
@Bisqwit
@Bisqwit 4 жыл бұрын
Yes, unit testing is another topic. I may attempt to cover it some day, perhaps.
@eyemotif
@eyemotif 4 жыл бұрын
do you think prototyping and then refactoring is more efficient or easier than trying to make everything as generic as possible the first time?
@Bisqwit
@Bisqwit 4 жыл бұрын
The more experience you gain, the less chance there is that the shortcomings of your design become _immediately_ apparent, but it all depends really on case. There is no generally applicable answer to your question.
@jasonyesmarc309
@jasonyesmarc309 4 жыл бұрын
In my experience, trying to make everything as generic as possible the first time can make you spend a lot of time rewriting large chunks of code as you discover better solutions in the middle of your work period. Most bugs and logic problems aren't easily predicted. I've found it's better to prototype first, because you will write your code toward where your solution really is, rather than toward where you predict your solution to be. Once you know exactly what the working best solution is, you can generalize it with a solid foundation in mind for the program's function. If you write generically out of the gate, it's only practical if you've already figured out what your full code will be beforehand, at which point you're hundreds of leagues above me and my advice would no longer have value. I try to sit somewhere in between. I'll prototype, but the moment I notice I'm writing the same code twice, I refactor that part to be less redundant and more generic, and continue prototyping.
@wargacosmos2812
@wargacosmos2812 4 жыл бұрын
ahhaha Selamat Pagi Too,, Salam dari Jakarta Mr. Joel Yliluoma
@MrM4dness
@MrM4dness 4 жыл бұрын
Selamat pagi, Pak!
@benjaminbrady2385
@benjaminbrady2385 4 жыл бұрын
So what editor do you use when programming yourself?
@Bisqwit
@Bisqwit 4 жыл бұрын
kzbin.info/www/bejne/kH6lgqCehJ1-p6s
@dertechl6628
@dertechl6628 4 жыл бұрын
It's obviously THAT editor.
@cortexauth4094
@cortexauth4094 4 жыл бұрын
I am thinking to work on a game engine (2D first), I was planning to do it on C because I just want to get better using it, and I wanna use up optimizations messing with assembly instructions. But I have also learned modern C++ recently and I can go with it too. I am so confused!
@laharl2k
@laharl2k 4 жыл бұрын
remember you first design it, then you code it. you go from the end product, back each step looking at what you need for the next step. Game > background and sprites > how do i draw background > primitives > etc. If you are gonna do it in C/C++ i can recommend SDL2 and try making (if you like sonic) a simple program that loads the tiles, draws a map, and lets you move a sprite on it, the rest depends on how motivated you are.
@cortexauth4094
@cortexauth4094 4 жыл бұрын
@@laharl2k is it bad idea to use opengl?
@cortexauth4094
@cortexauth4094 4 жыл бұрын
@@laharl2k I have done that in SDL! That tile and sprite thing. What I am more interested in is making transitions, and queues (on how layers deep you are in, like opening inventory then details, fading and being able to go back). I referred to someone's code on some ideas related to a game, but it was still bit tricky. I need to try again
@cortexauth4094
@cortexauth4094 4 жыл бұрын
Those "professional" effects were all in a C game, I saw and read the code, but I was puzzled because of terminology, and formalism, Like, code was so structured, I started feeling dumb and could not think of contexts and queues same way. Maybe I need to actually try and do it bit by bit
@laharl2k
@laharl2k 4 жыл бұрын
@@cortexauth4094 opengl is a bit more complicated i myself dont have experience with it but id say start with the basics and then "enhance it" With SDL you work with your standard ram, but to use openGL and all the hardware acceleration you need to upload your content to the video ram (afaik) which changes the way you do the graphics entirely. (also why doing images in software is so much slower. all the data transfer to and from the video memory kills your fps, you can see that enabling and disabling hardware acceleration in sdl)
@monad_tcp
@monad_tcp 3 жыл бұрын
4:20 No #pragma include in C++20 ? why ?
@Bisqwit
@Bisqwit 3 жыл бұрын
I think you mean #pragma once. For a discussion about its standards compliance and caveats (which may be why it is not a part of the standard) see en.wikipedia.org/wiki/Pragma_once
@ABaumstumpf
@ABaumstumpf 4 жыл бұрын
I HATE Refactoring with a passion - because we never get the time for it, constantly have to refactor and recode cause the requirements change MONTHS after they have been signed, often after development finished, and even for future projects we get told "nah, we want it quick and dirty now and not make the life easier for everybody later on". And yes, just last we we got such a reply - not word for word but in that sentiment. It was about an extra simulation-software that was supposed to simulate some subsystems and hardware-processes that our software is interacting with (Were we have 4 different systems that interact with those subsystems independently or through each other). The initial simulator was written by a programmer in his spare time to safe him countless hours when developing, testing and debugging as the only ways possible to do that at this point are still some very crude command-line tools, writting to a socket by hand, or even just creating xml-files by hand...... So the simulator of course is not designed to handle larger systems, it of course is not easily integrated, it of course is a pain to setup (still easier than doing ti by hand), bad performance and all that. But the higherups don't care as "it works". Heck, just doing some basic system setup to test the already existing state often takes each developer several days, testing a single scenario that after release would be done in a couple of seconds in the real environment with physical processes takes a couple of minutes by hand. I had to write 2 new tools and change quite a few other components just to get anywhere close to the system-loads that the software is expected constantly when released as the existing tool, via commandline, were too slow to actually do that. Yes - using bash/python/whatever with the existing tools was over 2 orders of magnitude too slow for simulating the normal case. Each event sent via commandline has a ~150ms delay before getting registered and conversion to the actual signals takes another 20ms (yes, that slow) but just the one part i had developed was supposed to handle over 4 events a seconds, being just one out of over 20 Processes that work together in a hard-realtime situation.......... TL:DR: Refactoring - really important, hardly anybody that does not work with the code will give it any resources and make it worse for everybody.
@Bisqwit
@Bisqwit 4 жыл бұрын
It sounds like you don’t hate refactoring, but you hate not being permitted to do it.
@ianpan0102
@ianpan0102 4 жыл бұрын
I really like the font used in the terminal (an old-school feel), anyone knows what it's called?
@Bisqwit
@Bisqwit 4 жыл бұрын
Which one of them? I change the font like 46 times in the video.
@ianpan0102
@ianpan0102 4 жыл бұрын
@@Bisqwit Hi Joel! I'm most interested in the first one you used. Let's say, the one at 1:00. I think it really resembles IBM VGA8. However, IBM VGA8 has a dotted zero, and yours has a slash.
@Bisqwit
@Bisqwit 4 жыл бұрын
The fonts used by _That Terminal,_ which is the terminal in which I used the editor, are listed here: github.com/bisqwit/that_terminal/blob/master/doc/fonts.md
@ianpan0102
@ianpan0102 4 жыл бұрын
@@Bisqwit Thanx I'll check it out
@ianpan0102
@ianpan0102 4 жыл бұрын
@@Bisqwit Found it, it's the EGA font (similar to VGA, but with a slashed zero).
@spiralingspiral72
@spiralingspiral72 4 жыл бұрын
Magandang umaga po... Good morning, sir...
@igor-the-software-engineer
@igor-the-software-engineer 4 жыл бұрын
Btw, Bisqwit, what do you think about path tracing?
@chiptuneanimation4492
@chiptuneanimation4492 4 жыл бұрын
Bisqwit, are you going to do beginner friendly tutorials in the future? I, and I am sure many others barely understand what is going on in your videos, although it is just amazing to see.
@Bisqwit
@Bisqwit 4 жыл бұрын
In general I try to make layered tutorials that have something for every level. Obviously not all of it will be useful for beginners, and some of it will be boring for experts. However, you should be able to get _something_ from it. For example, with this video, the general principles: Reduce dependencies, don’t have too big files, have each distinct topic together and different topics in different sections. Or the anecdote that in professional world there is rarely time to dedicate time for refactoring, so you should pay attention to it continually.
@nero008
@nero008 4 жыл бұрын
I was looking around for anyone writing code from scratch without using standard libraries, but I couldn't find any ? Why isn't it a widespread practice to write your own I/O library or own gui library ? I know that logistically speaking it's programming suicide but being ignorant about how things actually work in the non-abstract low level domain is not fulfilling to me. What should I do ?
@gayusschwulius8490
@gayusschwulius8490 4 жыл бұрын
Separating C++ and the STL is generally a bad idea because they're build to be complementary to each other. If you make your own libraries, your code will be extremely platform dependent, because every OS has a slightly different way of handling I/O, threads, windows etc. STL generalizes that task and allows you to compile your code for pretty much any OS in existence. The standard functions are also more efficient than anything you could ever write and it's therefore a good practice to use them instead of inefficient custom functions if you can. If you really want to learn how to do this very low level stuff on your own, your best bet would be to look up an Assembler tutorial to do it, then integrating that into your C++ program using an _asm{} block.
@perplexedmurfy9262
@perplexedmurfy9262 4 жыл бұрын
Nero Das, You should introduce yourself to Handmade Hero where the sole programmer live streams himself working towards shipping a game that doesn't rely on external dependencies, all while explaining what he's doing and why he chooses to do it. The archived livestreams should be on here under "Handmade Hero"s youtube channel.
@Bisqwit
@Bisqwit 4 жыл бұрын
“Write your own I/O library or own gui library” is rabbit hole with no end in sight, because of the reasons I mentioned in the video at 20:26.
@JoneKone
@JoneKone 4 жыл бұрын
Fantastic :)
@JosefdeJoanelli
@JosefdeJoanelli 4 жыл бұрын
The clock in the top is running in real time, but his typing is impossibly fast, how is this happening?
@JosefdeJoanelli
@JosefdeJoanelli 4 жыл бұрын
Haha literally the next minute he explains it 😁😁
@hyperbole5726
@hyperbole5726 4 жыл бұрын
Where can I learn about all this template programming? I'm comfortable with almost any other C++ paradigm including simple templates, but this seems crazy. Also is it even worth considering practically all computation will be done with 32/64-bit int/float anyway?
@Bisqwit
@Bisqwit 4 жыл бұрын
All that the template stuff does is that it lets you use the same algorithm regardless of the presentation of your data. It’s a thing that makes programming easier in presence of constantly changing requirements (such as when doing a video tutorial series). Later on (two episodes from now), it will also help using the same algorithm for different purposes, such as scene rendering and lightmap rendering, where the latter is done by first using lightmap coordinates instead of world coordinates and then doing several _recursive_ renderings for each luxel. It means I won’t have to write separate rendering routines for these different purposes. Like I said, it’s like pulling strings from afar. It is _not_ a thing that is done for efficiency. Rather, it is a technique that helps you gain reusability of code _without_ sacrificing efficiency.
@samzx81
@samzx81 4 жыл бұрын
Nice video :)
@saultube44
@saultube44 4 жыл бұрын
Fascinating, thank you. What do you think of Intermediate Languages (IL), like Java and C#? I personally think they're a stone in the shoe, and we can do way better with automated compilation and Assembly-Level Efficiency (ALE) to run code ASAP in all platforms; 1 good example of this, is Qt.io Have you met Bjarne Stroustrup?
@Bisqwit
@Bisqwit 4 жыл бұрын
Java is like “yo dude, I heard OOP is the next great thing, so I put OOP in your OOP soup and covered it in OOP”. It takes from C++ only the things that are bad and runs with it. C# is like “yo dude, Microsoft here. We heard Java is great, but it’s not invented at Microsoft, so we made our own”. Although to be fair I heard C# is somewhat better than Java, but personally I have had no interest in either. I have not met Stroustrup.
@kahnfatman
@kahnfatman 3 жыл бұрын
It takes a lot of courage to piss off both halves of the colosseum in the flame war between Java and C#. :D Hat off to you -- Jedi Master @Bisqwit, as always.
@kahnfatman
@kahnfatman 3 жыл бұрын
@@Bisqwit It takes a lot of courage to piss off both halves of the colosseum in the flame war between Java and C#. :D Hat off to you -- Jedi Master Bisqwit, as always.
@carbon13
@carbon13 4 жыл бұрын
People complain about how bloated the template programming side of C++ has become, but to be fair it allows you to accomplish amazing things at compile time that would be impossible or ambiguous without it.
@laharl2k
@laharl2k 4 жыл бұрын
It would be cool if C++ had all the ready to use high level libraries python has so you could seamlessly mix high level and low level code without having to cobble together python into your c++ code. Some stuff is easier to do in low level and some other stuff is easier to do in high level where speed isnt that important.
@zatherz2498
@zatherz2498 4 жыл бұрын
nobody in the history of the world has ever said compiletime execution is bad, it's just that the C++ implementation of it is beyond disgusting
@motsgar
@motsgar 4 жыл бұрын
This is the reason i am often stuck for weeks because i want to create my new feature so that i can actually use it without any weird hacks and so i can add to it later
@notlegal99
@notlegal99 4 жыл бұрын
your accent sound smart. i like it
@TheMariday
@TheMariday 4 жыл бұрын
I've just noticed something after watching a few of Bisqwit's videos... I always assumed the coding is sped up but the timestamp at the top of the screen is real time. So my question is how the hell does anyone program this fast‽‽‽
@Bisqwit
@Bisqwit 4 жыл бұрын
Answered in: kzbin.info/www/bejne/fZ-umWt7l5ati5om33s
@eemelilehtonen8628
@eemelilehtonen8628 4 жыл бұрын
I have no idea why that (sizeof...(args)) destroys my head
@eemelilehtonen8628
@eemelilehtonen8628 4 жыл бұрын
Found it> "en.cppreference.com/w/cpp/language/sizeof..."
@Bisqwit
@Bisqwit 4 жыл бұрын
For whoever is reading that, the URL should contain _three_ trailing periods. Fix it manually if it does not.
@simetri5459
@simetri5459 3 жыл бұрын
Selamat pagi joe a.k.a bisqwit
@marcoaurelio9527
@marcoaurelio9527 4 жыл бұрын
incrivel!
@antonsurviyanto5896
@antonsurviyanto5896 4 жыл бұрын
selamat pagi pak..
@KishoreG2396
@KishoreG2396 4 жыл бұрын
I chuckled when I first clicked on this video, since I saw it had exactly 256 views, which overflows the value for an 8-bit unsigned binary number. 😊
@huyvole9724
@huyvole9724 4 жыл бұрын
Advance C++ make me headache
@roku1892
@roku1892 3 жыл бұрын
omg he speak my country language 😳
@ceciphar
@ceciphar 4 жыл бұрын
Just realized that KZbin stopped showing your videos in my subscription box
@Bisqwit
@Bisqwit 4 жыл бұрын
Oh :-( Even on this page? kzbin.infosubscriptions?disable_polymer=1 The next will be published this Friday, so check if it happens again.
@Bisqwit
@Bisqwit 4 жыл бұрын
So, did it work?
@ceciphar
@ceciphar 4 жыл бұрын
@@Bisqwit nothing. Been on all week. Edit: with the link I was able to see it.
@KrrSplat
@KrrSplat 4 жыл бұрын
Why not just have DrawPolygon break the polygon into triangles and then pass the triangles to DrawTriangle???
@Bisqwit
@Bisqwit 4 жыл бұрын
That’s actually what I did before. That’s the Tesselate thing that I mentioned. It was covered in the previous episode. But it does involve some redundant calculations. For example, for a quadrilateral, you end up with two triangles that share an edge. The same edge will have to be computed and interpolated twice.
@official-obama
@official-obama Жыл бұрын
12:31 we he hed he h). "se he
@SoftBreadSoft
@SoftBreadSoft 4 жыл бұрын
I'm always making messes. Always refactoring the next day.
@SomeRandomPiggo
@SomeRandomPiggo 4 жыл бұрын
Here at 50 views!
@voxbine4005
@voxbine4005 4 жыл бұрын
I dont know if you speak spanish but i will try speak english.. Where you study to do all of this programing content, i like programing but i cant underestand all of it its bery dificult and confusing to me underestand this.... But i love it and i know if i study all of this i will able to know how this work, i went to a programing school but i just learn about python and the profesors before i enter to the school they promised me learn about c# c++ and some java. After that i move to another scool but without programing... Sorry for my english....
@Bisqwit
@Bisqwit 4 жыл бұрын
You did the correct choice: I don’t speak Spanish. Where I learned “all of this” is irrelevant. The correct question is “when”, and the answer is “25 years of professional experience”. The world was a different place when I began (in 1992). Even the Internet did not exist (in practicality). The tools, operating systems, and hardware were different. Each person has a different story.
@voxbine4005
@voxbine4005 4 жыл бұрын
@@Bisqwit that's right i think experience is a little bit more important than just learn but its important learn too so. Thanks :D now i will go to some website to practise with some .bat cmd console and have more information and experience in my brain :D but python is not a languaje that i want to learn well is not for videogames i guess...
@madridx2010
@madridx2010 4 жыл бұрын
Could a Noob programmer like me get a heart from a god programmer like you ?
@floatingpointerror55
@floatingpointerror55 4 жыл бұрын
Take a shot every time he says "function" 17:35
@GianGiovanii
@GianGiovanii 4 жыл бұрын
Selamat pagi
@elmonni2103
@elmonni2103 4 жыл бұрын
SHALOM is this siipasplas?
@Bisqwit
@Bisqwit 4 жыл бұрын
You tell me
@kuro68000
@kuro68000 4 жыл бұрын
Your code illustrates a problem that other languages have solved and that is one of the main reasons why it's getting less and less popular. The syntax is complex and esoteric and doesn't make for readable code. It's very far from self documenting.
@chappie3642
@chappie3642 4 жыл бұрын
The point of code is not to be easy. C++ won't die because it's currently the highest level language that allows you to keep the performance you could get from assembly as long as you know well how the language works.
@dariusduesentrieb
@dariusduesentrieb 4 жыл бұрын
The syntax for complex stuff is complex. You can translate Java/C# code into C++ and it will look mostly the same (except for memory management, which is not really about the clarity of the syntax). But if you'd try to translate a heavy generalized C++ function with tuples and auto and templates everywhere you would need a lot more code with Java if it is even possible at all.
@metallitech
@metallitech 4 жыл бұрын
​@@chappie3642I doubt that the performance is like assembly. The modern template programming avoids run-time polymorphism, but I would have thought it's always possible to write a faster program in assembly.
@fredg8328
@fredg8328 4 жыл бұрын
What ? A "two dimensional" cross product ? Heretic ! :D
@Karreth
@Karreth 4 жыл бұрын
dot product ≠ cross product (except for scalars).
@mokamoka7586
@mokamoka7586 4 жыл бұрын
oh , modern c++ again :/ , keep your code readable and simple is much better than flexing your c++20 muscles back to c++03
@ll_sch1zophr3ni4_ii9
@ll_sch1zophr3ni4_ii9 4 жыл бұрын
E=mC2
@aatishsingh1183
@aatishsingh1183 4 жыл бұрын
Do you spend your whole time in programming? Do your mom and dad live with you? Do you have brother or any sibling? I don't know but i am very curious about you since i started watching you.my intentions aren't to hurt you but i want to know about these things
@Bisqwit
@Bisqwit 4 жыл бұрын
Programming is my what I spend most of my free time with, and given today’s worldwide situation it tends to be the only thing too. I like to keep my personal situations private, but I do live alone for more than 20 years already.
@dominuspiritus
@dominuspiritus 4 жыл бұрын
Omg. New video with good code and ugly font
@Sopel997
@Sopel997 4 жыл бұрын
The moral of the story is that tuples are not the right abstraction for everything. Sorry, but this is an unreadable mess stemming from overgeneralization. Polygon rasterization is not a common algorithm. It's used in domain specific contexts with already abstracted geometric primitives. It doesn't need to be so generic. I also don't like the overuse of auto - explicit typing has a merit, especially in public API.
@Bisqwit
@Bisqwit 4 жыл бұрын
While you are right that polygon rasterization is not a common algorithm, this tutorial series makes for an exception because I keep adding new features iteratively, and when I do that, I want to focus on the actual topic at hand _for presentation reasons_ and not have to rewrite half of my code every time I add a new feature. But you are entitled to your opinion of course.
@dariusduesentrieb
@dariusduesentrieb 4 жыл бұрын
Ahh reddit.
@Sopel997
@Sopel997 4 жыл бұрын
@@dariusduesentrieb ? yes, I posted it there too
@Sopel997
@Sopel997 4 жыл бұрын
@@Bisqwit Understandable. The only problem I have with that is that people may think this is actually what writing C++ looks like and should be. Objectively it's a good video, but the message may not be exactly right.
@metallitech
@metallitech 4 жыл бұрын
I agree about auto; I like to see types. I was thinking of writing a visual studio plugin-thingy that changes all the "auto" for the type.
Texture Mapping & Polygon Rasterizing Tutorial (1/2) [C++20]
22:46
Forbidden C++
33:07
javidx9
Рет қаралды 1 МЛН
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 24 М.
3D Rendering with Binary Space Partitions
6:39
Quothmar
Рет қаралды 125 М.
How I got Mario in That Editor - And how Norton Got 🐁
13:30
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
What are EXE files made of?
11:00
Bisqwit
Рет қаралды 146 М.
I wrote a Raytracer for DOS, 16 VGA colors
15:00
Bisqwit
Рет қаралды 897 М.
CppCon 2014: Mike Acton "Data-Oriented Design and C++"
1:27:46