dogear

enter for all results · esc to close

Programming’s Greatest Mistakes

youtube.comvideo

transcript

hello danemarkland it's wonderful to be here has everyone had a fantastic week yes excellent glad to hear it uh i would just like before i start to say thank you to uh jacob and kirsty and steiner and henriette and all the volunteers uh the people in the green t-shirts who've been sort of marshalling the rooms and gathering the feedback and everything there's a lot of work that goes into these conferences so can we have a round of applause for all the people who make this happen so i'm gonna finish things off you're all tired it's been a long week you've got loads of information to process and so i'm just gonna basically share some very silly stuff there may accidentally be some lessons in there that you can learn i apologize uh but this is all about some some mistakes and the kind of mistakes that are made by software developers and engineers before i start content warning there is going to be swearing i am going to say [ __ ] quite a lot just in the next segment but it is relevant to the plot and so that is justified what i am not going to be talking about in this talk because it's light-hearted it's designed to make you laugh i'm not going to be talking about any situations where software errors have actually killed people but software errors have killed people okay so yeah but there's none of that in here this is all just it basically cost a lot of money for the most part or um cost me my job in in what some cases so yeah and this is me this was one of my biggest mistakes i worked for a software company and this was when i was in my 20s i was young i was arrogant i thought i was like a 10x developer and hot [ __ ] and all that sort of stuff and i worked at this company and also in my defense before we get into this i was already spiraling into what would eventually become a full-on nervous breakdown so i wasn't necessarily thinking straight our company we sold event management software and membership software and it was very complicated and you could build these huge complicated queries across the database and you could save those queries into a file so you could load them again the next day and those files had a med extension i can't even remember what it stood for but we called them med files and we released an update to the software and it corrupted when you saved the med file it corrupted it and so the support people came to me and they said and i quote mark the med files are [ __ ] can you write something to unfuck the med files and so i went into visual studio and i did file new project and i said what's the project name and i went oh um [ __ ] [Music] and so i created this little cons this little uh windows application uh windows forms application and it displayed a dialog box and it said choose file to unfuck and you clicked a button and it you went off and you browse and you chose your file and then it had a button that said unfuck now and then it ran it through its thing it did its thing and then it displayed a message box that said med file successfully unfucked close and it worked i thought it worked but you know support had a bunch of support were also qa it was that kind of company and so i gave the application which was called unfuck.xi to the support person who had reported this to me and i went can you test this out and make sure it works and then we can clean it up and send it to the customer i don't know if he tested it i can't imagine that he did because then without coming back to me he shipped it to the customer and they ran it and yeah it doesn't look particular these are the kinds of customers who are paying you half a million pounds a year on a sort of support subscription basis and we send them a file called unfuck.exe that says your file has been unfucked and at the time i was in such a bad place mentally i blamed the support guy for this because i obviously got hauled across the coals for this and i blamed the support guy for shipping the thing whereas obviously it was actually my fault i should never have created a program called unfuck.exe that was just not a good idea it's okay to swear in comments um as long as you're never going to open source things but but don't actually put unfuck on a slightly related note by the way when i very early in my career did anyone any windows 3.1 veterans in the room so windows 3.1 it was a file called win.com and every message uh and every piece of text that could be displayed in windows was embedded in wind.com just as text and if you used a hex editor you could open it up interesting trivia the phrase general protection fault has one more character than the phrase mongolian [ __ ] and so if you put two spaces in the middle you can edit someone's win.com file and then you can run away and then the next time that happens they will get a message box that says a mongolian cluster [ __ ] has occurred which has caused your application to terminate one of the worst things about windows 11 is you can't do that anymore okay let's talk about y2k everyone knows about y2k um that was probably one of the biggest mistakes in software but it wasn't that we let that happen in the first place it was really to do with how slow we were in fixing it because what you have to understand about the people who wrote the code that then caused the y2k problem was that this is what data was stored on at the time punch cards so every column on there is basically a byte of information and so those extra two digits on the year would have been an extra two columns on there multiply that by a million bank customers and a hundred million transactions a day and those extra two columns add up to a lot of extra punch cards and memory in those days this was what memory looked like in those days this isn't under a microscope this is just a photograph that is core memory and it's lots of magnetic poles and through each pole two pieces of wire have been passed these were made by usually women with microscopes and needles memory in the 1950s was knitted and core memory cost about a dollar a bit so a bite of memory would cost you eight dollars you think like that means a kilobyte of memory would cost you eight thousand dollars so memory was was really at a premium and uh this is also incidentally why uh unix still says core dump to this day it's because it was the core memory that was being dumped and of course in those days it was just a kilobyte and it was quite easy to read through so early programming languages like cobol they didn't think in bytes they thought in bits and so this is the uh definition for a date variable um and we say this is a it's a a string type variable but the nine means it's a number character and so it can only be naught to nine or some of the other like hyphen and comma and dot and things like that so that would fit in six bits instead of eight bits which meant you saved a couple of dollars every time you were putting one of these things into memory so it was quite reasonable to shorten the date and only use the the sort of decade and the year this is um i've forgotten his name uh bob beamer and bob beamer in 1954 was the guy going i i realized we have to do this but as soon as memory becomes cheaper we really should change that to a pick eight pick nine eight because this is going to cause a problem 1954 he said that in 1964 he started saying it with a little bit more emphasis in 1974 he started shouting about it in 1984 he was giving talks at conferences going guys we really really need to fix this in 1994 after bob bemer had retired we actually started work on fixing it and by that time all this software had carried on you so you wrote new bits of this software and you carried on using that and so the effort to stop the y2k bug from happening was ridiculous and it took an awful lot of people an awful lot of time but we did it and then the year 2000 came and there were very few big computer crashes and no airplanes fell out of the sky and all this sort of stuff and the whole of the rest of the world went well that y2k thing was a lot of nonsense wasn't it what a fuss and people like me who'd rewritten cobol systems in infamyx4gl to fix this when no you're welcome yeah it's it's like yeah yeah no it's thanks to me your hospital still works but no bob beamer uh died in 2004 um so he did actually get to see the the problem being fixed but the estimated cost of fixing the y2k bug goes from some people say 300 million dollars some people say 800 no 300 billion dollars some people say 800 billion dollars so let's put it somewhere in the middle we'll say it cost half a trillion dollars to fix the y2k bug and you'd think we'd learn from that and we wouldn't set ourselves up for any other y2k bugs particularly if you're like one of the biggest software engineering companies in the world you wouldn't put something into say your flagship email server that was going to break at a no no no microsoft this happened this year a thing that microsoft was storing in an integer ticked over uh i don't know what exactly what the number was but suddenly we couldn't convert this number to a long uh because it was too big and exchange servers all over the world including office 365 just choked and died and microsoft had to hurriedly roll out a fix for that in the year 2038 there's the apocalypse is coming eunuch still stores the system date and time as the number of seconds since uh january the 1st 1970 um in a signed 32-bit integer and that's going to crash in 2038 and you'd think well that's an easy fix change it to a 64-bit integer but no they've patched it with an extra bit so now they've got a 33-bit integer which kicks the can down the road until like the year 42 something but you know linux gonna linux my favorite one of these though is the dog 38 bug that the kennel club of the united states of america have so the kennel club um your dogs are categorized by their pedigree breed and then your dog has a name and it's one of those big long show names like like i have a pedigree dog and her i can't remember her show name it's got something sugar cookie something something um and so uh if they already have a dog with that name which is obviously a big country 300 million people lots of dogs it happens and so they they number them and so yeah one two three four five six blah blah thirty-seven and if you go to i had a dog and there were already 37 dogs of that breed with that name and so this is dog number 38 it crashes because it can't write the number into the database see if you can anyone guess how they're writing the number into the database that would cause 37 and all the numbers up to 37 to be okay and 38 suddenly crashes roman numerals they store the roman numerals in a char 6 field and every number up to 38 so 38 is xxx v uh 37 sorry is x xx viii um all the numbers before that fit in fine but 38 is xxx v i i i and this one i really don't understand it's going to the database change it to a char 8 or you know god forbid an integer and just format someone just went i i can't write the algorithm to format a number as roman numerables let's just store it as roman numerals so yeah that's fun um i would like to thank standupmaths on youtube great channel and i found that one on there as i was writing this talk so that was interesting a lot of this actually comes down to one of our biggest mistakes in program which is just enterprise programming generally enterprise software it's just you know the the processes and the procedures and the waterfall and the project planning five years in advance and all this sort of stuff and it causes problems and you can see the kinds of problems that it causes um so yes enterprise a business plan or project especially one that is difficult or may fail or lose money and everything in enterprise development is based around this it's nothing to do with building good software it's nothing to do with working efficiently it's all to do with covering your ass so that when the thing goes wrong at the end of the day you still get paid because you can prove it was somebody else's fault which is why you get agile development uh posters that look like this this is the scaled agile framework for enterprise this is the simplified version there are worse versions than this and you get things like this autoscrum 1.1 which is accentures this is still claiming to be agile this is accenture's agile framework that they use and somewhere in there we have a program backlog we've got us oh yeah we do we have a sprint right down there there's a daily scrum um and i think i think they've allocated some time for people to write code i'm not sure people have probably seen this this is deloitte's agile landscape version three the terrifying thing with this is that this and this are just single dots on this and and we wonder why so many enterprise projects fail quick story about enterprise i worked uh i was hired by one of the national um agencies the the quangos as we call them quasi-autonomous non-governmental agency organization um in the uk they had and then an api endpoint only had one thing and it just returned uh a list of the amount of energy that was being used in the uk right at that second and that is very useful information if you're investing in energy futures you want to watch those patterns and so people just kept hitting it and hitting it and hitting it it didn't have ip throttling it didn't have any accounts or anything like that it was an anonymous end point and you hit it and it did a quite complicated database query against an oracle database and did people put a thread.sleep10 or a task.delay10 in between no no no no they just get it hit it again hit it again um they had this running on one 32-bit server it was written in net 2.0 i had been brought in to look at this in 2014 and uh yeah it was 32bit.net so it didn't have much memory the oracle database was also 32-bit running on an old server the servers had been there since like 2005. so they were well past their death um time and uh yeah they said can you take a look at this code and tell me what's wrong with it and tell us how to fix it and i went i could just fix it and they went no no no don't fix it we give you two weeks to write a 20-page document telling us how to fix it and so i took it back to the office and i loaded it into visual studio and resharper actually started crying um and then uninstalled itself and when no you're on your own just just don't and basically i don't i don't do planning i don't do documentation i don't do that sort of thing i'm getting better at it now as i get older and more responsible but back in those days come back what i'm going to do i'll fix it and then i'll just write down what i did to fix it and actually the main thing i did to fix it was where they said var connection equals oracle database connection new oracle db connection i just added using because they weren't disposing their their database connections so it crashed every 20 minutes because they exhausted memory and the app pool had to recycle um and so i managed to write 20 pages on why using statements are important sent it back to them didn't hear anything from them for nine months and then they came back to me and and they said can you come in for a meeting to discuss your findings i'm kind of like you haven't done it yet so i go off and my boss goes up and um i'm he's charging them 2 000 pounds for me to be there for the day lord knows what you charged for him to be there for the day i'm guessing about 5 000 pounds we get there there's 10 ibm consultants sitting around this table and i know that ibm consultants are about 10 000 pounds a day so this is a hundred thousand pound meeting that's happening right here and and i go look i've actually if i can give you the code i've brought it on a usb if you want the fixed version of the code it's here and i would recommend running it on in 64-bit on a server that isn't 10 years old but this will probably still work even if you don't do that and they went yes we can't just go in willy-nilly and fix it and put it on new servers this is a critical system yes it's a critical system that crashes every 20 minutes and is is costing you an absolute fortune um and just just buy a new server just put it on a new server and it will be better but give it 64 bits and give it like 16 gigs of ram and it will run smoother well we can't just you know that has to go through a whole process and i'm like this meeting is costing a hundred thousand pounds and for a hundred thousand pounds you could buy a data center and run this thing on a server farm and it would be fine and my boss went uh mark why don't you go outside and get some fresh air and so i go out and i wait by his car and he's kind of i'm just uh i'm in so much trouble i'm gonna get sacked again um and i'm smoking a cigarette because i smoked at the time um and he comes out and i'm like i'm really really really so anywhere no don't worry about it i'll turn the [ __ ] off we don't need that [ __ ] he said okay this was a fun one so problems in software they're easy to fix so you've pat you shipped some software that doesn't work and they are it doesn't work and you go here's a new version of the software intel managed to get a software bug into their processor so the pentium chip was the first intel processor that actually had a floating point unit built into it before that we had the 486 and there was a 487 coprocessor that did floating point but intel had combined it into the actual chip itself and the pentium floating point unit accelerated floating point operations there you go that's what it looked like so what is four million one hundred and ninety five thousand eight hundred and thirty five divided by three million one hundred and forty five thousand seven hundred twenty seven it's one point three three three eight two except according to the intel pentium's floating point accelerator it's 1.33374 and there were a few instances where this would go wrong and people noticed and intel went okay if you can prove that you are actually affected by this bug we will just send you a new intel pentium processor where it is fixed and then so many people came up with these torturous this is why it's not working for me which were largely to do with microsoft excel and so intel ended up going fine just if you've bought a pentium we'll send you another pentium and that ended up costing intel 475 million dollars to fix i'm not sure anything like it's happened since i would imagine they probably run every possible floating point calculation as part of their unit tests null this is quite famous um null and we actually have a fairly easy value to assign to null because tony hawe who was the guy who invented null has called it his billion dollar mistake so tony haw he's a british computer scientist hugely respected he's like a knight or a kbe or something of the british empire um and he was working on al gold w and our goal w was the first uh programming language that introduced the concept of records what we think of as like classes or structs or whatever and so you had a record that was a person which had these things in here and so when you've got records you need references to where that record is held because now it's a collection of data stored on a heap and so you see here person has a reference to another person which is their father mother youngest offspring or elder sibling and so where you've got references what do you do if there is no father mother youngest offspring or elder sibling and so tony hall went well we'll just call that null and so we say if p equals null then m otherwise if m equals null then p otherwise do something with p and m and and we'll return that back um and at the time that probably seemed perfectly reasonable but ever since then uh hands up who has not ever had a null reference exception in net or java or any language they've ever programmed in or um or javascript undefined does not have a method index of or whatever it is javascript says so yes and tony hawk calls that his billion dollar mistake and and will quite happily tell you all about it there's a video on youtube of him doing a one-hour talk at a conference about how null happened and why it was a bad idea hartford center sometimes software problems actually cause other problems in the real world so the hartford center was built in the 1970s and it was one of the first buildings that was uh designed using a software cad package a computer-aided design package and back in those days there was no autocad there weren't these high-level things a cad package the engineer and architect using it would actually program in the algorithms the formulas for the stresses on various beams and all this sort of thing and they built the hartford center and it was fine but the hartford center i think it's in connecticut it's somewhere in the united states it snows it snows a lot and the hartford center was fine until one night it snowed a lot and this happened fortunately no one was in the building at the time there had been a concert and everybody had left the building about four hours before this actually happened and the problem was that they put in the calculations for the beams on how much the stresses on them were going to be but what they didn't account for was the roof is slanted like this and you people in scandinavia you'll know what happens to snow when it lands on a roof it kind of evenly distributes itself like this and then it warms up a bit and it goes and they hadn't accounted for the horizontal tolerances on these beams and so it did that and a beam sheared sideways and then that being sheared sideways and then the entire roof collapsed just because of one error in programming a cad package that cost them 90 million dollars to put a new roof on the hartford center that's not too bad this one's fun night capital i like this one because night capital are a hedge fund and i don't like hedge funds although if you work for a hedge fund and you need some consultancy i will happily come and consult for you and my rates are very reasonable by hedge fund standards certainly compared to night capital what you have to understand about hedge funds is the stock market the first stock market was created by the dutch east india company they needed to raise money to build ships to go to india to steal stuff and bring it back to europe to sell it and so the way they did this was they said we'll sell shares in the expedition and we go and we steal the stuff and we bring it back here and then we sell it and then how you get your percentage of our profits that we make from doing that and then other people that's a brilliant way to raise money to start a company i'm gonna do that as well and then 400 years later somehow that had turned into highly optimized programs running in dark pools trading with each other at microsecond levels skimming fractions of a fraction of a cent off the top of the transaction to try and make rich people richer while the rest of us got poorer and this is what knight capital were doing and in 1996 this was all happening in these things called dark pulls so the hedge funds and the investment banks and everything created their own sort of shadowy stock markets where they could do this and the new york stock exchange went we are missing out on so much commission we're going to create our own light pull and so they did and they called it the retail liquidity program and so everybody had to scramble to get their algorithms and their programs that were running in the dark pools to run on the new york stock exchange's retail liquidity program and so night capital basically copied and pasted a bunch of code around the place and dragged in some modules and all this sort of stuff and threw it into this new retail liquidity program with about two weeks notice and and it went in there and it started running and within uh four minutes it had spent a billion dollars and when they deployed it it was running on eight servers and the deployment rolled out but it only worked on seven of the servers and the eighth server continued running this old um code that was the buggy code and so they went oh no it's spending too much money a fail safe that was supposed to trigger wasn't working because it came from a different system and the flag wasn't getting set and whatever was going on and they went well it must be um that this new code has got a bug in it so we'll roll it back and they said copy the code from the eighth server onto the other seven servers that'll fix it by 28 minutes past nine on the morning that this thing went live their algorithm had spent seven billion dollars and night capital didn't have seven billion dollars and the rule is you have to settle within 48 hours and so they had to uh essentially bail themselves out so they sold all their positions this entire seven billion dollars worth of positions to goldman sachs for 450 million dollars um 440 million dollars um so yeah uh and then the following year they were acquired in a hostile takeover by goldman sachs um who kind of went yeah you really shouldn't be allowed to do things that's fun i like it when hedge funds lose money how are we doing halfway through good stuff so bugs in space like pigs in space from the muppets but bugs in space um there have been lots of bugs in space and bugs in space are difficult because you can't sort of attach you can't go how is this going to work in space i know i'll go into space with my laptop and set a break you can't do that laptops don't do well in space for a start so yeah so just a few of these mariner 1 this was one of nasa's very first missions um and the computers in those very very basic and so programming was taking mathematical formula and turning them into machine code i don't think there was even assembly language really for these guys and so they would take the mathematical formula and literally kind of just go okay so that would be this and this and this and this is what mariner 1 would have looked like if it had ever made it to space but it didn't and it wasn't the programmer's fault it was the the mathematician's fault he gave the programmer a formula that had an r in it and it should have been the r on the left with a hyphen over the top of it and what the hyphen means is smoothed over a period of time so we sort of it's going to spike up here and down here and down here and but what we want is kind of the average over the previous like 20 samples of whatever this is but he just left out the hyphen and so they used r and so if you've got a value where it's supposed to be zero and kind of plus one or minus one is probably okay plus two minus two is probably okay but plus eight is a very bad idea indeed and you're not smooth eo so eight and then back down to zero and then minus eight and back up to zero it's probably okay that's probably normal but they thought what they were getting was the average smoothing and so when it came through as eight the guy in mission control went bang and hit the button that blew up the rocket on purpose so um yeah if anyone was in martin thwaites's uh talk on open telemetry or any talks about tracing or metrics or anything like that it's really important to make sure that the data your telemetry data is accurate um and that you're getting out the number that you think you're getting out because otherwise you blow up your spaceship and then you have to build another one for 18 million dollars in 1960s money which is closer to 80 million dollars today you think actually the the mars the mariner one mission um is credited that missing hyphen is credited with the creation the inspiration of software engineering as a discipline that was the point at which people went hey maybe we should do like what those engineers do when they build bridges and you know bridges have collapsed and stuff but that was when we kind of started applying engineering principles to building software which did not save the mars climate orbiter which had a similar experience although it did get most of the way to mars to be fair the rocket took off it got it into orbit it set its engines going and it got to mars and then it crashed into mars crashed into the surface of mars at a very very high velocity and there's there's still a scar that you can see from one of the other orbiters that went up there and the reason for this is incredibly simple it's because americans are stupid and americans insist on using inches instead of centimeters now nasa are not stupid nasa use centimeters for everything actually they use millimeters for everything so nasa is like millimeter scale stuff so they don't say um a centimeter they say 10 millimeters because they work with the european space agency they work with ross cosmos they work with the chinese they work with space agencies all over the world they work with suppliers all over the world you have to be using the same units and everyone on the mars orbiter mission was using the same units everyone was using millimeters and centimeters except lockheed martin lockheed martin we're using inches so to give you a visual idea if this is me at five centimeters tall then this is me at five inches tall it's quite a big difference inches are not centimeters and so when the mars climate orbiter arrived at mars its planned trajectory was that it should have gone into orbit at 226 kilometers above the surface of mars and what it actually did was go into orbit 57 kilometers above the surface of mars which meant it got caught in mars gravity and smashed into it so yes units are important it's one of the one of the good things about f sharp is the whole units of measure thing can we get that in in c sharp at 12 or something that's you know you're copying everything else from f sharp so so awesome having you in the room to say that okay um it's not just nasa though um so yes 327 million pounds dollars for the mars climate orbiter uh plus the 18 months that it takes the thing to get to mars and then kind of going that didn't work should build another one but the french the european space agency um has has problems with their own uh this is the ariane 5 launch um and ariane this is the first ever launch of ariane 5 and it was a mission called cluster it had four european space agency satellites on it and the the tests had all gone perfectly the the the pressure testing and everything and then it took off and it soared majestically into the sky and then some code that they had copied and pasted from the ariane 4 control software tried to write a 64-bit floating point number into a 16-bit uh integer variable and this caused the boosters on one side to adjust their vertical their horizontal thrust um a lot and so the boosters split off the rocket and that happened and uh yeah this was spectacular there's actually there's a talk kind of similar to this one by kevin henny where he goes into a lot more detail and he has the code and it's on youtube so you can track that down if you want to know exactly what happened there but basically they had they had seven variables that controlled the the flight path um to get into orbit and four of them were guarded so if you try to write the wrong kind into one wrong type of data into them you wouldn't be able to um the that one the the one there that caused that that wasn't guarded because guarding a variable uses quite a lot of something and they didn't think they could spare it and so yes spectacular ariane 5 though i mean you know since then ariane 5 has been an absolute workhorse and it's put so much stuff into orbit and it's going to have to keep doing it for quite a while because ariane 6 has just been delayed again enterprise half a billion dollars the ariane 5 disaster that's that's kind of probably exaggerated but um yeah it's it's sort of including missed missions and people saying oh no you're not launching our satellites we're going to take these to nasa you can sort off so yes um the big rewrite this was me um this is one another one of my mistakes uh same company with medford unfucker actually we had a product that was written in a language called gupta sequel windows and it was dying and i was can we rewrite it in net please i've just this i've got this new.net thing it's brilliant can we rewrite and they said yeah all right and so i started rewriting the entire application as a windows forms application um and they had four people working on the old application and me working on the new one and so they were adding features and doing all that and i was trying to catch up to them but i was i was getting there and it was okay and then 2005 2006 came along and microsoft released wpf and it was new and improved and i was going oh no it's a new thing windows forms is dead wpf is so much better and the binding works better and the design is lovely and all this sort of stuff it's a shiny thing i want the shiny thing and so i decided that i was going to throw out all the windows forms code and and replace it with wpf and that did actually cause me to have a nervous breakdown and take six months off work um and then when i got back to work they did a performance review and they gave me a five which was the worst you could get and i went why and they said well you just took six months off so yes um new and improved do not just go ah anything and rewrite everything because you think it looks cool um probably it only cost them a hundred thousand pounds in terms of what they'd paid me to achieve precisely nothing uh but it did also cost me my sanity um and the the main sort of thing i got out of it is i know not to do that again um recursion uh this is just a little bug bearer of mine um i happen to read something about recursion and how recursion is a better pattern than loops and i just it's a lie effectively recursion is loops it's just a different way of doing it so if you recurse in a normal application you will end up getting a stack overflow error because things go round and round in circles and every time it pushes something onto the stack until there's no room left on the stack and so to avoid this there is a thing called tail call elimination where the compiler recognizes that that's what you're doing and eliminates that tail call and make something happen in a different way so to avoid this stack overflow exception so if you look at this this will eventually cause a stack overflow because this is 32-bit x86.net framework doesn't do tail call elimination and so the jit just produces this code here uh which calls countdown and calls countdown so if you call this with a big enough number like in 32.max value you will get a stackoverflow exception with the 64-bit jit they introduce tail call elimination and so that produces this code and you can see l 0 0 l 0 0 14 jump l 0 0 0 7. so every time someone goes oh recursion is a far superior and computer sciencey and and functionally way of doing loops point out to them that that's a go-to and i can prove it's a go-to because there's the same code written with a go-to and yeah look there you go we've got jump shaw lw it's a little bit different um but it's uh one less instruction than the recursion version and we do our jump short l07 um at the end there and yeah so recursion can go jump in a lake as far as i'm concerned um i would like to thank andre ashmined on twitter for sharplab.io if you've never seen sharplab.io and you do c sharp development um it's brilliant you paste some c sharp code into it it'll show you the c sharp compilers sort of the c-sharp that it generates for your properties and async methods and the state machine and all this sort of stuff it'll show you the il that's generated and then it will show you the actual machine code that's generated by the jit it's fantastic javascript any javascript fans in the room are about to upset anybody because this this really was it was a mistake it was one of the biggest ones and the thing is it was netscape version two and somebody stuck their head around brendan ike's door and went brendan can you knock up a quick language that we can stick in the next version of our browser so that when you put the mouse over an image we can change it to a different image all right cheers how long a week cool and so a week later brendan goes back with scheme basically because if you need to implement a programming language in a week then you write a lisp because they're the easiest programming language to implement so hey we've got scheme to run in the browser and they went oh no no nobody does lisp anymore no we don't like all those parentheses you know what's really hot at the moment is that java thing why don't you make it look more like java and so rather than sort of patch the holes and the problems and everything else brendan made his scheme look like java which involves changing prefix operators to infix operators and that sort of stuff and the other thing was they wanted it to be possible so the kind of people who were just hand coding html and creating personal home pages could hand code some javascript to achieve these effects and so they put all sorts of things in there to try and help these developers like if you said if this thing is equal equal to this thing and they were two different types then javascript would go well what if i made them the same type and then come that would work wouldn't it yeah yeah yeah that would work and and we ended up with this absolute abomination of language but the biggest problem of all is that it shipped and then people started using it and they can't you can't fix it you can't fix double equals in javascript so we have triple equals and bang double equals and apart from anything else that's wrong so it's it's just it should be bang triple equals or i don't know but anyway i just think if someone had poked their head around brendan ike store and said hey brendan can you create the language that will be used for 90 of all programming over the next 50 years and run on everything from spacex shuttles to the internet to watches to smartphones to everything else how long brendan would probably have said oh two weeks what's a smartphone so yes here are some javascripty things um an empty array equals not an empty array according to type coercion no idea why that is but but those two things are the same i think it's that empty array becomes object which is not null therefore it's true and not empty array it coerces the array to zero which is the size of the array and then knots it so it becomes true so that's true equals true equals true who can spot what's wrong with this line of code or why it does what it does so in the middle here plus plus so because javascript does type coercion what it's actually trying to do here is b plus a plus and then we've got this plus floating here and it goes well i'm already here so this must mean plus a so we're doing the positive value of a i'll try and coerce a to a number so that i can oh no it's not a number so it becomes nan type of nan incidentally is number so not a number is a number um and then we add the other ray on to it and so b plus a plus plus a plus a is banana because of course it is um and douglas crockford wrote a book called javascript the good parts um have you ever seen the photograph of javascript the good parts next to javascript the definitive guide that's quite i took that photograph and i put that on twitter and this was like back in 2012 or something um and it got 45 000 likes and i was yeah i'm famous but yes the difference between javascript the good parts and javascript the definitive guide is basically the dom it's the document object model um that is the bad parts of javascript according to douglas crockford and he's kind of got a point because uh document.all which is all the elements in in the document is an instance of object but if you do type of document.all it tells you it's undefined so you go all right does document all equal equal equal undefined and it says no it doesn't and you go does this document.all equal equal equal null no it doesn't equal that either you go well if you type coerce it does it equal equal null and the dom go yeah yeah it does and they can't fix it there are there is code in the world that relies on that behavior um and so java i mean i don't know what the cost of javascript is but the fun we have with it is priceless and uh yeah i'm i'm just quite down with that um so i would like to have some honorable mentions here um heartbleed that popped up a few years ago this was a serious bug in openssl which essentially rendered the whole thing completely vulnerable to attack and of course openssl is used by everybody google microsoft amazon facebook apple everybody uses openssl and everyone was like how could this be allowed to happen and the you know that xkcd cartoon of the entire modern infrastructure of the world and a random open source project somebody in nebraska has been thanklessly maintaining since 1996. that was open ssl i was just like this one guy who was maintaining this thing that multi-trillion dollar companies were relying on and there was a bug in it and none of them had thought to kind of give this guy's code a read or check it out or anything like that and then this year we had log for j because it turns out that one of the things you can put into log for two is a log this log this call to another service and while you're logging this call to another service pass it some information again martin's thing earlier on about baggage and log4j was very so you could put something into a text field and then log for would log what you put into that text field except it was a uri that said execute a java enterprise b there's that word enterprise again on this other server and just pass it all the data that we've got attached to this log while we're at it and there is not a single java application in the world that is not using log4j um so so that was fun and then they fixed that one so i mean that wasn't in java it was in a library that every java application uses but it wasn't in java itself so java looked okay for literally two weeks and then somebody looked at java's actual in the box ecdsa implementation so ecdsa is a very complicated algorithm and it involves three numbers and one number is the result of a sum and the other number the other two numbers if you multiply the first number by the second number then it should equal the third number and so so that was fine but it turns out that you pass these three numbers along with your ecdsa token this might be a json web token or a saml token something that you've encrypted using the ecdsa algorithm and if you pass it in and so you've got the numbers i think they were p um r and uh and q p and r and so it's like p times r equals q um and so if you set q to zero and r to zero then it did p times q and does that equal zero yes it does and so literally just by sending a malformed ec dsa signature with these two values set to zero you could get java to go yeah that's fine that was in the actual that's that's like the base class library that was in the jdk but that one came along that was fun so so we've seen some fun examples we've seen some very very expensive examples i would like to finish off with with one example where we basically got lucky that yeah programmers make all these mistakes we're fallible and we're sort of hubristic and we're arrogant and we do stupid things fortunately the rest of the world knows that and they don't trust us as far as they could spit a rat and so the soviet early warning system uh in 1985 was switched on and almost immediately reported that america had launched five missiles against the uh the ussr um it hadn't what the image recognition software running on i don't even know what kind of computers the soviet union had in 1985 i'm guessing they they probably involved rocks and and bits of elastic but um you know it wasn't great but when they've launched five it was actually the sunlight glinting off clouds but that was incorrectly identified as the rocket trail from intercontinental ballistic missiles and this man stanislav petrov lieutenant colonel stanislav petrov on the 26th of september sorry 1983 not 1985 was told that five missiles were inbound to the soviet union from the united states and he should immediately launch the soviet union's response he should immediately launch what turned out to be all four of their intercontinental ballistic missiles and if he had done that then the american early warning system would have seen those and america would have launched all the minutemen missiles that eisenhower had built because he thought that the russians had 4 000 icbms they didn't they had four but he thought they had four thousand so america had five thousand and they would have launched all of them and that would have been game over humanity most life on this planet and then in another fifty 000 years maybe there'd be a building here with a software conference with highly evolved cockroaches talking about programming's greatest mistakes but stanislav petrov said nah i don't believe that i'm not launching missiles based on what a computer says it can go stuff itself and so we did not get world war iii on september 26 1983 because there was a human between the computer and the missile launch system and thank god for that because that very nearly cost all known life in the universe and that's how serious some of this stuff is so yeah think about that as you go back to work tomorrow or next week and maybe just be a little bit more careful thank you very much for listening to me and i will see you next time you

from
Talks
added
2026-10-10
likes
0

similar

  1. Programming is Writing is Programming youtube.com
  2. Being The Human in the Loop youtube.com
  3. Hey Underscore, You're Doing It Wrong! youtube.com
  4. Effective Programs - 10 Years of Clojure youtube.com
  5. Rethinking Software Development - Insights From 20+ Years In The Field youtube.com
  6. Programming is terrible - Lessons learned from a life wasted youtube.com

Talks › Categories > Software Development: “by Mark Rendle (NDC Copenhagen 2022) [55:34]”