The Art of Code

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

24:38 "There're no dogs here"

"I don't care, find me the dogs"

👍︎︎ 3 👤︎︎ u/lawrencelewillows 📅︎︎ Feb 15 2020 🗫︎ replies

Awesome talk.

👍︎︎ 5 👤︎︎ u/Asgeir 📅︎︎ Dec 25 2019 🗫︎ replies

It was great. The end alone is worth the wait, but the whole talk is great.

👍︎︎ 3 👤︎︎ u/RufusROFLpunch 📅︎︎ Dec 24 2019 🗫︎ replies

This is so interesting, especially the part he starts to play a guitar.

👍︎︎ 1 👤︎︎ u/_okdalto 📅︎︎ Dec 25 2019 🗫︎ replies
Captions
my name is Dylan BT and the first computer I ever had of one of these this was the Amstrad six one to eight it was 1985 I was 7 years old my dad brought one of these home and he put it in the spare room in our house this was not a very good computer and it was all right for 1985 it had a green screen it came with a couple of very very dodgy games like a chess game that I could beat even though I was seven and a game where you had to throw soap at ghosts sued invaded a launderette but it also came with a thing called logoed has anyone used logo the programming language and logo was brilliant because I could use logo to make the computer draw pictures and it seems weird now like you know 1 2019 you wanna see something on a screen it's easy you get your phone out and you type in anything you want and there'll be pictures and video of that online that you can just download and play and share with people but back then just getting something on a screen that wasn't there before was a big deal you know you've got this 7 years old I was digging through these programmers manuals and the logo programming manual was not written for seven year olds so I would be sat there working out with all these words mean and trying things out and when I made the computer do what I wanted and draw this picture I got this rush this thrill it was brilliant and that's never gone away for me and I hope for many of you as well that that thrill that you get when you make the Machine do what you want like we failed to do with the a/v there for about 10 minutes now over the next three days you're gonna see some amazing talks by some brilliant speakers about architecture and unit testing and user interface and experience design things that are important and useful and lucrative if you can sell them to the right people that helped to make software better in terms of as a tool for the world we live in but I'm not gonna talk to you about that I want to talk to you about something that I think is important but maybe not as useful as the other things I wanna talk to you about art now there is this famous quote from Oscar Wilde he said all art is quite useless and maybe it is maybe all of you being here is a total waste of your time and everything I'm going to tell you is pointless and you should have gone to another talk or maybe Oscar Wilde was wrong I like this quote the function of art is to hold a mirror up to nature art can help us understand the world that we live in better and if we want to hold a mirror up to nature before we can do that we have to invent the mirror and that's where science and technology come in because for hundreds of years we've used science and technology and tools to see the world around us in different ways we had no idea until we invented microscopes that there was this amazing microscopic world hidden right underneath our noses things like this which is the eyelid of a beetle at 200 times magnification this is crystals growing in a dish of soy sauce this is the vessels inside the stem of a banana leaf this amazing beauty we had never ever seen until we built the tools to allow us to see it and we've sent telescopes and satellites into outer space we've looked back at our planet rising over the surface of the Moon we've looked back from beyond the rings of Saturn and seen our pale blue dot down here in the distance we've even looked into the farthest corners of the galaxy these are the pillars of creation they're seven thousand light years away and we put a telescope in space that took a photograph of them and sent it back to us and thanks to modern computers we have been able to start exploring another secret world that's hidden right here under our noses it's a world of information and mathematics throughout the 1970s a guy called Martin Gardner had a monthly column in Scientific American magazine where he'd share mathematical puzzles and curiosities and games with all of his readers of all the columns that he published the one that had the greatest impact was from october 1970 where he described something called John Conway's Game of Life now the game of life as games go it is not much of a game it is a game for one player played on an infinite board and it has only three rules the first rule of the game of life each of these little rectangular cells can live it can die it can be born again if a cell has zero or one neighbors it dies of loneliness ah if a cell has two or three neighbors it survives into the next generation and if a cell has four or more neighbors it will die of overcrowding it's a bit like living in London and finally the slightly weird spooky bit if a cell has exactly three neighbors it will come back to life and that's it that is the entire rules of Conway's Game of Life now when Martin Gardner's column was first published he included this diagram here he says these are the life histories of the five tetrominoes so these these shapes here you probably recognize those if you've ever played Tetris and what he's doing is he's plotting out how those shapes evolve over a couple of generations but looking at it like this on paper is like gonna a museum and looking at the butterflies pinned up in the glass case you can kind of see what they are but you have no idea what that like you don't get any sense of the nature of the the evolution of the game of life so those five tetrominoes let's see what they actually do watch this and so from those five shapes and those three rules we get this four of them stabilized but one of them goes into this infinite looping repeating pattern that we call traffic lights and you can understand that using graph paper but instead you start running the stuff on software you don't really understand you can't visualize what's really going on here even back in the earliest days of doing the stuff on on graph paper people started identifying some configurations which were interesting for all kinds of reasons one of the earliest configurations they found was found by a guy called Bill Gosper in the early 70s and it's something called a glider and the glider is a little shape that just crawls across the grid as it goes every five or six generations it repeats itself one squared down and left and these things keep gliding across this infinite grid of mathematical space and people started asking questions like will other configurations in the game of life that will just grow infinitely are there configurations that are stable can things switch on and off they started playing around with gliders once people started using computers to model as stuff they found all sorts of amazing configurations all generated from these same three rules this entire fleet of what we call spaceships these wonderful bizarre shapes that just crawl across this mathematical space in the mid 70s gospel and his team discovered something really cool they were playing around with this idea of gliders and they created the first thing what we call a glider gun now the glider gun is a stable configuration and every 27 generations it gives birth to another glider and then repeats itself and it keeps going round and round and round firing the stream of gliders across the grid they discovered another pattern which is a thing called the eater this thing will consume gliders without destroying itself in the process now on the one hand this is very cool and very pretty on the other hand we've discovered a way to generate signals and a way to destroy signals we've created truth and false one and zero yes and no off and on and if we have 1 and 0 we have binary logic right the question is can you use the game of life to actually build circuits so have a look at this this is an and gate here are two inputs a and B and this down here is a and this is our output now what do they do by switching these little eater configurations on and off we're gonna get rid of that one and now a is true one of our inputs is true but our output still false we're gonna switch on B now B is true but when the pattern stabilizes our output is still false if we turn both of those inputs now to be true by removing both of those blockers and we run our circuit again we've created a logic gate we've implemented a NAND gate within the game of life and if we can build logic gates we can build circuits and if we can build circuits we can build computers and if we can build computers we can run programs on them including this program that you might recently have heard about it's a thing called Conway's Game of Life and it's a simple cellular automaton based on these three very very simple rules that can lead to the most fascinatingly complex behavior and patterns just from those three simple rules now Conway's Game of Life is one of a whole category of systems that start with very very simple rules and go on to exhibit incredibly complex behavior you've probably heard of something called the butterfly effect this idea that long-range weather forecasting is impossible because of her butterfly flaps its wings in Beijing next week we're gonna have hurricanes in Los Angeles instead of sunshine and all of this is to do with the study of systems that have simple inputs and complex outputs very sensitive dependencies on initial conditions the study of these kinds of systems has become known as chaos theory and it has all sorts of applications people use chaos theory to study stock market prices economics weather forecasting engineering but it's also given rise to a whole new field of digital computerized art now to understand what we call fractals and fractal geometry you've got to get your head around some really weird maths so here's a piece of graph paper and we're gonna draw a square here which is 2x2 and you want to tell me what the area of that square is for now we're gonna draw another square this one is minus 2 by minus 2 what's the area of that square 4 so if 2 times 2 is 4 and minus 2 times minus 2 is 4 how can we get a square whose area is minus 4 well we can't it's completely impossible and at this point physics and engineering goes well yes impossible let's get on with everything but mathematicians go well hang on what if it was possible what if we just make something up what if we say all right we accept that it doesn't exist so we're gonna take the impossible thing we're gonna scribble on our chalkboards here and we're gonna come up with this number I which we're gonna call I for imaginary because it's not real and it doesn't exist and it can't exist and we proved it can't exist so let's play with it anyway because hey mathematics and this is the rule we say I is the number that if you multiply it by itself you get minus 1 everyone goes that's impossible and we go yes maths we don't care impossible as we did that before breakfast now when you take these what we call imaginary numbers and you mix them up a little bit with real numbers you get what we call complex numbers now a complex number is like a project plan some of it is real some of it is imaginary and you have no idea what is gonna happen next but we can do arithmetic with these numbers just by following the rules so we take this number here this is no point 8 of real stuff and 1.2 of imaginary stuff and we can plot this on this graph here it's a thing called an Argand diagram and we can actually do equations with these so let's say we take this number point eight plus one point two I and we want to just multiply this number by itself and see what we get now I've syntax I've color-coded the numbers here the real parts are red the imaginary parts of blue and this is basically highschool arithmetic with with imaginary stuff in it we're just going to expand that out and we can multiply all these terms together and all you remember is anytime two blue numbers get multiplied you take the eyes off and the whole thing becomes positive negative negative square root of negative numbers and so you expand the thing out and then you can go through you can simplify it back down you add the red bits together add the blue bits together and you get an answer at the other end the arithmetic is not that complicated now for most of history mathematics has been obsessed with solving problems if you can't solve a problem it's not interesting but during the last century and particularly the last decade or so a group of scientists and mathematicians started studying systems where they weren't interested in solving it they were interested in seeing how it behaved take a function here we're gonna take some number X and every time we're just gonna do X maps onto X plus 1 so we start at 0 and we go to 1 & 2 & 3 and you can see almost immediately how this is gonna behave this is really gonna keep counting up to infinity right let's take another one X goes to 2 minus X so we're gonna start off here with 2 minus 0 is 2 2 minus 2 0 2 minus 0 is 2 so within 2 or 3 generations we're confident we just have this stable looping repeating cycle we understand the behavior of the system and we can predict what it's gonna do 200 generations from now let's try the same thing with a complex number so we're gonna take this number here 0.7 plus 0.8 I and we're just gonna square it and the first time we square it it goes to there and we square it again and it goes to here and then it goes to here and then it goes to here and then it goes flying off into by the way there are four different flavors of infinity on this graph so we've got the imaginary positive infinity the imaginary negative infinity and then we've got real positive and negative infinity but that's fine don't worry about it we're not gonna go there yeah let's move that point ever so slightly and run the same procedure over and over again now this time it's gonna jump to here and then here and then here and then here and then here and then there now the previous one it vanished by this point it gone off to infinity is never coming back this one kind of bounces around for a little while then it does this it goes into this sort of weird almost like a circular pattern for a couple of generations we cannot predict what its gonna do next and if we take a bunch of points that are almost next to each other and we plot in different colors their eventual behavior we get radically different behavior from starting points that are almost next to one another in this scenario the blue line that pale blue on here does one two three and then it goes vanishing off to positive infinity the green one here goes disappearing off the bottom and then at some point it comes back in on the top and goes has another go around the red one is the loop we just looked at now a pair of French mathematicians around 1910 started studying these kinds of shapes the iteration of complex systems and they won a medal for it Gaston Julia and Pierre fatou were their names and Julia want a medal for the work they did on that but they had to do everything by hand during one of these lines could take them a couple of hours using you know graph paper and pencils and stuff so they never really understood what it was that they had discovered we didn't discover that until this guy comes along sky called Benoit Mandelbrot he was a Polish mathematician his family lived in France then he moved to the US swear he did most of his work he had an awesome job he worked for IBM so he had access to computers at a time when most of the world had never seen a computer and when he got bored he'd go to Harvard and he'd teach mathematics for a semester and then he'd go back to IBM with all these new ideas and he was fascinated by the mathematics of reality he had this quote which kind of summarizes his philosophy clouds are not spheres mountains or not cones coastlines are not circles bark is not smooth nor does lightning travel in a straight line he looked at the jaggedness and the fractured nature of the shapes that are all around us and he wanted to understand the mathematics that made those kinds of shapes possible now his name has gone down in history because of something that he discovered using Julia and Fatt whose work on complex systems and ibm's computers in the late 1970's and his idea let's start with this this complex grid of numbers and we're going to take some starting point here and all we're gonna do is win a square it and then add the number we started with and square it and add the number we started with and we're gonna go round and round and round and round with that now his approach here was we're going to run this a bunch of times say a hundred times and if that number disappears off to infinity and it's not coming back then we leave it blank and if after a hundred iterations it's still on our grid then now we didn't he didn't really have graphical capabilities so what he said was well we'll just plot an asterisk there on a line printer to give us some idea which of these points in our grid are still gonna belong to the set and which ones are gonna disappear and sometime in 1980 he and his team became the first people ever to see this this is a photograph of the original rendition of the Mandelbrot set now computers got better they got faster we invented graphics we invented colors and the standard algorithm that some of you here may have played around with is you take the same approach Z goes to Z squared plus said you go round and round and round and just depending how fast it disappears you color it in in different colors if it goes vanishing off to infinity really really quickly it's blue if it takes a little while to get there it's purple if it's really slow to get there it's red and if it never disappears you color it in black that's the basic algorithm that we use to draw the Mandelbrot set now the first time I ever did this was on a 286 PC and I had to start it running go to school and when I came back and it kind of drawn this level of detail but we have better computers now which means we can see it in this level of detail now the astonishing thing about this set that one equation Z goes to Z squared plus Z contains a literally infinite level of detail we're gonna start here this is the Mandelbrot set how BIG's that screen to 3 meters across do you reckon so let's say that now we're at 1 times magnification and we're gonna keep zooming in and in and in and and when we get to about here the original set we started with is probably the size of the radisson hotel and there's still all this detail to zoom in to get a little bigger by the time we get to a bat here the set we started with is the size of Vilnius and we have more detail and we keep zooming in and we get to around about here the original one is now bigger than Lithuania and we have more detail around the bat now it's probably bigger than Europe sometime around now the original one is probably the size of the solar system it just keeps growing now we're stopping here not because we've run out of detail there's an infinity of detail at every single one of these tiny little points and that original graph is now so big that if we start here in a 747 and fly towards the edge it's going to take us a thousand billion years to get there and all of this complexity came out of Z is Z squared plus Z but there's more to it than that I think because this this thing the Mandelbrot set somebody has called it the thumbprint of God now I'm not a spiritual man at all but I do play a lot of computer games and I like that thing you get in a game where you go off and you do I'm crazy that you're not sure whether it's part of the quest or not and you find something there that was put there that says you're on the right track we left this here for you to find it and for us to see this first of all we had to invent mathematics then we had to invent imaginary numbers and work out how to do equations with them we had to invent computers which is basically putting lightning inside a rock until it learns how to think we had to come up with these algorithms we had to build the rendering systems to do it and we did all that and we found this hidden there and I think that is really cool now computer graphics is not actually that big a deal anymore 1982 Disney came out with the movie Tron which Tron was disqualified from the Academy Awards for cheating because they said you couldn't use computers to make films it wasn't in keeping with the spirit of special effects that's right they gave it a Lifetime Achievement Award later they sort of saw the error of their ways but you know computer-generated imagery now luxo jr. 1985-86 was the first fully computer animated film we had Jurassic Park which were the first computer animated characters interacting alongside human actors a few years ago this guy appeared on our screens and if you want to argue is this the actor Peter Cushing who's dead or the fictional character grand moff tarkin who's not dead well Lucas films lawyers would be very very happy to talk to you but we have computers now that can recreate just about anything we can bring anything we can imagine to life we can say you know hey Siri what would it look like if friends was remade with Nicolas Cage playing all the parts and computers just go in and do it now like yeah we can do that that's fine now the reason we can do stuff like that is because we have created computers that can learn computers that can recognize shapes computers that can see things now you lie on your back in a field on a sunny day and you're watching the clouds you know is a cat that one looks like a rabbit no one looks like an airplane and your brain is seeing all of these shapes they're not really they're they're just clouds of vapor floating through the sky and we've started training computers to work in a similar way we've built something called a convolutional neural network and what it does we don't really know how they work but what we know is if you feed enough photos of say cats and dogs through the whole thing you end up with a network that knows how to recognize cats and dogs and within certain you know problem spaces they actually work pretty well now you might think well hey you know how hard can it be to tell the difference between a puppy and a muffin well it's often harder than you think you know but we've built very very sophisticated dog detectors into our computers that can look at this and be like is that a nose or a blueberry hang on let me look at my nose database and stuff so we've basically built digital dog detectors now the fun happens if you take your dog detector and you reverse the polarity and you say right you're a dog amplifier now and you give it a picture and the computer says there's no dogs in this picture and you go I don't care find the dogs and when you find them enhance the dogs and a computer goes this is a horrible idea but all right you're the human here and you go enhance and it comes out with these really weird psychedelic images now this kind of category of art is called deep dreaming deep dream was the first program at - three years ago came out of Google that allowed us to do this and stuff like this it's unsettling to look at isn't it because you're looking at it and what's happening is that some parts of your brain is going dog dog dog dog and then you look closer like that's not a dog I don't know what that is but I don't like it what is dog not a dog I honestly and because it's exploiting the same kind of pattern recognition things that exist in our brains in an in the neural networks and thanks to that we've got this entire new category of art that never existed until someone when what if we turned the dog detector backwards and start inventing dogs where there were no dogs to begin with now I think computers and technology are gonna do astonishing things for the whole field of art [Music] [Applause] [Music] [Applause] it's a demo of a thing come out of Google called tilt brush which is basically or meant augmented reality painting in 3d and I think computers technology augmented reality virtual reality some people are gonna use it to do brilliant things some people are gonna do it to you do not so brilliant things some people are just gotta see what they can make it do for the thrill of going look the computer did what I want isn't that cool but I want to move on now let's stop talking about using computers to make art and I want to talk about programming as an art in itself what if the code was an art form now this is Donald Knuth's famous the art of computer programming and we have these ongoing debates what is programming is that is it art is it creative are their software factories are we engineers you know what kind of thing is it and I'm sure some of you have reviewed code that maybe somebody on your team wrote late at night when they were tired and you've looked at that code and you've gone this is not art it's not engineering I wouldn't call it craft in fact I don't know what I'd call it but the good news is there is a safe outlet a safe space for that kind of code and it is obfuscated coding competitions these are the goals of the International obfuscated C code contest to write the most obscure program to show the importance of programming style in an ironic way to stress compilers with unusual code to illustrate the subtleties of the C language and to provide a safe forum for poor C code here is a submission from 2015 this is the entire source code for this program anyone want to review this code tell me what it does let's run it because what the hell why read when you can just compile and hope it's not a virus hey oh there it is look at that it's flappy bird in ASCII on a terminal and even on a terminal it is still impossibly difficult let's have a look at another one so this is another C source code submission um this is just a subset of it if I show you the whole thing it'll give the game away a little bit but if you zoom out so this is a Mandelbrot set generator that runs in a UNIX terminal but it is the Mandelbrot set generator that is shaped like a Mandelbrot set and this won an award now one of the things about the obfuscated code competition is they try and keep the program small what can you accomplish in a like really small number of bytes this is 32 lines of JavaScript this if you copy and paste this and open it up in a web browser it plays chess and I don't mean it draws a chess board I mean it plays chess it beats me at chess it is an entire chess engine implemented in that much JavaScript including the graphics the board the rendering and all the logic of the game algorithm itself it's called nano chess by a guy called Oscar Toledo G who just keeps winning these programming competitions he's absolutely brilliant now in 1994 similar syncovich won an honorable mention in the obfuscated C contest for this program because he submitted it with instructions saying if you compile it using this specific compiler it will print its own source code because the compiler he was using had a feature where if you gave it the empty input this is a blank file if you gave it empty input it would give you a C code C program that didn't print anything now he got an honorable mention and they changed the rules and they said your program must be at least one character long otherwise it's just a copy of this one and that one already won which i think is fair you know but this gets us onto this this whole field of things called Queens now a coin is a computer program that prints its own source Queens some of you may have come across in this book girdle Escher and Bach the eternal golden braid by Douglas Hofstadter and he's in this book discusses a philosopher William ohm and von Quine an American philosopher who studied statements that refer to themselves and so we're gonna take this we're gonna spin it into software how hard can it be to write a program that prints its own source code and you're not allowed to read the source from disk that's cheating you have to actually print it so we're gonna do one now we're gonna we're gonna build a coin right here in c-sharp so I'm gonna start with this this class program and I'm gonna write line program and I'm gonna close my brackets down here and static void main I'm gonna close down here but now hang on because I need to console right line the class program but and and now I hang on so this I need to console the console that write the console and you very rapidly get tangled up in your logic now most languages have quirks that you can exploit to get them to print their own source code in C sure they're NC sure got net developers in the room good check this out what we can do is we can put the syntax of our program into a format string and then we can feed that format string into itself as the thing that should be printed where we've put these placeholders and we have a c-sharp program that prints its own source code in JavaScript this kind of thing is stupidly easy we just say function f prints f2 string if you're using ECMO script six this is a valid Quine now somebody told me this and I was like I do not believe you so I tried it and you put that in and you press GO and sure enough that function evaluates itself and prints its own source code and then I found something I think is really brilliant which is an HTML Quine glycol DeLeon BAM break came up with this idea it's a web page that prints its own source so we're gonna start with this HTML head title blah blah blah blah blah slash HTML and when we open this in a browser it looks like this now we're gonna exploit some quirks of the HTML specification here first of all we're going to put in a CSS rule that says display everything as a block even style and head and title and things that the browser is not supposed to display and we're gonna refresh it and look at that our CSS and our title are now appearing in the page code and the page rendered output now we're going to start exploiting some more CSS rules we're gonna say well the HTML element before one of those put this content and after it put this content and we refresh again and there we go we've grazed him on our slash HTML is actually here because it doesn't know where to draw it but it is there and if you could scroll down on the screen you'd see it now to put style around the style sheets we need to escape the slash style otherwise the parsers have a fight over who gets dibs on that bit and the HTML parser wins in the CSS break so we escape that that passes that through we're gonna put some white space formatting on there we refresh that page again we go round a couple of times because we need to define rules for each of these different elements and round and round and round we go now we've got this link here this a and that needs to show the href that that a actually links to so we can go in and see we say well before one of these please extract the attribute value and put that in the content and put that into the page and there we go a href equals yada yada yada and I'm just going to put in one more little rule I'm going to put a 1% height and a margin on the HTML and there we go slash HTML at the bottom we have a web page that prints its own source code beautiful and completely useless but how much did you learn about the CSS preprocessor that you didn't know until you tried to do that because I learned a hell of a lot doing that here is a computer program what language is this program written in C++ well I don't let's try it I'm gonna apply some syntax highlighting okay so I'm gonna apply a syntax highlight here so we gonna include standard IOH there's main char star this is a big string literal and then a printf yeah alright C C++ probably works on both I don't apply different syntax highlighter and an apply Ruby syntax highlighter and I'm gonna highlight the things that Ruby thinks the string literals and that's interesting because Ruby thinks this is a valid Ruby program so which is it I tell you what let's try running it so here's our poly Quincy source code there it is now I'm gonna feed that into GCC and I'm gonna run it we got a warning but hey the safety is off well before this point kids and look at that we run it ADA out and there we go this is our output from that program and now I'm gonna feed the output of that program into Ruby and see what route oh look there it is it's printed itself again and now just for the hell of it I'm gonna run the same thing in Python that's interesting because pythons basically Ruby anyway right and I'm gonna run it in Perl because I had to install Perl on my laptop just to make this demo work and it produces the same thing again this is what's called a poly Quine it's a program that is valid in more than one language and prints its own source code in all of them and this example runs in C Ruby pearl Python and C++ if you can find an old enough compiler because it complains about main not having a return type but we can do a hell of a lot more take a look at this chunk of code here now you're looking at this trying to figure out what language it's in it's like well we got a system console here and so that's probably dotnet or you know C C sharp something like that but this is an xml XSL transform namespace so i don't know what's going on there this is a for each in a console dot log which kind of smells a bit JavaScript C to me and this is a dot txt IO procedure which I'm guessing is is a DES I'm not familiar with it but I did look it up and then you know over here we've got begin in block capitals which means it's probably COBOL right any COBOL programmers in the room and then up here we've got act 1 scene 1 enter Ajax which doesn't look like programming at all this is your Sookie and O's or abhira Squier it is a computer program written in Ruby that produces a program in rust which produces a program in scala scheme said Shakespeare s Lang small talks were all the way around and eventually you get an RC program that produces a Rex program that produces the original ruby program back again the source code to this program is absolutely stunning look at this that's it with all this stuff at the bottom where it says buffer for future bug fixes so that they can maintain the exact shape of it and you know the most brilliant thing about this all 128 of those languages you can apt-get install on Ubuntu Linux and so there is a continuous integration pipe for this program on github that will run all of those programs and just contrast the time we started a little late so we're gonna overrun by a few minutes there's a break straight after this right yeah yeah cool all right otherwise I'd have to skip the good bits and I don't want all you to miss out now in this coin you notice among the COBOL and everything there was this weird Act one Scene one and two Ajax you know what's going on there well it turns out there is a programming language called Shakespeare which is designed for making programs that read like Shakespeare plays and the way Shakespeare works is that flattering things increment variables and insulting things decrement variables and so here is the infamous hello world program first of all we have to declare our variables by introducing them so we have Romeo a young man with a remarkable patience and Hamlet the flatterer of Anderson insulting a s act one Hamlet's insults and flattery scene one enter Hamlet and Romeo Hamlet says you lying stupid fatherless big smelly half-witted coward you are as stupid as the difference between a handsome rich brave hero and theyself speak your mind that will print H you are as brave as the sum of your fat little stuffed misused dusty old rotten codpiece and a beautiful fair warm peaceful sunny summer's day you are as healthy as the difference between the sum of the sweetest reddest rose and my father and yourself speak your mind E speak your mind speak your mind l l and then this final line here is O so this this little thing here prints the hallo in hello world now I like this because Shakespeare plays were not noted for being short and neither are Shakespeare programmes and Shakespeare's a lovely example of what we call esoteric languages Easter lands which are computer programs where the entire programming language is designed to be funny and beautiful and useless here is hallo world anyone know what language this is written in this is white space a language that ignores everything except spaces and tabs here is syntax highlighting for hello world in what space white space is a brilliant language for hiding programs inside other programs because you can put the spaces and tabs in a C program and the C compiler will ignore them and white space will ignore all the C code so you can write coins in white space really easily this is the hello world souffle in the programming language called chef now chef is designed for writing programs that are also recipes and the canonical hello world involves 72 grams of beans 101 eggs a hundred and eleven cups of oil a hundred grams of mustard and 33 potatoes now this prints hello world when you run it in chef but it doesn't look like a terribly appetizing recipe and a few years ago a guy called Mike worth created a recipe a hello world in chef that is also actually a cake and he baked it and you know I love this because he killed this video of this thing is a valid set of instructions in two completely disconnected domains if you run it in the chef interpreter it prints hello world and if you run it in your kitchen you get a chocolate cake with chocolate sauce that apparently was a little dry but really quite good and I love this idea of computer programs that also exist entirely independently as art in their own right let's have a look at how to square a number in the programming language called Pete there it is that's the program is a graphical programming language this is the instruction set every time the cursor the cursor starts here and it moves across this grid and when it travels between two colors that is an instruction from this set here variations in hue and variations in lightness this is our color palette light normal and dark and let's look at how that example actually works so we start there and when we cross from light blue to dark green that's a difference of two in the but the brightness four in the hue input a number reads some input black means change direction dark green to dark red duplicate whatever's on the stack two of those dark red into yellow take the two numbers off the top of the stack multiply them and push that back onto the stack yellow into dark red output whatever's on the stack so we've squared these numbers now we print the output anything that crosses white is a no op no operation when we get to the edge of the grid here we change direction we keep moving inside this blue thing and so we end up with black on all sides and that means halt the program is finished this is hello world in Pete and it's also just nice it's artistic it's the kind of thing you could hang on a wall and nobody would ever know that you were looking at a computer program I like that idea now we've talked a lot about this idea of you know programs that you give to somebody and they run it later and it does something and we've talked about designing languages and publishing them online but you know have this idea in software that everything needs to be reproducible right we automate everything unit tests integration tests delivery pipelines take the humans out of the loop because they might not do the same thing twice and when you watch live performance anything can happen now I'm sure there are gonna be people here at build stuff who are gonna do live coding demos and life coding demos are kind of exciting right because anything can happen it might work it might not work you might what was it you did mark exceeded the rate limit on the people issuing the certificates for your demo because you rehearsed it so many times you burned out their quota and use the last one life performance has this excitement in this risk and in computing we talk about things that are hard to reproduce as snowflakes right we talk about snowflakes servers don't patch it don't run Windows Update if you even breathe on it all the finance system will stop working we've tried putting it in the cloud and the cloud broke and now we just locked it in a room and never touch it ever again but also if you pick a snowflake out of a blizzard and you watch it melt on your hand you've just seen something nobody else will ever see you are part of this unique experience that will never happen again and that's what makes live performance exciting this guy here is Sam Aaron Sam created a programming language called sonic Pi which is optimized for doing live performance and I want to give you a very quick run-through of sonic PI now you learn sonic PI and you do play a four and it plays a mint now sonic PI is the only language in the world where everything runs in parallel unless you tell it not to imagine if JavaScript ran all your statements at the same time unless you put pauses in we're going to go in here we're going to say use bpm that's beats per minute and we're gonna put a couple of notes in here and we're gonna put in a loop we're gonna say 16 times do this and we've got a beat and now we're gonna go and we're gonna start plugging in a little bit of logic we're gonna put in this variable I and we're gonna say is I divisible by three if it is play this note otherwise play that note and then increment I I is I plus 1 and we've just invented electronic music go us well done it was much harder when they had to do this with analog like being able to do it on a Raspberry Pi makes everything much easier but what makes sonic PI amazing is something called life loops so we've defined a live loop here we've called it my loop and we've said just keep doing that over and over and over and now while that's still running we're gonna drop him down here and we're gonna create another loop which we're gonna call symbols and in this loop we're going to play some samples drum sounds now first of all this line here sync to my loop it says these loops always start at the same time keep them in sync deep to the beat and we're gonna say three times play the sample drum symbol closed you'll hear what that sounds like in a second and then we're gonna drop in actually would do that 15 change that round because we got 16 beats in this bar we're gonna play a drum symbol open just to close it out and then without stopping anything now you hear that dropped in in the background now it's doing all of this in real time it's optimized for live performance if you've worked on real time AP is you can live with 30 40 milliseconds of latency that's pretty good right even for like first-person shooters in music 40 milliseconds will kill you because everything sounds horrible it sounds like country music so we need to keep it absolutely tightly focused so underneath this sonic pie interpreter there is a thing called super collider which is a real-time audio engine which is based on Erlang which means it can patch methods and functions while the program is running and have the old the current in the new version in memory simultaneously so we can do things like write a drum pattern while that melody is still playing we can come over here we can drop that loop in we can fix the name error there it is you ready and now we're gonna come back to our little melody here and we're gonna say well if that number is divisible by five I want you to play this note and if it's divisible by three I want you to play this note and if it's divisible by 15 [Music] does anyone recognize the algorithm that's being implemented here a venerable screening process for recruiting developers [Music] [Music] [Music] what we've got here is fist buzzers implemented in music and we're gonna put a little bit of reverb and we're gonna change some of the effects around a little bit just to make it sound a little bit more exciting not that we get a huge amount through the projector speaker that's up there but [Music] so that's sonic pipe real-time interactive audio programming now I want to finish up we have a few minutes left by telling you about the thing that I did because all this stuff about Easter Taric languages and climbs and all that kind of stuff it gave me an idea you see we've always had this trope about this idea of the Rockstar developer right you look at the ads on LinkedIn and you'll see everyone is out there recruiting for rock stars rock stars do this rock started do that rock started do that and last year pulsed eval put this on Twitter he said to really confuse recruiters someone should make a programming language called rock star and I had this experience I had this moment of blinding revelation because you see when I wasn't messing around with logo on amstrad's I was listening to music like this and I thought this is what the world needs the world needs a curing complete programming language for writing computer programs that are also 1980s hard rock power ballads so the hello world in rock star is very easy as say hello world but it's also scream or whisper or shout because creative expression is what Rockstar is all about variables an assignment now we have in X and we have var my string and we have the message and this does not look terribly rock and roll now first of all we don't need semicolons we don't need types it's a dynamically typed language if this is good enough for Ruby it's good enough for rock star now we don't want these equal signs we're gonna plug in is instead how many of you ever had an argument longer than three hours about whether they use Pascal case or camel case or chainsaw case or snake case or any of these other cases because I saw Douglas Crockford give a talk last year when he said we have all these stupid arguments when what we really want are variable names with spaces in them now I invented rock star in a bar and when you invent programming languages in a bar you can do anything you want so we can have variables with spaces in them there are simple variables we have common variables my heart your dream the night dr. feelgood Black Betty Billie Jean anything starting with capitals you can chain those together less of variablename now programming involves a lot of numbers and rock-and-roll kind of dozen fizzes three buzzes five the limit is 100 I wanted a more creative way of initializing variables so I came up with this what if we take the lengths of the words modulo 10 and treat those as digits in a number so we've got 3 5 1 0 0 the limit is a love-struck Ladykiller that's much more creative than limit equals 100 isn't it we can do with floating-point numbers as well you want to initialize pi and c 3.1415 them and JavaScript via pi equals but it's JavaScript so you're gonna get almost 2 pi like approximately in rock star my heart was ice a life unfulfilled waking everybody up taking booze and pills 3.1415 we needed arithmetic now in English we talk about are how much is that it's the price with the tax it's the total without the tax the quantity of the product the distance over the time here's the same thing in rock star but we can be more creative we can say a girl with a dream a man without a face the wings of the night a whisper over the water we need comparison your love is a lie the whiskey ain't the answer my heart is stronger than steel my soul is weaker than water my will is as strong as a lion and your lies are as low as a snake you can't program with that functions right so modulus takes a number and a divisor and while a number is as high as a divisor put a number without a divisor into a number and give back a number this blank line by the way that terminates the loop because that's how music works we don't need semicolons and n statements it's a blank line it means something just finished alternatively midnight takes your heart and your soul and while your heart is as high as your soul put your heart without your soul into your heart and give back your heart so I did this and I came up with this parody language specification I stuck it on github and I tweeted about it and the internet went kind of crazy and it made the front page of hacker news it got a write-up in boeing-boeing magazine people on reddit were saying nice things I don't if you hang out and read it but getting reddit to say nice things is no small achievement it doesn't happen very often shut up and take my money then this happened classic rock is a real rock magazine that has nothing to do with programming jokes and they emailed me and said what's this rock star thing we keep hearing about and they did a feature on it alongside interviews with the Rolling Stones and the tiger people like that dislike then people started filing issues and I was like why are you filing an issue and they said because your specification has undefined behavior and I said why do you care and they said because my compiler has undefined behavior and I said what and they said I've implemented a Rasta compiler in Scala yesterday I was like you can do that and it just kept going round and round around there's about five different implementations suddenly sprung up there's a Scala one and a rust one and a Python transpiler and all kinds of things and you know I kind of I like the sound of Dylan Beatty the creator of Rockstar but I didn't think that just writing a parody spec in a bar was enough work to justify it so I decided it I actually had to build an interpreter for it if I was gonna do this and I did it over Christmas in JavaScript because I'm an idiot and for another reason II because I wanted everybody to be able to run Rockstar without installing in the Rockstar to be a language you can write in a browser on your phone so that everybody can become a certified Rockstar developer and so I did code with Rockstar comm slash online there is an interpreter there anybody here can type in some code run it and come up and get your official certified Rockstar developer certificates which are self-adhesive and wipe clean by the way the logo here that's on the website I just want a little tip of the hat to the people I stole that from because they weren't using it anymore I wanted something that was really like all out over the top 80s neon rock and roll and I looked at lots of band logos I didn't come up with anything then somebody said have you considered Microsoft consumer products 1980 to 1982 and I went yes I'm gonna recycle that so thank you Microsoft so that is the story of Rockstar now I'd like your help with something because I have one little surprise left in store for you today this morning and that is the example of the chocolate cake that was also a valid program in chef I want to see if we can have a rock star program that's also a valid song and so what I'm going to do is to perform it for you fizzbuzz live at build stuff and you can draw your own conclusions as to whether you think this is two kinds of art one kind of art or no kind of art at all that alright with you [Applause] [Music] I've just worked out what the problem is lalalalalalalala there will be a tiny tiny interlude while we do that [Music] takes your heart and your soup while your heart is as high as your sue put your heart without your soul into your heart give back your heart [Music] [Applause] [Music] [Applause] [Music] [Applause] [Applause] [Music] my [Music] virus [Music] [Music] [Music] [Music] [Applause] [Music] [Music] thank you build stuff [Applause]
Info
Channel: Coding Tech
Views: 274,399
Rating: undefined out of 5
Keywords: coding, programming, art of code
Id: gdSlcxxYAA8
Channel Id: undefined
Length: 61min 28sec (3688 seconds)
Published: Sat Dec 21 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.