Jonathan Blow on Stack Tracing and Errors

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
right Etc and so I want to start working in that direction but this stack Trace thing was was one step in that direction I forget how we even got on this topic um but well we were we were talking about how the error message handling is recording things like file in line information and stuff like that and you were saying you go a step further and you hand that to the meta code and this is an example of where you would care about the fact that you could get it in the meta code as opposed to only in error reporting yes and so so the the further thing that I would say about that is the the reason why this makes sense and this was a good piece of the puzzle to like work on and fit in is uh you know if you're an experienced programmer in C or C++ or many other modern compiled languages well let's just say there's several there's several times when there's like a safe Comfort comfortable Zone that you like to be in and then like a toxic waste Zone that you don't want to be in right and for example a lot of this has to do with this is not my main point but a lot of this has to do with code reuse like right like if you're in your own code and you know how things work and you know none of it is like stupid or the parts that are stupid are temporary then it feels very good and you can get a lot of work done right but as soon as you start trying to use someone's API that you don't totally know how it works and it's not well documented and whatever it could take forever to get anything done right so you cross this line where things are suddenly like toxic right and you would prefer to stay inside the line where things are not toxic and the most productive programmers that I know usually stay inside the line as much as they can both for productivity reasons but also just happiness reasons like quality of life reasons right I think you probably agree with that those people probably at least speaking for myself and also other folks that I see like you said you try very hard part of your programming that you're actually doing is working to widen where those lines are like you're actually actively trying to create those lines as you go because if you don't do that then you are essentially you know creating a very small area you can work in so you're constantly going like yes how do I how do I create a wider swath that I can work in here by building out more reliable pieces I can stand upon and so on if that makes sense yep but anyway and so so another example that's uh similar but a little bit different because you maybe don't have a choice is let's say you call some operating system call or whatever we've all gotten you know crash in ntdll right and you're like what the hell is this how do I debug this or maybe you call some operating system API call that you don't have any other way to do this task on this operating system and it returns you know error bad parameter value right and there's like 17 parameters and they all look fine right and and maybe the actual bad value is like a member of a data structure that's one of those parameters right and that's a giant pain in the a to debug it sucks right um there are many many instances of that they're just toxic waste areas that kill productivity and so what I have observed is another one of those areas is basically any time you have to interact with the operating system in terms of tooling what people call tooling so like getting your program to build right or or um SDK Where is the files yeah or or getting it to link properly or like y just you know oh this library that I built was compiled in debug and I'm trying to link it against something in release so I need all these combinatorics or now oh that that that was in 20 Visual Studio 2017 build but the 2019 can't build that exactly what I was about to say is now Microsoft has totally ruined it used to be not that big of a problem you used to just have debug release problems but now yeah you can't link across Visual Studio versions so absolutely not you're you're basically hosed anytime you want to link now and and then let's talk about shipping something on Linux versus Nintendo switch versus Windows versus MAC right it's like versus Raspberry Pi like it's just a complete disaster right whereas if you stay inside the language semantics well again C++ is ruining this because the language semantics themselves are completely for most langages if language semantics and actually what they are can be very and then it's just oh I started a new machine and visual studio wouldn't load the project file that's 5,000 lines of XML for some reason and my pre-compiled headers are not working right for some like whatever that's what destroys your productivity can we pause for one second please cuz I just want to point this out because what you just said happens literally all the time like I can't even tell you how many like open source projects or whatever I have like tried to like GitHub and build but they needed to have their project files imported by visual studio and that just completely failed yeah so the only reason the only reason why you would ever contemplate doing something like storing something in XML is because it was supposed to be a format that you could have flexibly added something to and not change there's no other reason to do it right there's literally no other reason for a textual arbitrary markup language for saving your build configuration well there is a reason that we'll get to you in a second but yes I agree with you so they did the thing that costs you everything you had to write the parser you had to have it be slow and big and whatever the heck else all of this stuff happened and then they still break it every single time yep so what were you what was the point of that like well there's no adult supervision right there's nobody there's nobody who's saying are we getting the benefit of the thing that we did right there was some meeting 10 years ago when when somebody said we're going to do this format because it'll give us this benefit but then there's no adult in the room making sure that you get that benefit and so we just get more and more complexity now the actual reason to put it in XML is actually because people are afraid of doing anything now because they're afraid to thing lying around and they were just like that's how you store things like if you go to some like somebody will come on my chat somebody right now will say but if you write the parser yourself it might have bugs in it whereas you know the XML works or whatever and it's like a no that's not at all true because XML is way more complicated right yeah um and B XML is so General that you kind of have to do your own format reading and like you don't know exactly what format the sub trees are in and whatever and you have to write all that stuff anyway and often often it's more involved than what you would have written to begin with right so um yeah it's it's just very strange you see all these decisions I mean I guess they're not really decisions as part of it but you see all these things where you're like you literally got nothing out of all of these things like it's like that it doesn't these things just don't make sense together but yeah anyway so anyway so so another way that I say this with regard to a general programming language is look the job of a programming language is to specify what happens that is literally what it is like this when you run this program the semantics of of the whatever the side effects whatever the output is of the machine code instructions that are eventually run by the computer should be determined by the input text right that is the job of the programming language and the compiler so why are we saying that somehow that specification doesn't cover what actually the program is right so in C we have all these compilation units but C itself doesn't tell you what the program is right it's just like well we somebody else puts together all these compilation units and that might have seemed fine in the 1970s it's very obviously a mistake now because the place where all these problems come in is the parts that c doesn't do it doesn't say that A.C and B.C are part of the same program so you need all this other stuff and that other stuff is what fails and causes all the problems so like why did we do that well oops you know and and so people start doing things like we're just going to include our A.C and B.C into a giant file so that we don't have that problem right yeah it ends up being it that ends up being the only way you can actually make a sane build is by doing exactly effectively what you're doing in ji just with extremely weak tools we need to be able to build in the actual language and the only way you can do it is with pound include right there's just simply no other support yes so that's what you do because that actually works and is defined in the language so you know that it will always do the same thing totally anyway so that's where this stack Trace thing came in it was look this is a thing you want to know sometimes um especially so if you even if you're using a debugger right one common thing that will happen especially in a game or anything with long live data um you'll make some data structure and then later you'll do some operation on it and the operation realizes that the data structure is not exactly formed correctly and maybe there are many sites that could have made the data structure or you know modified it so that it was correct and now is incorrect and you want to know right and tracing those could be annoying so for example if I'm a compiler and I want to put a breakpoint um I want to know like well let's let's not say a compiler because in compilers we have this file in line info that you can use to do breakpoints but you know if it's a game or something and I'm like well you know somehow you know this this entity ended up on a non- integer coordinate and it shouldn't be because it's not a decorative entity but literally there's lots of code that modifies coordinates so like what the hell right and um one way to do that is just when you modify the data structure just grab a stack trace and stick it on there right and then when you hit the actual breakpoint later in the debugger you can look at that field of that data structure and be like oh okay here's what it was and that's something that could take you a long and agonizing time to actually do when you're stepping through something but if you store it when the modification happens and then just look at it later in the debugger it could be very fast and being able to do that in a language independent or in a in an operating system independent way has already been very beneficial like I just did it on a stream the other day and I found the problem in like 10 seconds you know absolutely because at that point you basically have the power of you know a a really really really good uh tracing debugger which typically you have to use an incredibly like esoteric like you have to use wind dbg with a bunch of really cumbersome commands to get yes but now you can just it doesn't matter doesn't matter what the debugger is right like any debugger can just be used now and get all of that power which is pretty pretty great right now you can do the operating system dependent version of this which we have we have a library somewhere that did this which is you know do whatever you need to do on your operating system to generate a stack Trace right but the problem with that is then you know the output is going to be different and how much can you depend on it does it depend on whether your program was compiled with debugging symbols in or not or like whether somebody stripped them or uh you know what's how do how are names mangled right and uh you know things don't work that you can do with this so because this is completely defined by the programming language semantics because again the job of the language is to specify what happens right I can write some code that gets a stack trace and some other code that looks through that stack trace and says anywhere in here is there a call to make sandwich right yeah and I don't have to look for the string make sandwich I could even compare maybe there's three overloads of make sandwich and I want to know is it the specific one right or whatever I can just do that that's actually something that's not guaranteed to happen because um you know when there's overloads and functions with optional arguments and stuff in in a link file you might have multiple entry points for the same function depending like that's all up to the compiler and you don't freaking know so you might take the pointer that the stack Trace gives you but that might be big different than the one that you get if you refer to the pointer from your language right but all that ambiguity goes away you could even match by string and you know that the string is the same every time and I can do that right now and it'll work on Linux and windows and Raspberry Pi and whatever and that is very far from something that you would even try to do probably like I wouldn't try to do that with like a stack Trace operating system some level debug Library like that's just not well the other thing too about it is that once it's integrated into the language properly and you're not talking about something that is fundamentally going to be sort of a separate thing you have to build every time uh and that's external and specific it's just like look what else do I want to do with this once I know I can get a stack trace it makes it easier for me to write a built-in profiler it makes me easy it makes it easier for me to do stuff like if I want to do a log file that gets written to disk that sometimes I send you know when people are doing you know customer support and once you have that standardization where you just know that you can do this thing then you can build everything else on top of it and it's not this weird like oh but don't forget to install the blah blah blah lib for your operating system and like oops which version is that and all this other stuff you know whatever version of the compiler you have it has this thing in it so you're going to just get that and it's going to work and that enables like a lot of other KnockOn effects at that point yep um I don't know if you're getting tired I could still go for a bit um we could do more Casey questions or we could do general questions it's entirely up to you uh if we're just on compilers then like I said I think we had most of the questions that I had because I was curious about the parsing side of things um but I didn't have a lot of other questions because I think I'm more familiar I guess with the other stuff you've been doing so I didn't have as many things that I was wondering about but you know that particular part maybe you live streamed some of the parsing at some point but I didn't see it so you know well let's do a thing let me get up and take a two-minute break because I just finished my third IC tea and that has consequences consequences um okay uh so how about if we have people in the chat can ask whatever questions they have and you could pick one or two as a question curator and then we can do those all right well we we need to take uh uh well you know what two things first yes I need to take a break as well then just so I can grab maybe some some more uh water here but then I'm going to open up hex chats because all the questions are going to scroll by and I'm not going to see any of them so I need something that actually has you know a scroll back buffer like you said twitch chat may take a tremendous amount of memory but it doesn't actually store anything yes go ahead and put Q colon in front of questions you want to ask so we can see them more quickly and we'll go from there yeah well I can't see those more quickly but I guess Casey can okay okay so we're taking legit two-minute break for both of us you all can be thinking about your questions during that and then when we come back Casey will be the question curator
Info
Channel: Jonathan Blow Highlights
Views: 22,453
Rating: undefined out of 5
Keywords:
Id: _EpHbwd_Jh8
Channel Id: undefined
Length: 16min 9sec (969 seconds)
Published: Tue Mar 26 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.