Advice for Writing Small Programs in C

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
testing of staying you you you testing alright so is the stream up for anyone else I do not see the stream for me myself up there just white all right sorry about that crazy technical problems I have not had when I was doing a BBG so I don't know what was going wrong there at all right so about that guys uh folks so writing small programs in C so this is like I said an informal talk I wrote up some notes and then I made some slides but I did not get the slides entirely done in time so you'll have to bear with me as I make that up make that up and as I and I'm the whole talk is a little half-baked I'm not really sure what the point is but it was a topic that was interesting to people so it seemed worth doing so go ahead and get started here and because it's an informal talk if I'm talking about something and you have a question about it go ahead and ask put my name at the beginning you know do the at things or is it just the nothing someone in chat will say and I'll try to remember to look over and please restrict things with that prefix to questions about stuff that I'm talking in the chat I mean talking about in the talk not underly questions and not random commentary the random commentary in the stream in the chat self is fine alright um yeah exactly like that coming from John Nicholas so uh what uh what is the point of this all the the thing about this talk is that I use C as my primary programming programming language for everything not for writing games but for writing utilities for writing quick one-off things that stuff like that and people generally think that's a crazy thing to do so I've been programming a slide on this I've been programming for a long time I've been programming since um gosh of 1980 so I followed an arc with programming languages in 1980 I learned basic in 85 maybe I learned Pascal 87 learned to see I know learned six five or two assembly back early in the basic days and then I gradually acquired C++ knowledge and I wrote C++ programs professionally from 92 to mm and then I went back to see and during that time period we've seen um kind of an arc of how people solve small problems without using a programming language like C of even the early days there were UNIX pipes where you could just construct little programs by a sequence of programs communicating with each other if you needed something a little more programmatic you could write shell scripts and then we had Perl come along because shell scripts weren't very portable and so people could write scripts in this Perl language that we're way more portable than the scripting languages the the shell scripts because they didn't rely so much on external programs that you might not have it was all built into Perl and then in some sense Perl got starting people people start treating that as a real programming language and then we saw the growth of python ruby some other dynamic languages that people were much more likely to use if they just wanted to write a small program and uh meanwhile I stopped at C++ in you know 2000 I went back to see um and I think I'm a pretty productive programmer in general and I write lots of little programs very quickly uh in a way that people aren't familiar with and so something here is out of order I really need to skip ahead to this slide so the too long didn't listen here before I go way too deep into this stuff um the only things I can actually concretely point at that I can say in this talk but I'll go into more detail is the two things you need to do if you want to be successful at writing small programs in general is you have to spend your time writing code that gets stuff done and that you really need code reuse and this is particularly important C because the C standard library is terrible and you need basically a better replacement for the C standard library to really successful you see all right so let me go back now so I was talking about this arc Python and Ruby um what was my point about that so those languages of course are used for large projects as well small projects but there is certainly this let me let me just pull up an example oh no no no no no okay so here this is Brad Pitt's Patrick who is the guy who created live journal um and in 2008 he made this post where he was like you know I'm learning I'm using Python these days more than Perl and I'm not super familiar with Python he's saying so here's my Python program to solve this little problem and um you know I'm sure I'm not using the idiomatic Python ways to do it I bet it could be smaller if it were done in that way and so here's this little Python program and what this program does is it takes a user dict words or no actually takes a similar thing of senseless government lists of names so it takes a file in this case the list of names and finds entries in the file that are anagrams of each other and he wanted to solve this problem for a particular reason he wanted to come up with a list of names for twins or triplets that their names would all be intagram so he wrote this little program and as he says it's a terrible program or whatever but you know it produces the results and then he was like so he went and back and he wrote the Perl since he's more familiar with Perl read the Perl and the Perl is a little smaller and you know he kind of comments about how this uh uh wow it's shorter I've already lost my train of thought there anyway so um it so happens that at the time uh Brad Fitzpatrick and I followed each other mutually on LiveJournal so if you scroll down here what when was this 2008 so I created sth in 2006 and that's going to be relevant to the story uh and I'll come back to that a bit more and so here's you know people saying well here I'll do a TCL version is a better Python version etc and eventually you scroll down and you find where I do a si version here it is that's longer it's definitely a longer program um but it's not that much longer right it's uh doing a little more work um expressing things a little bit more concretely in the way that you tend to ensue it also doesn't really resemble C code at all because if you check almost every single line has an ST B underscore at the start of it um and so this is my solution to writing small programs in C is that I've replaced in some sense the C programming library the standard program library with this library that's a lot more useful and so when you know he didn't mean this as a challenge but once people sort of engage with is a challenge I looked at that I was like that's actually right in the wheelhouse of the sorts of things that I've built this library up to help me solve um so you know you need to sort something oh and I have a collection of little helper functions that they actually are better now but that so you don't have to go define because normally in C when you're using Q sort you always have to go define a little thing so I have a whole bunch of helper ones that cover a bunch of common cases it won't cover every case you have to do stuff and so I'll come back to what I actually do in FCB dot H in general but my point here is talking about the languages stuff I've my impression is that nobody looking at this problem than these pair of things would ever imagine that a C program could do this with the same level of concise and concision is important because it lets you program faster um you know it just takes you when you're writing something simple it takes you three times as long to write a three hundred line program as a one hundred line program and here it's a twenty line program where would all right so that's that um now before I figured this out I had a lot of experiences and the language relative relevant one is in 2003 I started writing a new programming language for myself and it was explicitly for the ability to write programs I didn't want to write and see namely anything other than games so small programs basically I wanted a language that was better than C for writing small programs and I looked at what was currently out there at the time in 2003 and it wasn't a fan of any of the things and I was like so I started designing this language and it you know had garbage collection or optional garbage collection I remember and just out a whole bunch of stuff that would let me approach it more like a C programmer but cover a lot of this other stuff that I felt uncomfortable with how C handled and it's a little interesting to compare to John blows jaw j ai ai get the compiler that he's work he's been doing because he's sort of tackling the opposite problem he's like C is a terrible C++ is a terrible language for making games so let's make a language that's better for that the connection there is that Stu I introduced the syntax in which use : equals to initialize variables and you can leave out the variable name and the initializer in in the same ways that you can in in Dai and which uses that because I sent him an email saying hey here's here's a syntax idea and of course he hates getting syntax ideas but I snuck it in under the wire and um but I find that all very interesting because it still turns out that a lot of the stuff that John is doing in that language is actually useful for the problems I had so 2003 I really thought this problem in C was so bad really using another language was the right thing I agreed with everyone who thought doing it and C was a terrible idea you really needed to use another language who says talked or lets were so far past that and I already gave you that one so um and I've already talked so much this is a little irrelevant but let's go ahead and do it so Who am I I'm primary known for writing the STB libraries which are collection of libraries on github and collection of libraries is 18 libraries 45 times the lines of code so it's not huge but they're becoming well-known amongst game programmers um professionally back in the 90s I worked at a company called looking-glass I've forgotten what the last yes looking last Studios look unless technologies originally um and there I worked on the game thief the dark project and I made most of the engine that was used to for the rendering part of the engine although incredibly complicated and sophisticated engine for doing object stuff and other things that I was not involved with but I did the rendering engine for that and that was used also in System Shock 2 so and I have been programming for as I said since 1980 or so so 35 36 years and I have perhaps accumulated a little bit of wisdom over those years I certainly have a follow two distinct trajectory in that I talked about the going up to C++ and going back to C like um I mean I have some peers also but I think who are similar but I think a relative rarity and I'm certainly not saying that those many years of experience make me a perfect all-knowing being I do lots of dumb things I still experiment I'm still trying to figure out the right way to do things but there are definitely some critical moments where I learned something and I changed how I did things and those are the real reason I'm giving the talk even though those things I've already summarized in the too long didn't listen to a slide and so for example the fact that I was working on this language stew in 2003 because I believed that C was not useful for writing small programs that's there was a turning point where I realized that didn't have to be true so yeah so who is this for uh you don't have to actually be a C programmer I'm going to try to give insights here that are useful in lots of other environments but towards the end probably I will drill down and give some C specific thoughts make sure I didn't miss any questions all right so I want to just establish a little bit more like more than just that I have 35 years of experience or whatever that number was so here are some major projects I worked on um in 1990 I wrote something called sludge which was a mud a language environment so if you've ever heard of a LP mud a bir mud mud tiny mud tiny Moo tiny mush back in the 90s a lot of those things were uh were kind of hard-coded and there was a move by several of us towards a system where you wrote all of the game logic in the interpreted scripting language that they almost all had and sludge was one of the ones that I think went the strongest in that direction uh and no one ever used it so um but it was like a you know a full programming language interpreted garbage collected and designed for the multi-user UNIX kind of world with the text protect stuff and did not have any built in system at all that had actually anything to do with muds it was all written in the language professionally I worked on a company that made postscript rips which are put script interpreters and before the company went out of business in 94 we needed to become more relevant by supporting push script level 2 so I led the efforts to do this which means I sat in a room and I started writing the PostScript level to rip well everyone else tried to do all the work on the old one to keep the money flowing on the contracts while I made forward progress on our script level to a forward enough that the company could switch over I should point out I had been working at that company since 92 and I graduated from college very late in 92 so they put me on that um they were putting all their faith in that company in me and it was my fault I did wonder we just I didn't have time to get it done so theif the portal engine uh which uh I already mentioned I worked on some large-scale indie games in from 2000 to 2008 which I never shipped I should some small ones but I never shipped any of the large ones and then the STB library said I talked about so what I knew about small programs well here is a collection of programs these are not all the small programs I've written in the last 10 years but these many of these probably more than half of these are programs that are command-line things that I live in my bin directory and that I do potentially use all the time so I'll talk more about what where this came from where this directory came from but I just want to give you some impression that I have been doing some small programs okay what I mean by a small program typically I'm talking about a program that you write in five minutes or two an hour or that I would since obviously different people program at different speeds and I don't want to imply any kind of inferior order so if you program at half the speed I do I'd be talking about program that takes ten minutes to two hours um typically like I said they're command-line utilities but I also do things where I write simulations to calculate like a Monte Carlo simulation to solve some problem that you can't do math solve with pure math that you know something or something that someone might break out Mathematica for sometimes I might people do it spoke graph generator sometimes I need images for different purposes there's a paper of paper an article I wrote criticizing screen space ambient occlusion where I pointed out the corners don't actually shade that way and while aiming occlusion is a nice device that does tend to make things read more eat more easily for people because it's a quick approximation to global illumination and in that I needed to overlay some some little diagrams on images and so you know I wrote a little 30 line program to do that I've done a lot of work in game jams and game jams tend to be two or three-day projects um not one our projects but obviously the skill skills that you can use for small programs will scale to larger programs they you know scale less well the larger the program is the less the tricks that make small programming better or not matter okay so here's where my slides right now um so code reuse um it's the most important thing and let me bring out my notes you okay and identity objected to don't dump to dump so one of the origins of this and so I mentioned this on Twitter much of what I'm talking about here is the secret history of the STP libraries in other words it's what there was a big confluence of different things that led to the SUV libraries and it's hard to point at a single cause and so this will just reveal a few more of the causes so starting to say oh yes so when I worked at Looking Glass one of the things I did in the thief renderer is I had a complicated system in to sort objects-- because you had to draw objects from back to front for them to draw correctly because we didn't have a z-buffer which is the thing that in graphics hardware just magically solves this problem so you're not even a way that it's a problem and yes it's a static desk and protector so that algorithm was really squirrely was really complicated had a lot of weird cases a lot of different stuff and I was worried like had I really understood the problem like sometimes I'm like well if this case happens and then I'm in this case oh and then this sub case I'm not always even sure whether the sub cases even a thing that really happens so what I decide to do it Looking Glass was I decided to write a coverage tester so a coverage tester is a program is that shows you with some other program what parts of the program are being run so you know the traditional coverage Chester gives you back a listing of your program and marks up each line that got run and the lines that didn't get run are unmarked or something like that and yeah I'd seen one of these in college you know there was one for the UNIX systems or whatever and I was like that would be a good way of getting some handle on this algorithm that's sort of getting out of control that's so complicated that I'm putting in cases I'm not sure can even ever happen now obviously if they don't happen in a particular run it doesn't mean they could never happen but it would help me get some insight into what's going on so um what I did I guess I should switch this so what I did was I wrote this program that I I wrote a header file that redefined if parentheses and for now I can do for weighted are you for for yeah I've turned four into a cattle cats for macro and a while those three conditional statements are the main sources of where your control flow changes um unpredictably you can also jump through function pointers I didn't handle that case so I wrote this set of macros that recorded the filed line and the condition so the if you know X it would record into a buffer file line and X save that all the way write it all out to disk load it all back up after I ran it taking the the program and annotate all of those lines to indicate which way branched oh and switch statements you grab the integer value from the switch statement and store that and so I wrote this program and so because you can see which way it branched you can implicitly infer I didn't bother parsing the code and antitank all the code but you can see if the if has never taken then obviously the code inside the if it's never taken um so I did that and you know it was a useful thing I was like okay that's you know helpful and I think I also maybe wrote a profiler a little mini profiler we had other profiling things but I think I wrote an invasive profiling because I needed it for some reason alright so that was in the 90s so then in the 2000s Here I am NOT at looking-glass anymore and I was like you know what this problem I have right now I could really use a coverage tester oh no I'll have to write one again I already wrote this it'll be exactly the same but I don't have that one that was looking glasses it's not mine and I think at that one I just didn't bother I was like yeah maybe I won't bother doing a coverage sensor and then I went John blow I'd have to check the timeline to make sure this is actually order this all happened but John blow suing a programing series in game dev magazine and did a thing with the profiler and I took his profiling core and readapted it to provide a different set of originating that I thought was more useful and really sad as a little thing called AI prof and my peers at least like Chris Hecker used it on Spore but I don't know how much I'll take it got it was just out there and I did not public to mean that it was just had some copyright on it so my point there my point the thing I realized then was that I'm never going to do that again I'm never going to write another coverage testing library that I just don't have rights to for myself I don't want to be forced to do that multiple times if I'm working at it if a company comes along and uh you know hires me as a contractor to come in and do stuff I want to just have this library that I already wrote it would be nice if I can just drop that in and um so I kind of Oudh well I'm going to figure out a way to make these things reusable from now on always and took a while before I found the right but that was the the incentive I was like why am I writing this it's a coverage tester is not a core competency of a game company it's not an important thing it's not something that company really needs ownership over so I was like you know if I can swing it I would say I was not working in the industry it's 2002-2008 if I can swing it I'm going to next time I work for coming I'm going to be like anything I write that's this small utility library kind of thing I want to not all under the control the company and eventually sit on public domain as sort of a compromise for that where people could understand that it was for everyone's benefit not just for my own benefit although obviously my entire motivation was for my own benefit I don't want to write these things multiple times of course the odds that you can find a company that will agree to that I think in practice nobody at the company individually would necessary mind but getting that through a company's logic just not probably going to be very viable for most people so you know I don't know what the solution there is but for me where I work at rat game tools they're totally happy with that I actually one of the libraries of STP Vorbis has paid for them paid by them on contract because they needed for Miss decoder and I was like well can I put in the public domain too and they're like we'll pay you a lot less and I was like okay and then after I started working full-time at rad I needed a true type rendering for my project Higgy which I left off my major projects list there I don't remember why I left it off but and so I wrote my own TrueType renderer just because we are a very not invented here shop we really don't like to have dependencies on third-party code so I wrote my own full-time while I was at my job and once it was done I said to my boss so I was like you know unearthed company and I said hey can I put this in the public domain and he said sure so because it's not part of our core competency and he doesn't feel like you know that gives a leg up to somebody making a competing product a little leg up maybe but it's just not worth worrying about so that's a super-lucky benefit of the environment I happen to be in I can't promise you can always get in that environment so that's sort of the sort of philosophy behind the stuff let me find my notes again behind the code reuse stuff do I have more specific points about it I'll talk more about su SP libs and fit so okay yeah so here's what I want to talk about I do want to talk about the high concept of SUV light so the punchline of that 2003 writing this language called stew is that um I figured out a trick that lets you do a STL's vector something like that in --see wit by which I mean that you can just say you have a variable named ah by which I mean that if you just have a variable named foo that is conceptually an array of you know struct so let's call this data all right if I have that and I'm in my code I can write through some three that's like a fundamental thing that you expect to be able to I should swap these sorry so you guys can see okay so I have variable name foo so you know this would be vector food in C++ the crucial thing is that this works it's possible to write and see some kind of vector like abstraction but you have to use macros everywhere to access variables from it and um the the crucial thing to making this stuff work for me for this to see solution and to be valuable was this had to work this line and it turns out the way I actually declare these oh this was backwards sorry um we're actually declare these is just that they look exactly or acknowledge they look exactly like a regular C ray so that was like that's actually requirement because in C that's you have no operator of length so for that to work this has to be the type and so I figured out how to make that work that was crucial and the reason I bring that up is because I was looking historically here's a list of all the SUV not H versions I can find in my hard drives unfortunately B because nobody in the world uses the freaking ISO format that's sort properly and since the sort is not or Windows sort is not smart enough I can't actually sort these by date to find the earliest ones uh but yeah here we go fourteen that's not actually the one I have written down here so when the earliest ones I have is from yeah so three months later three months later I have one that is 900 lines booths the array type I was just talking about some file handling stuff and some other things and within a year and a half it was 8,000 lines I don't actually even know how big it is now 14,000 lines now I think it might have gone up to 20 at one point and then I took about the stuff out so the crucial thing is that I figured that out and that let me do vector style stuff in C and that one thing by itself is really what saved C for me without that I would not be comfortable using C so I'll come back and talk more detail about that like I said so for now let's just uh move on to the second bullet point and I'll come back to it so the second point Center got screwed up um spend your time writing useful code not doing other things so I'm trying to sort of incorporate some of the lessons we've heard maybe from handmade hero and uh Abner Coe Embry's coin Bray's talk uh what programming is never about and usually we talk about that in terms of you know don't write UML diagrams or maybe object-oriented programming is a waste of time and things like that uh but one of the things that inspired me was that I have this directory that I just showed let me show you something let's suppose I were going to make a new program in so I'm using an ancient IDE here this is 1999 Visual Studio you know things maybe they've gotten better but probably not so if you just count here I'm doing a new project so I've got a one-click Oh two three there's no tempter let's call it dummy I have to do a little typing but that's okay that's required in and that's required and now I've created the workspace up now I've got this okay for a five alright now I don't actually like that view for a small project so I delete that extra keystrokes I have to go into the settings some of this is because it's ancient so I want to turn off precompiled header files and maybe I want to add that all that you add that automatically expands your wildcards for you so you don't have to remember what it's called in the release build I still want debug info they're like a cure and turn on again fo for the really spilled and now back to the debug build see uh what's the other absurdity Oh cogeneration this is definitely because I'm on some ancient things so I have to run off blend and tell it to use Pentium Pro optimization now let's go ahead and use uhh like multi-threaded Lys I have to tell it to use now I don't quite have to do all of those steps if I know I'm not using multi-threaded okay so and now I got to create a text file and I'm instead of using the keyboard I'm going to actually just type it actually not my word so here we go now I finally get to start writing my program and this part of this talk was inspired by watching someone wrestle unnecessarily with build problems and there's not not a criticism about that person that was doing things a not an unfamiliar way on the stream but but it was just kind of hilarious to see how much frivolous work was involved and and how kind of counterproductive it was especially when something went wrong so let me show you what I do actually when I want to make a small project i double click this i go up here recent I select quick choose my name for this thing which we saw earlier and quick is this C file and what I do when I want to do a new thing is I delete it and I delete it and I start typing and maybe I don't actually delete it maybe i bleeped everything but the first couple lines because i always want to use those and I start here and I just start programming right because the point is spend your time writing equal code not doing other things so I want to be able to drop it in as fast as I can now of course you can do this with command line the stuff where you just write your program and then call CL and your thing is right there this is one of those inconveniences of Windows of using ID if you not use the ID though and you're willing to do that stuff that way I don't by default have my you know stuff like me like I'm not saying to do this thing I'm doing my point is identify what you're doing that isn't programming and streamline it out so for example so here this actually is the program I used to generate the slides for this talk of at around a little bit before 5:00 p.m. so an hour ago I still had not started slides and I was usually use PowerPoint for my slides but I don't haven't given a talk in five or ten years so I don't have a PowerPoint on this machine don't have it on a disk or anything and so I was like I'll have to find a place to download install it and install it and wrestle with it and remember how to use it and if I just use HTML that'll probably be a lot quicker so I wrote this program it took me five minutes to write this program it's a very trivial program that parses a text file and auto automatically centers stuff and turns bullet items it's like a mini minimal markdown it turns bullet asterisks items asterisked items toad whole times and my point is is this is exactly the kind of program that I've been talking about throughout this whole thing it's a little trivial program in this case I didn't use that may STP functions it's mostly afraid of oh I should explain by the way well I say it took me five minutes I did have two bugs in the program I forgot to increment I here I got in the infinite loop and I get forgot to carry my page here so it everything output to the same page I had to fix those two bugs when I actually ended up spending 10 minutes wrestling with was I've never learned CSS so I have to use tables to do the formatting and I didn't remember how to do that stuff and I've still didn't get it right and I did spend like 10 minutes wrestling but that knife probably should have just done PowerPoint so that was my point was that I where was I going with this oh yeah so this was just an example of using that thing so then what I do is I this is a file called quick dot C it's the only file on the thing actually if you need to use C++ as a quick CPP dot CPP empty and um it has some other stuff in here that doesn't get compiled and so it doesn't matter that it's in here and this is uh often I use this for building initial tests for stb libraries I'll write a program in this thing and um so uh - what I do is once I've got a program that works I then i building release I going to here and I stay install Q and what am I going to call this I'm going to call this program slide gen a batch file that copies that noon executable to this new thing and there you go I've installed a new command line app for all time that I sink that to a backup repository I copy that to my work directory etc so again nothing magic and specific about this quick oh and then sorry the final step which I've already done here is I then write this file out to some cname typically the same name as the executable and if I need to go make changes to it I can you know I'll say say I had started a new program what I've got here I'd save this out and then I would go open slide gen don't see it can someone change slide Jenna cut copy - quick CA paste and now I can I'm back to developing slide gen here and then I save it out again except I just did it wrong because I now tells me I'm in slide gen somehow missed switching to endemic Oh anyway undo is your friend so uh so that was the uh that's my point about no it's 100 I accidentally closed it um oh yeah my point about Spain your time writing useful code not doing other things right so find the places where you're not doing useful work and eliminate them because that is stuff that you're doing that is not programming that is making writing small programs harder the whole point of that is that all that overhead that I did if I was making a project that would take two years to finish I wouldn't care about that time invested yeah I forgot there was a that this also had a looking-glass story as well I forgot about this so at lookingglass we had a tech group that made shared libraries that we used in all her games back the software rendering days and we um you know so they had to Deer n during 3d rendering and various you know resource management various stuff and when I wanted to write small programs there at Looking Glass I discovered this problem which was that those libraries were only intended to be used in large projects they had a lot of overhead to set up to deploy to use the api's were complicated in certain ways um you've heard the direct right critique from Casey and maybe from John blow though there's this kind of common tradition in API design which is you make simple things easy and make complicated things possible and a lot of Abijah API designers especially at Microsoft have a habit of making the complicated things possible and that's as far as they go they never make the easy things easy so you want to work with things that make things easy when you're making small programs if they make things hard and it's a large program it's less of overhead if the overhead gets amortized over the larger program but when you're making small programs every little thing you do is just terror and it sucks so ah the the install queue for installing that program into the bin directory you know that's just I I could type it out by hand but I I'm less likely to make a typo you know that's there's that cliche that you know good programmers are lazy and they always you know automate everything and I'm not actually an automated guy I don't automate things very often but this was a thing that was worth automating because it was one of the things on the barrier to making small programs if I didn't have an easy way to make sure the thing I just wrote is always on my path I would feel a little less incentive to do it so it was important to get all that stuff streamlined as possible all right so that is pretty much everything I want to say on that topic and swimming there were no questions so the next thing is to drill down more into the STP stuff and actually talk about see and so this is way less interesting if you're not a c4 guy way if you're having with C++ you're having with Python Perl whatever Ruby Ashlyn don't you remember what all those cool languages are these days I'm like I'm 10 years behind here now if you're having with those languages that's awesome you keep using them you know the stuff I'm talking about it's not really you know uh well I when it comes to code reuse that I was talking about that arc of these languages growing coming into being and people kind of switching to those languages and one of the things that those languages did is they kinda to have better standard libraries more appropriate to the task at hand for example in Perl and then you started getting things like Perl C pan and equivalent you know ruby gems and I don't even know what the Python repos are called and then you had boost in C++ and then you kind of saw this pattern that well these things have lots of libraries they're not necessarily sure if their libraries you want to use and this is something I think read Brooks talked about no silver bullet his essay that's not part of the mythical mythical man-month it's also famous think he has like a follow-up to that or maybe was a fob yeah but where he was talking about code reuse was being the thing and uh the uhh what we stopped uh ed works oh my god I'm so terrible now about losing my mental track I was rewinding talking about sepia oh yeah so he talked about in silver bullet or the follow-on article to it I think that code Riis's really making a difference but now the problem becomes knowing that the code even exists to look for it but I think there's a strong rum which is that these you find a lot of programs out there that you don't necessary is because those things and obviously I have a particular taste in those things I'm trying to be careful to not assume that I'm objectively right obviously the things I do appeal to a lot of people so they are useful in that sense and I talk about that in the why the STP libraries my a little article about how to make your own STP libraries where I talk about with the three things I try to do an estimate libraries are which is that they need to be easy to deploy easy to use and easy to something else which I don't remember now and so the easy uses the API part and the easy to deploy is the single header file part and I think the easy to licenses you know the public domain it's the third one I don't remember the so I think that stuff is valuable having the giant Sipan library you know instead of the STB dot h approach is totally reasonable if you can make that work for you um but identify what works for you and if that isn't working for you in whatever language you use if the giant sets of gems out there then start doing this because I didn't make s bah for the first time until 2005 and I had been programming since 1980 so it took me 25 years before I realized I really needed a way to systematically reuse code so the one thing that I would like to do from here for women with his talk that I would hope would happen is that some of you guys out there who are younger we'll have to figure this out for yourself we'll have to really to really understand we'll have to figure it out for yourselves but you'll do it earlier than 20 years into your program career and quick the quick thing a project did not do that till 2006 so same around the same time I've suddenly got serious about how to do this stuff um and uh so yeah like um if you if you're comfortable with the CPN style stuff and you get useful or boost and you get useful stuff that way and it makes you productive and you are spending your time writing code that actually get stuff done that's awesome that's great you've already found the solution um but if you find yourself not doing that stuff then figure out a way to in the future minimize your time doing that stuff for small programs again for large programs you know if you have to write a vector library vector matrix library for every game that you make and that game takes you two years to write it the amount of time you spent on the vector library is if in a test well it doesn't really matter I mean so that's why there's for example no as to be vector libraries because people get very personal out director I raise and they really want the C++ operator overloading that I wouldn't provide in a c1 but I have two or three and I tyent kind of reuse them but I also kind of mostly just make the stuff up again from scratch on those projects but if I'm writing a small game like thing like when I wrote cave you for the STB voxel reader the minecraft viewer um I think I reused I'm pretty sure I reuse some existing vector code for standard Lib is a great thing to use to answer a question somebody asked in chat insofar as it does what you need so one of the problems with the standard Lib is that some of the api's are not designed very well Stern copy which copies of substring is a notoriously bad thing that's easy to misuse because strings are supposed to be null terminated and it ends up is it or isn't null terminated I think you get S is a notorious security hole because it doesn't take a length for its input buffer on the other hand I use get us all the time in my dumb little utilities because I don't expect to put my dumb little utilities on the net where the security hole manners um on the other hand I can't do that in STP libs because I actually have to worry about the overhead from that stuff so uh so I absolutely do use the standard Lib unlike KC I have a totally different attitude towards that when the stuff is well-defined store copy juror you use store copy I mean why would you not use printf it sara is my attitude I use malloc and free I use realloc realloc has ro semantics so if you one of the things when you use realloc is what you'd like to do because you have some buffer that you're growing what you'd like to do is you'd like to say P equals realloc P to the new size because you have some variable and you'd like to it to be updated but the this code that's a bug because if the realloc fails P is now no and you don't even have the old p value so you can't even free the old one so you have to do something like this and then you say if Q is null then you failed sorry it's not only that you can't free that you just don't even have access to it anymore you don't know where that pointer was you have no book so now you can deal with failure and otherwise you say P equals Q and you're done right that's like if you're doing this little bit of code in line so I've used realloc and I kind of always hated that and sometimes I would just be lazy and not care if it ran out maybe I would just say P equals reality and screw handling the failure case because often I have no better solution so what I found of course is that I had a pattern with realloc where I had to keep track of the capacity so I stored that in another variable and then I had the actual length of the array which I sorted another rail so I would end up with these three variables structs going around everywhere doing these dynamic arrays that because that way I could still use this notation because these were things so and John has talked about how the fact that his dynamic raves in Jai Jonathan Blow are in fact just a struct of three elements and the appropriate syntactic sugar at the exact same three elements and the STB array type that I use my vector SVR a which is my vector replacement which I showed you as being data star foo the way that works is it realloc sunder the hood and stores at the beginning of the array right in the bytes right before the array of stores those other two variables the capacity and the size which means that this thing does not actually have like a vector it behaves like a reality array which means it can relocate and that causes some trickiness which I may even get a chance to show you in a second so but in general I absolutely have no opposition to using it both for small rooms and for games because I totally disagree with Casey on a lot of the details but I agree with him on a lot of the large-scale things that he's talking about in handmade hero um so uh Shh all right so what I was going to do right Casillas let's investigate what functions in SP I actually use a lot so this was something I was kind of curious about if I go in to purge quick just quick sefa listening so I just copied all the C files into this directory alone and there's some redundancy you know I've multiple variants of stuff and various other things and you know this is not going to be a perfect test but what I want to do is do a little groveling through these files never done this before I have no idea what the output is going to be travel through these files and find out which STB functions I'm actually using and I don't want to waste a lot of time on the stream so hopefully I can do this really quickly fortunately that problem you could probably do it in awk or something like that would be the better way but since we don't have things like awk on our machines these days those of us on Windows and since I don't know it I really do have to do it with the C because it's the way I know to do these kind of small programs so what do I want to do what I want to do is get a listing of all the files so as to be a reader ask with masks remember reader files right you have to say whether you want files or dirts ask um so we'll get them from C e : Shawn urghhh Rick Rick see piles and we don't actually need a mask because the only thing in there are sea house old if it didn't all right so that would give me a list of all the files through all of the vowels and we'll load them we'll just load it as a configure string you so I got all the and it's a string so now I just have to find all the symbols that start with s DB so I need a really trivial C symbol extractor Oh go ahead and go we don't really want to just want to do a little faster we just want to say while well a space X and well use these are an ident something like that I think there is it might be posix only or some space is space right um or that list for the other one album like a variant of elements and juices on them so if you you giggles you'll identify characters this will pick up stings inside strings which I can fix if it's a problem yeah you can definitely do it with the red X to extract it it's just not kids I have red X but I don't have a red X with extraction and I never use it so and the red X wouldn't actually handle the strings very easily and so if I do add support for the strings Oh so otherwise let's just advance by one character assume that will give me a crappy parts of the tokens so and we but parse to the end of it it's not his alpha and it's al al dome inside all or all right so now s2t is the token so we can just print that and check that so let's just make sure that all correct else to custody you she was already no be you raagh sometimes it's mo forgiveness you just don't bother freeing stuff like I'm at the end I should free files but while I bothered but at that point that be spilled it didn't seem to do anything I'll have a bug no ugly files is empty yup files this empty so I path right you you sorry actually listing all right sorry about that you something I shouldn't free ugh you it should be safe to free did I trash the memory anyway that looks like that was working up to a certain point then it went off the end of the memory possibly go so right now this doesn't print the last token but this is only because I'm overriding at zero at the end and then losing the ability to tell that I mean that might be what this mug is so I'm going to I'm just going to change that okay so it looks like it's right let's just do that so I don't have to write into that string and screw things up see if this bug is still happening so there were something I'm doing wrong here with writing entity right in those zero entity breaking something because I don't actually need to do it it was just doing that to print it okay so now I've got the list of all the tokens Oh so SUV starting copy copy from so it will copy to offer s I need a different one it needs to actually have to thing you have to do them so I'm going to copy yes search sterlin buffer equals t minus s it's what it should do you and will bother processing seconds you oh yeah that's another thing I would have to turn on is okay so I didn't quite do that right not me remember how Stern copy someone weird oh that takes the size of the buffer that's what that is should you want okay do need to rework that like I said all right so I don't know how long this has been already five minutes maybe more ten but we're right there now because now we can go if Stern calm buffer or comma SUV underscore now we have only the tokens that them okay and let's yeah okay so let's just go ahead and do that to a file right that 2cx to be so I'm going to go ahead and sort these externally I could do it internally pretty trivially I could build the array and sort them in turn out them actually I better do it internally so we'll go ahead and show you how this stuff works so No so now we've got the buffer so we has to be a rain pushed and hits strode OOP all right to the end say sort it's to be our land it's size of hits zero struck up this you struck up count them for I'll SNS by the way it's I what's the easiest way to count of a sequence you bro strikoff it's swine one i0 Ryan Oh sixty that but yes Oh one two you probably does what I want or that book okay the counts were all wrong and Oh you you so this is just like you know using sort and or something so now we can say that to call an ex STB tokens CID and run it and that we say sort from X SUV okay call it run te calling X okay usage it's not all your completing X new search text okay Sallah complete it's not actually doing runs okay so I struck humped in the wrong direction I remember thinking that out while I was doing it do know it's in the right direction why do these not match Oh I'm a missing all one long yeah the trick for doing with printf is fine it just it only works for printout for you have to use printf or whatever and so I really prefer to just have a function dedicated to do um I think I already do I think I have a better than s to be storing copy and I just don't remember it's maybe comes with a Fred Brooks problem of knowing everything that's out there but what's my bug first of all let me do it this way because I way prefer for surkov to have meaning of the start comp at the beginning so I'm checking that it matches leave this one if it does I increment run skip to the next one and we print so why is it how could you ever print artless disparate you like that so slow too crazy slow it's not that much data same not sorted okay uh it doesn't not work to pass the circle here because you pass the pointer to the so I have a function for that probably so the problem is you're getting a pointer to the you're not getting a point to the string you're getting a pointer to the old inter compare let's try that one ah all right I call it s PQ sort string clear there we go okay so that'll fix all that so for that you see decals idea this is always worked for me in the past and that's why that functions there a reason that doesn't work must be something about the flavor or something oh hey look it was only a warning then we run the sort and it's still not right you buggin live on the stream it's zero one it's ok well yeah those are not sorted at all sighs of hit zero I would that not sort am I missing is the array length then the size not vice-versa this is the kind of thing that normally I just thinking about it the size comparison function you then I think it is now you you I don't know what's going on but I'll just spray the trivial the dumb thing or this is exactly what the other thing does not sure why this would be anybody maybe that maybe whatever that took declaration in warning it is something meaningful look now they're sorted all right so I don't know what that was but there we go okay so now we can see what do i what are the things that I use the most s to be our Len and then SVR push is going to be up here so the vector is the thing that I used a lot it's always going to depend on the code that you're doing but has to be lerp is just an implantation of the obvious loop function has to be linear remap to function that have X in the range from A to B and you want the equivalent point in the range from C to D so I use a function to do that it's equivalent unloop on the first set and then larping the second set s to be straining comp because there's no cross-platform store case comp vs. store I comp um obviously I use STB image a lot so that's the header file being included I think s to be R and it has to be a friend because the random number generator and C is really terrible SB maintenance to be max because the standard ones in CRMs has to be or a functions char I know I haven't used that in year or so Hohner SP clamp just because hey you want clips um string file in the file SUV file should be in here while steering file for reading files it's pretty common the s stick that's a really important thing that's a hash-table mapping from strings to pointers I use that all the time obviously not all the time given that it's only here yes took 15 times so the other thing I should mention is that that list of files that we're looking at here is not every file I've ever used with this quick system because sometimes if I'm just doing a one-off I will write the program running collect the data I need to from the program and not bother saving it so I don't actually have a history of all of them all right so anyway that was just another kind of curious a little look at that stuff and it let me write a little small program on the stream for you just to give you a sense of it it was not to say the best example I wish I could turn this off I said no turning off there goes but it you know it serves the benefit it's a fairly small program I don't know why that I can get that queue sort thing to work it would definitely be smaller in other languages if you use regular expressions you could get rid of you know this much of the parsing could be a regular expression actually I don't includes this part too here so um but on the other hand you know again I'm not trying to tell you to use sth SPR H is my header file for what I want it is available but if you are in Z and you don't have these kind of tools you're really hurting yourself that was my actual point now that I've finished doing that so there are a bunch of useful things in SUV NIH I have 15,000 lines with way more stuff than I ever use because I would just start experimenting well I'm I love programming so I'm going to solve the second problem so I wrote a little Atilla T library to do something that I didn't even need and snuck in yesterday I was like now I'll have it there if I ever want it which is you know potentially can be it and the odds are I'll never want it but I wanted to try to write the thing in so that's it that's a gets at my points I think so let's go ahead and step forward there you go yeah that was it so I have not seen a chat update at all on the stream and that went a little longer than I meant to I wanted to be an hour but that program took a little longer than expected so uh so yeah that was that's it um I hope some of that you know like I said in the TLDR there isn't really anything deep going on here but I I just want to give you the the ability to avoid the mistake that that it took me twenty years of programming to realize what I was doing wrong and on a different scope than what we normally talk about in things like handmade hero so yeah so that's it and questions guys else except for my chat not updating at all there goes sadly I cannot recommend you any good book I learned to program uh 35 years ago and learning to program or you know that kind of thing I don't have any recommendations for books for people with 30 years of experience um ya know you know in the middle ground I certainly would I certainly approve of you know reading the Knuth books they're very dry and academic and um not very fun but um I use 'fl full stuff just taste broaden your horizons why do I not cash us to be our Lin when I'm looping it is a little bit of overhead but so there's two answers to that so the question is like why I write this kind of loop where I have to keep recomputing this every time and you know there's three answers to that the first answer is that I don't care about efficiency usually when I write these kind of programs efficiency is not the goal although because I use hash tables and dynamic arrays they are almost always faster than programs written in other languages and programs written by people who do not reflectively deploy a hash tables for problems the in fact the way I'd intended to solve this was not to use Q sort I'd meant to use a hash table and insert the every entry to its own name but I forgot by the time I was coding it and it is a different way the second reason is that SV our line is a macro that is a very fast trivial thing so if you care about the performance it's all it's actually doing is doing an interaction off of that hits array the same as everything else is it's looking like if you imagine hits was a structure it's looking at the negative one field of the structure so you know if it was an array of ants it would literally be the negative one of that same array so it's not particularly expensive you already have the hits variable around you're running on an x86 so the instruction that that generates is just a single instruction that the memory address off of that thing which is the same thing it would be doing indexing off the stack anyway so it's not actually necessarily going to be a faster and third reason is because it would be bug prone if you cache end in a variable and then the array changes lengths because the whole reason I'm using the hits array of s to be array stuff is that it's a dynamic array that I can't change the length so if the length changed the tests would now be wrong so just as a reflex you don't ever want to cache s to be R Len ray length in a variable ever because that is just going to encourage that kind of bug what other advice would you give yourself if you could go back 25 years I don't know I wrote this talk or sort of we're at this talk to talk specifically about that thing that I knew that I wished people I had had told me and I like I've said to I don't want to be clear about this I don't expect this to convince you I don't expect you to you might come away from this and think oh yeah that all makes sense that's good idea I'm gonna try to do that the point is is that for me I always knew code Reese was a good idea and you know it's obvious that overhead is dumb but it took me 20 years to really get that deep down which is why I gave some of those stories about like wanting to use my code if I worked at a contract on contracting or something that I really had to feel it deep down I really had to hit that like John Carmack had a Twitter post where he didn't specifically reference the speed lives but it was he was clearly talking about that where after he went to oculus he wrote this tweet where he was like he basically said that thing I can't remember what specifically he said but he was saying it really sucks when you go to write this library again because he had been at it for so long like it's code was his code right he just kind of took for granted that everything he'd ever done it he could use and then inside oculus and he no longer can and I think it's really common then certainly for people our age that it really takes being hit by that explicitly right really running into that going oh crap I have to go do this thing all over again I let me keep my cell from doing it so I don't think just telling you that is really going to convince you maybe like you really have to experience that for yourself to be one over to this idea and to really take it as seriously as I do which is a thing I forgot to mention which is that the STB libs are all part and parcel of this as well as SDH you know I made STP image because I wanted an image loader that didn't suck compared to the JPEG and PNG experience that I was dealing with which is many different things the API the problem with deploying the license is fine in solving that problem I was like I might as well give the results out to everyone else why do I bother with a good API design a flexible API design for something I'm just using for myself for one project it's because I might use it later and I better get it right now because I'm not going to have the you know the full mental knowledge to try to fix it later so it's totally selfish except for putting it public domain so everyone else can use it is one perspective on anyway so maybe that without getting that expressional experience you never go me quite convinced so all I want to do is like that next time you get burned by this a little bit maybe that will be enough you don't have to get to the full burn that car back and I had before you really realize how big of a deal this is um um I know you remember which question I was answering have I used I am good yes I have written three or four I'm gooey libraries uh I'm been a friend of KC's for a long time and he first posted about I am going on the Molly rocket forums um and uh I was I wrote about I'm GUI four game developer magazine many many years ago although my article that was when I only knew a little bit about it because that's generally get during your colonists so everything I said was not that a kid but I absolutely encourage every for programming quickly it's not necessarily gonna get you the best results for a user facing thing although I'm trying to do that for the current project I'm working on for my work but we'll see if I want to have Sara and Stan live where do you think it would be better than trying to have one standard library for everybody it's hard to say um I honestly I think a one standard library for everyone that was a great standard library would be pretty good thing different people have different needs I need lerp sand leaning ori maps and most people don't and you know you have issues with learning the standard library when I first started programming see I didn't really understand the programming library and you know I would write a you know I needed to copy a string I would write this what is the you there you go I write that instead of calling instead of doing this that's way easier this is a bizarre idiomatic crazy insanity but I understood strings at a character level and I didn't what's it familiar like this was in school I wasn't familiar with the full suite of the stair library and come on look at that look at that how how do you test your Starling Raja like why would you know that that is how you do that you know and this is the reason I knew that was gonna have something they teach you is that oh well reason let's see has all these crazy plus you know post increment operators is you can write crazy things like this to do a null Terminator incompetence anyway obviously I didn't do that for very long but the point is that you know you can end up rolling stuff yourself and I don't remember what that had to do with your question I've already lost that train of thought so anyway one standard library that did everything everyone needed to be great I think they're more realistic is to have multiple libraries that split out the things that people need but I would rather everyone use the same ones if we can solve the deploy problems um you know and that is one of the things that SUV image tries to do no by no means saying it is the right solution or the perfect solution or anything like that it's just it's what I've come up with to do to make progress on this we routinely use the ideas of polymorphism with void star and function pointers in your C programming I rarely use it certainly in small programs I almost never use it in a one of the things that I have is I have in sth a hash table data structure generator that you can its a macro and you pass in the types that you want in the hash table and it's real pain to set up it adds like 20 parameters to set it up so there are baked in to pre setup once the one I mentioned which is a string dictionary which maps from a string to a pointer and another is a pointer dictionary that maps from a pointer to and I tend to use those two rather than have to roll my own and those pointers there are just void stars and yeah I have to use polymorphism in that case and I lose a you know type safety that you would get in C++ by not having that that's not that kind of friction in the small program like this because the number of different types you deal with in a small program is pretty small so you're unlikely to just have the totally wrong pipe you know when you are casting your void stars to stuff and I tend to cast the void stars implicitly so you know I've I'm storing something in my string dictionary as the values in the hash tables and fetching them by saying you know has to be a stick to get that returns me a pointer and I store it into the variable and that variable was the wrong type it wasn't the same as the type I was doing in the program in sticking in the thing and it's a 20 line program like something has gone horribly wrong plus I'll find it immediately and fix it so not like a big deal function pointers almost never use obviously other than the Q sort kind of thing sometimes when I'm programming larger things I do the you know pre C++ style thing where you make constructive function pointers and fill that out and it's like less efficient than B tables because every object has its own set of function pointers or whatever I certainly use that pattern if I need it but it's not that common the question there's a question about whether the you're a length thing is safe and the answer to that is in traditional C it is 100% safe it is C as a systems programming language that lets you manipulate memory as you prefer so you allocate more memory than you need for the array and first few bytes are used as the length and the capacity and then the rest of it is used as the actual rate and then you off take a pointer so you're not writing into random memory that's before the array you're writing into a memory you allocate it that leaves before the and that's all just hidden away in the macros um so the spra length is just a macro that casts it back to the thing I believe in this a couple different ways so I don't know what the current implementation actually is but um so yeah if it's a null it's always zero and if it's not null then it extracts this structure and gets the length field out of the structure and that thing here is that which is an SI idiom where I'm casting to a different structure type and then also saying by negative one because that's the move to back by the length of the structure which means that that structure now ends exactly where a point which is exactly what I want and so the unsafe thing comes from the fact that the C language standard has not changed but people have become started exploiting a failure of the C standard the C standard hence allowed some stuff to creep in that is not acceptable for systems programming and compiler optimizers are exploiting it in this case I am talking about the strict aliasing the this SP rate thing does not work with the strict aliasing optimizations in GCC and playing I had a different imitation that probably did work but it requires you to declare things differently because the C++ part of it had it has C++ compatibility and to have the C++ compiler really it had to do it a different way and I wasn't able to do it and that's doing it this way let's me declare them in the easy way but has that strict aliasing problem and that's a whole separate rant that I have it's a thing that is very common amongst my peer group that we are critical to see that way and the problem that we actually have at heart largely represented by a kind of person who will say but the standard says X you know when we say this is a bad idea they'll say but the standard says X and standard was written by some people and those people were not necessarily correct like we like to think that they knew what they were doing and we're mostly correct but their choice of making a bunch of things implementation not implementation to find but making them undefined behavior which opens this exploit hole where your code just doesn't do what you thought it was going to do is just a terrible idea it doesn't make any sense from the programmers point of view the de facto C standard that everyone was always programming to that lots of old code relies on that assumed no strict aliasing assume no integer overflow optimizations these other things that code was all working code it's not broken code because the spec says it's working that was all working code for its code that was written 20 years ago was working or whenever that's that first spec happened 94 iso I don't remember yeah 89 I guess but uh that code the code is not broken the code is broken according to a standard that should never have been acceptable it's not what programmers were doing the ecosystem and consists of programmers and compiler writers and the compiler writers sort of feel like they are the ones who are setting the rules but the reality is and I wish there was a good rant about this that I read ten years ago about de facto standards and I can't find it anymore the de facto standard is what the C programmers were relying on because no C programmer read the spec C programmers did the things that worked and the things that other C programmers had worked they could verify worked and they tried to write cross-platform code I learned to write cross-platform code a long time ago in C on UNIX systems and I have those habits ill and I use those habits and they're very effective habits it doesn't make your code necessary non-portable or bad to code the code that's all super awesome it's just written against the spec which is not the actual spec but the spec that everyone was actually relying on and then all the compiler vendors for a long time we're actually implementing they weren't necessary implementing intentionally but it was what they were implementing and then there's this shift re that was a super long answer to a super short question that had nothing to do with that but I just got caught up in the rant so it keeps going down and unfortunately was prefixing the things so I have to actually slow I'll context um people may have already answered this question but you can create a debug jail context in STL - you probably couldn't in one but I believe I'm doing it in a BB gee I believe I'm using STL - and I have a debug context and debug Handler it is very slow to open up the thing I notice it slows down my app app takes like three times as long to open through SDL as it did with my native thing but that's because they're doing a correct thing of opening up multiple to get to the second profile you cut second context you have to create the first context or whatever they're doing that slightly differently one of the more simple STP lives for beginner to start playing with well the whole point of the SP libs is that you don't play with them they solve simple problems and get out of your way there so the canonical one that everyone cares about is SUV image it's just an image loader it's like I need an image here's that here's your image it's a simple API to use it's easy to deploy boom you're done there's no experimenting and playing around and what to do there are other CB lives that you might experiment play around to do with but they wouldn't be the simple ones for a beginner so well code race is really important don't you think it's a good idea to rewrite their tools and coorporate new knowledge to make the most buggy especially since useful tools tend to stick around for a long time well depends what kind of tools you mean I'm writing all these little command-line apps that are tools that I use for things other than programming things I do on my computer that aren't necessary programming so tools for programming like this becomes like sort of a meta question so like what's the case of this that I was posting about the other day um yeah so I was posting about oh I haven't written this post I was writing as post I haven't posted yet one of the things I an example of a tool people used in programming was yak and Lex so these are tools that would help you write compiler so Lex is would write you would write in mini language some regular expressions and into Lex and Lex would spew out some code and you could use that code to do lexical analysis phase of your own compiler and lots of people swore by them back in the day and probably people still swear by them now and this article that I've been writing and I put off I wrote two weeks ago half of a ton I haven't finished was about some stuff into ten years ago experiment with this where I hand wrote it the lexical analyzer and got a faster one then I got out of Flex but also su V dot H has a library for doing this because the problem with the Lexx thing is that it intrudes into your build process you need this Lex file that's a dot L file and then you need a rule to tells the compiler to run flex on it that have to output of C file and then that C file how to get incorporated into your build that's all doable but it's just like some of that build system friction overhead I don't know only have flex necessary installed on my machine like if I place tens on github I would now have to double oh and you need to download flags and if it's just a library so the advantage of the way flex works is it gets tasks you do all this pre-computation and can do it offline and it generates this Lex file that you can just use and it doesn't have to pre create it everything when you do it with my library that's an estimate on H the first thing it does is you set up all the lexical analysis and it certain compiles the regular expressions into a efficient form then when you run it's about the same speed as Lex is but you paid this overhead of having to recompile it which people wanted to avoid by having this offline thing that generated their C code and computers are so fast this is totally irrelevant the time it spends pre compiling the thing is not relevant so forcing that offline you know there's a kind of purity that purity purity that Casey Murtagh and Jeff Roberts tend to exhibit where they really just don't stand for that you got to pre generate that's data into your file and I've moved on the path of I will take small inefficiencies I'll take a 10% hit or the streamlining in the programming experience if that 10% performance hits start slowing down my development time if that's part of the iterative debugging cycle that arts then I'll will care about it but but for me yeah the tools for programming tend to be things that get in the way other than grep you know that kind of tool that's not so much for programming but programming and knows and and switching from tools that process your code to tools that you code that you call is generally superior in my experience how totally depends you're probably imagining totally different tools but hey that's the case that came to mind and I've been talking about that for too long so I'm going to move on um si has been pigeon-holed perhaps unnecessarily and the my point here is that you don't have to use it that way and that's absolutely the thing that I said on that first slide I think with enough options out there like to s to B if C could be recognized as more reasonable competitor to high-level language in the future not realistically I mean I would be awesome I don't see a path to that like C++ if nothing else had so solidly won the hearts of minds I don't know like I I don't follow that like Fabien uh my coworker and friend of handmade hero is has pointed out to me many times that there are many other programs out there that are still developed in C not C++ so it's possible that there is backlash to C++ happening and we might see C grow but compared to the other languages I think there is validity like I had it this discussion over dinner with cacey and Fabien I think there is possibility that performance is not uber all's and it maybe is sometimes reasonable to work in Mathematica instead of writing that code and C to do scratch and that there could be some programming language like Python or Lisp or whatever that's even next more gen where you're working with abstractions that are very far removed from what the hardware is doing and you don't understand how it maps to the hardware and that's okay I'm willing to believe that that could come along and if that happened you would never want you C for that because you would be working at this higher level abstraction that gives you a 10x or more boost that Fred Brooks I said will never happen that was the subject of silver bullet is that there is never going to be a 10x from a single technology but assuming that doesn't happen assuming we just stay in the world of pythons and rubies this doesn't seem plausible to me I would be happy if it happened but I I don't I think we'll get a new generation of programmers from handmade hero that are more in tuned with the low-level world but I've probably just a drop in the bucket everything changed very much with the web um like I talked about that arc that pearl was you know would the only one like there were always languages but they were always toy languages I even Lisp it's not a toy language but nobody took it seriously and pearl was the sort of beginning where those languages start to rise and I think the web is sort of the culprit in some sense of a lot of this stuff and I don't imagine that's going to change I've written CGI um things in C but that's not a particularly popular approach uhh you all the comments on my questions are so far back in time I can't make any sense of them so if you had interesting comments I'm sorry because I have no idea what so ok I've caught up there have been no more questions so if you have more questions go ahead and do it is he using vc6 that is a FAQ if you check the FAQ on the left there is a YouTube video that addresses that question oh there and somebody already answer that in the chat yeah okay if you want to you want to play with the library in the sense of looking at the code that's a different question and I don't recommend it I'm not saying my code is particular well I but my code style is my code style and I write in my code style and the point of a speed libs is really like yeah I don't like using libraries where I don't know what's going on under the hood either and this is the eternal not invented here problem but I feel like the STP libs the good ones are focused enough that you don't depend on them like the only time you're calling this to be you know the only time that s to be what's going on inside has to be image matters it's why you're calling STP I load once you finish calling load you're done it's you don't care what happened so as long as that meets your requirements as long as what came out the end is the image you wanted and didn't take too long who cares what's inside that code I think you even for not invented here people you can get to that mental space because it's easy to deploy it's one file you don't have to like it's not shooting lots of stuff in your directory sorry I'm just trying to avoid cursing I probably that was probably wasn't the first time you know it's the mental space it intrudes on is very small because the API is designed to be as simple as possible if you need to do other weird things it may be as NFS good as an API you want to stream out the image with minimal memory usage you can't do it so there's there's downsides to this approach but it's it's definitely meant to be that you don't play with it at that in that sense okay um alright I have no more questions so everybody thank you for coming and I will stick around in the stream for a little bit longer in the chat in case there are any more questions but I'm going to cut the stream off here and till we get up we got one more question would I consider a specific pool request okay I'll answer that when I'm turned off the stream I haven't even bothered finishing reading the question since that sounds a little too specific so um okay that's it I will chat people I will still be in the chat so thanks for watching bye bye
Info
Channel: Sean Barrett
Views: 77,663
Rating: 4.9012985 out of 5
Keywords: twitch, games
Id: eAhWIO1Ra6M
Channel Id: undefined
Length: 105min 23sec (6323 seconds)
Published: Sat Jun 06 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.