The Art of Code - Dylan Beattie

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Thank you for sharing, it was beautiful.

👍︎︎ 6 👤︎︎ u/e-t-l 📅︎︎ Apr 23 2020 🗫︎ replies

Here the author showcases, among others, the works of the late John Conway and Benoit Mandelbrot, esolangs and his own Rockstar language...

👍︎︎ 3 👤︎︎ u/SatacheNakamate 📅︎︎ Apr 23 2020 🗫︎ replies

I love this guy! I had the pleasure of watching him talk in NDC Porto last year, funny guy!

👍︎︎ 2 👤︎︎ u/aerkenemesis 📅︎︎ Apr 24 2020 🗫︎ replies

I've seen this and it's one of the most beautiful talks I've ever witnessed!

👍︎︎ 2 👤︎︎ u/FreshFromIlios 📅︎︎ Apr 24 2020 🗫︎ replies
Captions
good afternoon NDC thank you have you had a good few days I have it's been a blast and they have asked me to to come along and close out the conference for some of you those of you who were wise enough to be here because there's some strong competition in this spot by talking to you about something that I call the art of code now does anyone recognize the language that this little intro sequence here is written in logo this is not only is this logo this is original Amstrad logo from 1985 because the first computer that I ever had was this the Amstrad six one two eight it was rubbish I mean it was brilliant because I'd never had a computer before but it had the games that it had were all this kind of green screen and they weren't much fun compared to the games in the arcades and everything and you couldn't do very much with it no modem no dial-up no BBS or bulletin boards or internet but what it did have on it was this logo programming language and logo got me hooked because using logo I could make the computer draw pictures and that was a big deal in 1985 because I'd never seen like I could put things on that screen using logo that maybe nobody had ever seen on any screen before and I got hooked on it and I got this this lovely kind of you know feedback loop where I liked it because I could make the computer do what I wanted and every time I did that I'd get this little thrill and this rush and I'd go back and I'd have another go and you know throughout my entire career developing software and designing systems that thrill for me has never gone away and I hope for you all you here as well you know you have good days and bad days but you still get that rush when you know all your tests are green or when you you know you hit monitoring and it's a hundred percent or something just works and you're like I did that I made that work and over the last three days here at NDC London we've had some amazing brilliant people telling us how to solve useful important problems how to design scalable services deployment strategies information security the ethics of artificial intelligence and machine learning I'm not going to talk to you about anything useful because I am going to talk to you about art and all art is quite useless says Oscar Wilde now I don't entirely agree with this quote I like this quote a lot better the function of art is to hold a mirror up to nature and if we want to use art as a tool to explore and understand the world around us we can hold a mirror up to it but before we can do that we need to invent to the mirror and that is where science and technology and engineering come in because for centuries we humans have built machines and tools to help us explore and understand the world around us we've created scanning electron microscopes that have allowed us to see things like this this is shards on the eyelid of a beetle it's been there the whole time and nobody had ever seen it until we invented machines that could take photographs of something that's only a handful of micrometers across this is crystals growing in a dish of soy sauce this is the stems inside one strand of a banana leaf this amazing beautiful microscopic world we had never ever seen and we've sent machines and cameras and telescopes and people into space and we've looked back we've seen you know our planet Earth rising above the moon we've looked back from beyond the rings of Saturn this is us down here this is the pillars of creation this is six thousand light-years away in the Horsehead Nebula and until we invented machines to show us these things nobody had ever seen it and within the last thirty years maybe we've started exploring another hidden world that's been there the whole time until we developed the machines that allowed us to go in and see it and play around with it it's a world of mathematics and information throughout the 1970s there was a guy called Martin Gardner who wrote a column for Scientific American magazine about mathematical puzzles and curiosities and certainly the most influential of his columns he ever published was this one October 1970 where he described something called Conway's Game of Life created by an English mathematician called John Conway now as games go Conway's Game of Life does not look terribly exciting it is a game for no players played on an infinite board and it has four rules the rules of life the first rule each of these cells on our grid can either be living or dead if a cell has zero or one neighbors it will die of loneliness if a cell has two or three neighbors it survives to another generation if a cell has four or more neighbors it's like being in London it dies of overcrowding or it moves to Germany I don't know but it's not there anymore and finally and this is where it gets a little bit spooky weird if a dead cell has exactly three neighbors it will come back to life and that's it that is you now understand everything that there is to understand about the rules of Conway's Game of Life now when Martin Gardner's article was first published 1970 very very few people had computers and so they used pens and graph paper to play the game of life and they drew diagrams like this now these these five shapes of what we call the tetrominoes there are five Tetris tiles and this shows you the evolution of each of those shapes under the rules of Conway's Game of Life but you know looking at this it's like go new Museum where they have the butterflies pinned in a glass case you can see what the butterfly looks like but you don't understand anything about a butterfly from looking at this kind of representation it wasn't until we started using computers to actually simulate this stuff that we really understood the behavior we were looking at because these four patterns they all stabilized quickly but this one over here this is just gonna keep going over and over and over and once we could visualize things like this exploring the game of life became addictive people started saying you know are there packings that will move across the grid and just keep going are there limits is the game bounded or is it infinite this was one of the first shapes this is known as a glider repeats itself every six generations and it just keeps crawling across the grid forever and once we realized bladers were Possible's people started looking for more and they found hundreds of these shapes spaceships they call them these incredibly elaborate beautiful creations that just glide across this grid driven by four simple rules and that's it one of the earliest questions that came up in the game of life can you create patterns that will grow infinitely it's a guy called Bill Cosby was a founding artificial intelligence researcher and computer scientist some of you may have heard of and his team at MIT in the 1970s they created something absolutely wonderful they created a thing called gospel glider gun now what the glider gun is is it's a stable configuration and every 27 generations it creates a glider and since these gliders streaming out across the grid and gossip esteem discovered another you know lots of configurations while they were exploring this they also discovered this thing here which was called Villita now we have a glider generator and we have a glider consumer we can generate signals and we can destroy signals we have one and we have zero and if we have one and 0 we have binary logic and we can use that to create logic gates so this thing here is a NAND gate built in the game of life these little highlighted cells are our inputs now what we're going to do first of all we're going to start the circuit running and then we're going to say ok we're gonna take that blocker out so that our input a becomes true there we go a is now switched on we have no output signal we only have one input let's flip the inputs what happens if we switch B on will be as on but we still have no output signal because this is a NAND gate in order to get an output signal here we need to enable a and be we switch on both of those inputs we switch on our circuit and there we go we have a NAND gate now the brilliant thing about this is that if you have logic gates you can make circuits and if you can make circuits you can create computers and if you can create computers you can run programs including this program that you may have heard about a little while ago it's a thing called John Conway's Game of Life and it goes a little something like this now Conway's Game of Life is just one of a whole category of systems that exhibit very very complex behavior based on what looked like very very simple rules simple inputs you've probably heard of this thing called the butterfly effect it's a term we get from a branch of science called chaos theory the idea that weather prediction is impossible because if a butterfly flaps its wings that input is gonna change the output and you're gonna get hurricanes instead of sunshine in Tokyo two weeks later or something and over the last few decades mathematicians everywhere have started studying systems in a different way for a long time maths was only interested in problems you could solve give us the solution if you can't give us the solution this problem is not interesting we're just gonna go and find something else to look at but mathematicians kind of embraced this this whole at different school a different way of thinking we created imaginary numbers now the basic rule of an imaginary number we have this number I and in the natural world negative numbers don't have a square root 2 times 2 is 4 minus 2 times minus 2 is also 4 so how do you get what times what equals minus 4 well nothing it doesn't exist and mathematicians go no problem we'll just make something up we'll invent I it's an imaginary number and I squared equals minus 1 and they just this is where the rest of the world goes you can't do that and mathematicians go we can do anything we want it's an imaginary we don't we don't care but then once they've developed this and they've come up with a rigorous set of mathematics around it you can do some really interesting things with it now this thing here zero point eight plus one point two I I hang on a second give me one second there's a bunch of slides of gonnna stare and this is not making a huge amount of sense that yet no wicked will get we get we get one slide is missing right now this number here no point eight plus one point two I this is what's called a complex number a complex number is like a project plan it has a part that is real and it has a part that is imaginary and it is very difficult to predict what is going to happen next once these things get involved now there is a whole study of systems and the behavior of systems that we can talk about this thing here is called an Argand diagram and the the blue bit is imaginary the red bit is real so not point eight over there on one point two I plot it up there and this way we can plot numbers in in complex mathematics in this this kind of space and we can do arithmetic with these numbers just like you used to do in high school so we take point eight plus one point two I you just expand the numbers out as you go and you multiply and all you need to do is remember that anywhere you have two blue numbers multiplied together the result is going to come out negative it's gonna come out backwards so this one point two times one point two I will you square them and then you stick a minus on the beginning and you take negative complex inputs you get complex numbers out the other end now what's really interesting is when you start studying the behavior of systems that are driven by these let's take a really simple function e we're gonna take some real number X so we're back in in ordinary mathematics and every generation X is gonna go to X plus 1 so one two three four and you can already intuitively see you know how this system is gonna behave you can can't be confident you understand its behavior all the way up to infinity let's try another one so if we take this example x equals 2 minus X it's gonna go to there not - - - - - not - - round and round and round if we apply the same thing to this complex number what we're gonna do is we're gonna keep taking that number and squaring it first time we square it it goes to here we square it again goes to here we square it again it ends up over here and then over here and then it disappears off to infinity we're gonna move it ever so slightly and we're gonna run the same sequence again this time point six and it goes to here and here and here and here but it doesn't escape this time it goes into this little kind of weird almost circular orbiting pattern now those two points are right next to each other but they exhibit dramatically different behavior when we iterate them over and over again by squaring them and squaring them and squaring them and eventually this one disappears now the first really rigorous study of these kinds of systems was done by this guy a Polish mathematician called benoit mandelbrot and Mandelbrot was fascinated by the mathematics of real life he had this quote clouds are not spheres mountains are not cones coastlines are not circles a bark is not smooth not as lightning travel in a straight line now Mandelbrot had a brilliant job he taught mathematics at Harvard and when he got bored he went to IBM and played on the computers because this is the 1970s when IBM had computers and nobody else did so he would come up with these you know wonderfully complex mathematical ideas and then he'd go over to IBM and spend a couple of months playing around and simulating them and then he'd go back to Harvard and you know talk to his graduate students about all this kind of stuff and he was the first person to see the shape which now bears his name it's his name was Mandelbrot but everyone calls it the Mandelbrot set and I know that I'm gonna do that so let's just call it the Mandelbrot set basically it took each of these numbers in this grid and he said we are going to square this and add it to itself and square it and add it to itself and we are gonna see whether it stays on the grid or not and if it stays on the grid we are gonna color it in black and if it disappears and vanishes off the grid we are gonna color it in a different color depending how quickly it what's called tends towards infinity he started off with these very very low resolution renditions of this image but the one that you're probably used to the one that all of us have seen is this the Mandelbrot set now the astonishing thing about this from this incredibly simple mathematical rule there is an infinite amount of complexity we're going to take a Mandelbrot set here and we're just gonna start magnifying and we are gonna start zooming in and when we get to around about here we're gonna say that's 1 times magnification and we're gonna keep zooming and zooming and zooming and by the time we get about here that original shape is now size of this building and we are still zooming in when we get to around about here that is 2 to the 21st Amana fication the original shape is now bigger than London and we are still zooming in and around about now the original shape is bigger than the United Kingdom and we are still zooming in and we are still zooming in and we can continue zooming into the shape forever it never repeats it is what's called self-similar which means it resembles itself at different scales but it never repeats exactly there is an infinite amount of detail buried inside this one shape and this has been there the whole time nobody invented this we discovered it now this the Mandelbrot set some people have called it the thumbprint of God now I'm not a very spiritual person but I do play a lot of computer games and I love that thing in a computer game where you're doing something silly that maybe isn't part of the main campaign and you find that the game designers left something there to persuade you that you were supposed to be here and you're on the right track and this thing has been hidden in mathematics since you know our universe was created and no one ever saw it until we humans we invented computers which means taking lightning and sticking it in a rock until it learns to think and we invented advanced mathematics we invented high-definition color displays and rendering technologies all this kind of stuff and this is what we found something that was hidden there the whole time nobody had ever seen until we built the machines and the technology to allow us to visualize it now in this day and age just putting pictures on a computer screen is not actually that big a deal anymore this was from Tron which was a movie Disney made in 1982 first film to have completely computer-generated sequences Tron did not win the Academy Award for Best Visual Effects it was disqualified because using a computer to make a film was cheating according to the Academy of Motion Picture Arts and Sciences they changed their minds eventually and they gave it a lifetime award but we've got really really good at using computers to simulate things luxo jr. was the first completely computer-generated film 1985 Jurassic Park 1994 the first time we had computer-generated characters on screen with human actors and it looked convincing you know it looked compelling it became part of the story a couple of years ago we had this guy on our cinema screens don't who this is because there's one bunch of people who say that's Peter Cushing and he's my grandfather and he's dead and you shouldn't have done that and there's another bunch of people going that's grand moff tarkin copyright Lucasfilm Entertainment 1978 we own him you know and you know who is it is it the actor or the fictional character it's triggered this really interesting left ethical and legal debate but the point is we can put I saw a review of the last Jedi the last door which says we've now that living actors playing dead characters and dead actors playing living characters it's come full circle thanks to computer technology and we're at the point where we can do anything you could turn to your computer and go you know what I'm bored what would it have been like if they'd made friends with Nicolas Cage playing all the parts and we can just do that now now the reason we can do things like this is that we have created computers and algorithms that work on the same principle as some of the the most complicated firmware in our own brains you ever rely on your back in a field on a sunny day and you're watching clouds and your brain is kind of filling in shapes for you it's cloud looks like a rabbit that looks like an aeroplane that whenever there looks like a house and you're running all of these pattern recognition algorithms and filling in shapes and recognizing things and one of the things that we are hardwired to do is to recognize faces now we've got very very good we don't entirely understand how they work but we can now create something called a convolutional neural network you build a whole stack of layers of logic and you give it input you say these are cats and these are dogs learn and it goes away and it learns and it learns and it learns and eventually it creates an algorithm that you can give it a photograph and it will say with confidence that's a cat or that's a dog now you know that doesn't sound terribly difficult right I mean how hard can it be to tell a difference between a puppy and a muffin you know it can be a lot harder than you think but we're getting good at this but what gets really interesting is when people take the dog detection algorithm the dog detector and they wire it backwards and they say this is now a dog amplifier and the Machine goes alright and then you give it a picture like this and you say amplify the dogs and the computer says this is a horrible idea please please please don't make me and you say neural network find the dogs and enhance the dogs and it goes you're gonna regret this and you cannot turn up the power maximum dog amplification and you get stuff like this either this is a whole new kind of art that has become possible because of machine learning that nobody had ever even thought of before and the technique that's used to do this is something called deep dreaming came out of a project in Google in 2015 it's really unsettling isn't it because you're looking at it and what's happening is those same circuits in your brain that we've learned to emulate in in hardware those circuits are going dog no it's not dog dog no it's not a dog dog and kind of your peripheral vision is finding patterns you recognize but then when you look at them it turns out you've been tricked and so you get the kind of very very complex perception around what's going on with it now this is just one of a whole bunch of ways that people are using modern technology and software as artists to create new kinds of art I wanna introduce you now to a guy called Robert Felker who I met in Warsaw the other week who's doing some really really interesting stuff when I start a new art work it's just an inspiration you just have a feeling so between the first ID and the end wizard there's just the same feeling it's not about the visual I'm not interesting in what you see I'm interested in what you feel I'm Robert my everyday job I'm a flutter dev and project manager and I'm also photo artists previously I wasn't kind of locked by the tool I can do a lot of stuff but only what the tool permits me when I found the flutter it opened the door inside me now I can really push further [Applause] generative art is a lot of research like a lot it's a lot of failure it's a lot of failure finding the color finding the form understanding the good behavior of light what's really good with flutter is the speed of the feedback it's nearly instant currently artists do not understand the full potential of the tool when you start further you start with material design or you start with the iOS component and you think this is flat but this is just the the tip of the iceberg now if you want to push then you start to enter the photo engine and the photo engine is like the juice of the cone each time I start to cut I just feel joy so some people are painting so people are cooking I just do flutter and photo in and this is an example of one of Roberts works this is a photograph he took in Tokyo at night that he then used machine learning to do a depth perception analysis to identify from the photograph the depths of all the elements in this and then use software and tools to creatively rebuild the photograph working in layers and I think this is quite beautiful it's kind of hypnotic and every time you watch it loop through it reveals something new and this is just one of hundreds of ways that artists are using code to create new kinds of artworks we've never seen before but what if we stopped talking about using code to create art and we start talking about code as an art form in its own right now this very famous book one of the great text books or volume set of text books in computing science Donald Knuth's the art of computer programming and we can debate for a long time is programming an art is it science is it engineering is it typing is it you know now but I'm sure many of you have reviewed code that came from somewhere maybe somebody on your team was was tired or out of that depth with it or maybe you were just having a bad day and you look back at it a few days later and you're like I don't know what this is it's not engineering it's not art I don't think it's terribly creative I wouldn't dignify it by calling it hacking I have no idea what this is but fortunately there is now a safe space for this kind of code and these kinds of programs and it is the International obfuscated speedboat contest the goals are to write the most obscure C program to show the importance of programming style in an ironic way to stress compilers with unusual code to illustrate some of the subtleties of the C language and to provide a safe forum for port C code I just like to share some examples with you so this was a black I think Jonathan Mills contributed this this is the entire source code for this program very C programs here in the room today you want to tell me what this does and it's just code right there's only one screen of it how hard can it be let's just run it and find out because you know why not we'll just run that to make file and then we'll run it and there it is it's flappy bird running in a terminal here's another one lynnium zoom out give you a little bit of context so this code actually generates and draws the Mandelbrot set in a text window and it does it in a relatively kind of compact code base that's shaped like the thing it dramas which i think is rather neat now brevity is one of the objectives of obfuscated code you want to do something really surprising with a very very small amount of code this is the entire source code for a program by a guy called Oscar Pulido gee if you copy and paste this into your web browser it plays chess it doesn't draw a chess board it plays chess it is a chess algorithm implemented in just under a kilobyte including JavaScript HTML graphics behavior logic engines all the rules of chess and an engine that is actually better at chess than me this thing beat me in games is that much JavaScript now there are some astonishing examples of programs that do wonderful things with very very small amounts of code but none of them is quite as good as this one this was submitted to the International obfuscated contest by Simona syncovich in 2005 and it was accompanied with documentation saying if you compile this using this compiler it will print its own source code there's nothing here this is an empty file but that compiler had a quirk that if you fed it empty input it would create a C program and compile it that produced no output and so he quite rightly said this program prints its own source code now the obfuscated C competition when okay one very clever to have a price three we're changing the rules from now on all programs have to have at least one character of input otherwise they are just this program completed again but this idea of a program that prints its own source code is something called a quiet the word comes from from this book which some of you may have read which is that's kind of fascinating riff on mathematics and recursion and fractals and poetry and music and stuff and it turns out that writing a program that prints its own source code is actually surprisingly hard now you're not allowed to just read it from disk and printed that would be cheating you have to generate the source from within itself so let's let's write one I don't write a coin for you now using c-sharp so we need a class program with a static void main method and then we obviously need to write line the class program and close the bracket and we need to write line the static void main and now we need to write line the right line and then we need to write line the bright line with the and you very quickly get tangled up in oh this is just kind of e strings all the way down but every language out there has quirks loopholes that we can exploit to make it do things that it wasn't supposed to do now in c-sharp there is a feature called string templating so we can define a string that looks like this and we can put placeholders in it these little things here say when you see an argument put that in the string at this point and then we are going to feed this string back into itself as a placeholder variable so that when it gets to that bit it prints itself and it doesn't go into an infinite loop what it does is it prints itself it prints its own source code and different languages have different loopholes you can exploit to make coins JavaScript coins are very easy because every function in JavaScript has a two string that prints it so this javascript function itself in JavaScript and ACMA script six this is a coin and I didn't believe this because that doesn't look like anything so I ran it in a console and sure enough that's the output that gets produced when you run it but what's really interesting this is an idea I got from a guy called Leon BAM brick who wrote it a great post about this is can you make a coin in HTML now HTML like you know is it a real programming language I'm not touching that argument can you write a coin in it well let's find out here is some simple HTML source code title head body couple of paragraphs and a link to Leon's original thing on this and this is what it looks like in a browser right start breaking some rules so first we're going to put some style on that says display everything as a block even things that are supposed to be invisible this star will match everything we run that in a browser and now we can see our CSS our source code is coming through in that browser now we're gonna put some rules in let's say well before HTML we want you to display this and afterwards you displayed this now the slash HTML is actually down here off the bottom of the screen because it knows it has to draw it but we haven't told it where to put anything and the safety is off at this point we have no idea no the browser is like you're on your own kids have fun we plug in a bunch more rules style here we have to put a backslash to escape the slash because the web browser is actually running three different passes it's pausing HTML it's pausing CSS and it's pausing JavaScript and they're all fighting over who gets to eat the next bit of input and at this point if we put slash style our CSS parser is going to go yep I'm done and HTML is gonna choke on the rest of this chunk here so we have to escape it now we have before and after tags now there's no way of generating these we just need to go and plug-in head body title anchor paragraph and we get this now you'll notice that down here we've got this a but we don't have the href equals with the web address we want to link to can we do that using HTML and CSS oh yeah no problem if you see a with an href we want you to take this attribute and put it into some content and stick it in before the thing and there you go and the last thing that we're going to do just to make it look nice is we're going to put a margin on there and change the height of the age and there we go we have a web page that actually prints its own source which is completely useless and utterly pointless but how many of you learned something you didn't know about the ages here's our parser when you were watching that little run-through there look at some more here is some source code who wants to tell me what language this code is written in si si si any other votes for si well let's let's apply a C preprocessor to it well take out the comments include standard IOH main char I mean that the formatting on this is a little wonky but yeah this is this is fine this is completely valid C code but what happens if we apply Ruby syntax highlighting and highlight the strings because that looks to me like perfectly valid Ruby code right let's try running it and see what happens so I'm going to take that program poly coin see there it is and now I'm gonna feed that program into the GCC compiler and I'm gonna run it it's got a warning but we're way past the point where we care about warnings and there we go that program prints its own source code and now because why not we are going to run the same thing through the Ruby interpreter and we are gonna get look at that it prints its own source code now we're going to run it in Python because we can and it prints its own source code and now hey in for a penny let's run it in Perl and see what we get and it prints its own source code again and apparently it'll also do it in C++ if you can find an old enough compiler this is a poly coin this is a program that is valid in more than one language at the same time and in this example it always prints its own source code now who would like to tell me what language this program is written in well let's break it down alright let's do some syntax highlighting so we got system dot console which is kind of like a dotnet II kind of a thing right and then we got this chunk here which is an XML namespace we got a console dot log in a for each in the lower case so that smells kind of JavaScript T to me right we've got an ADA textio procedure we've got begin in capital letters which is either COBOL or SQL it's definitely from the 1970s and it lives in a bank and up here we've got act 1 scene 1 enter Ajax which doesn't look like any program I've ever seen now this is an excerpt from something called the or Robert Quine it's a ruby program that creates a rust program and the rust program creates a scholar program and the scala program creates a scheme program which said Shakespeare all the way around the circle 128 languages until you end up with a RC program that creates a Rex program that creates the original rust program again this was written by a Japanese developer called Yosuke and though who one of the contributors to the Ruby core language and the fact that it exists at all is astonishing this is what the source code to that coin looks like [Laughter] which is also incredible and if you zoom in on the end of the source code you'll notice that the last four lines all just say buffer for future bug fixes because they don't want to mess up the shape of the source you know now this is the most astonishing thing about this all 128 of those languages can be installed on a win to Linux by going apt-get recs apt-get Shakespeare apt-get TC so there is a github actions continuous build pipeline for this thing that whenever changes to it are committed it runs them through all 128 languages and tells you whether it succeeded or not which I just think is fantastic and you know weird but I love the fact that we can do that but let's backtrack a little bit in that chunk of code we looked at there was some C and there's some JavaScript but there's also act 1 scene 1 & 2 Ajax now that is an excerpt of a program written in the Shakespeare programming languages one of a family of what are called the esoteric languages ISA Lange's and Shakespeare is designed to let you write computer programs that are also Shakespeare plays this is hello world in Shakespeare the infamous hello world program now all variables in Shakespeare have to be declared as the characters in the play so we have Romeo and we have Hamlet act 1 scene 1 that's a namespace and a block enter Hamlet in Romeo this is variable scope we are dealing with right now and then the way variables work in Hamlet is when they say nice things they increment and when they say insulting things they decrement so at this point Hamlet is talking to Romeo and Hamlet says you lying stupid fatherless big smelly half-witted coward you are a stupid as the difference between a handsome rich brave hero and myself speak your mind that puts the letter H into Romeo and then outputs it because H is the first character in hello world the next chunk here will print e and so on hello world and Shakespeare is about three pages of fairly florid prose which is fine because it's Shakespeare and that's what it's supposed to look like how about this one can anyone tell me what programming language this is written in this is white space let's have a look at that with syntax highlighting applied white space is a programming language that only cares about spaces and tabs it ignores everything else it's brilliant if you want to hide programs inside other programs mix up your tabs and spaces and you can put whitespace alongside anything else this is hello world in white space let's take a look at the hello world souffle now this is a programming language called chef and chef is designed for writing programs that are also recipes now 72 grams of haricot beans a hundred 1 X 108 grams of lard 111 cups of oil you know 33 potatoes it's a valid program but would you like to eat this souffle you know and so somebody called a guy called Mike worth looked at the chef's programming language and when challenge accepted I'm going to write a hello world program that's actually a sensible recipe you can make in your kitchen and he came up with the hello world cake with chocolate sauce now I think this is brilliant if you compile this on a computer it says hello world if you compile it in a kitchen you get an edible cake with a kind of chocolate sauce ganache that you can pour over the top of it but the thing I think about this that's beautiful is if you didn't know about chef you'd think this was just a recipe it fits so well into two different domains of human creativity that from one you'd have no idea that it also worked in the other one I'm going to show you how to square a number in a programming language called Pete that is how to square a number in Pete Pete is named after the Dutch artist Piet Mondrian and Piet is a graphical language where the instruction set is dictated by what happens when you cross from one color into another every Piet program starts with an instruction pointer in the top-left travelling towards the right traveling due east so what's actually happening here is when we cross from light blue to dark green that says input a number prompt the user and put that on the top of the stack when we get to black turn the instruction pointer through 90 degrees when we cross from green into red that means whatever's on the top of the stack duplicated when we cross from red to yellow multiply top two numbers off the stack multiply them put the product back on the stack when we cross from yellow into red that is output whatever is currently on the top of the stack omit that to standard out when we cross white that is a no operation we reach the end of the grid we turn right again and then we follow this blue instruction certain till we end up with black on all sides which means you have reached the end of the program please hold so that's a completely Turing complete language whose instruction set consists of areas of light and shade and the transition between colors this is hello world in Piet one of many many examples but you could hang this on the wall in your house and somebody could come in and take a look at it they'd have no idea they were looking at hello world they just think you like kind of slightly weird 16-bit art you know the Windows 3.1 school of Expressionism now we've talked so far about this whole idea of you know using we've talked about using code to create art we've talked about code that is art and over the course of MDC you've probably seen a couple of speakers here doing live demos which are you know the the tightrope the high wire act ooh the death-defying circus thrill of the technology industry because someone is coding something on a laptop live and it might work and it might not work and there's always this element of kind of risk and then it works and it runs like yeah and you got a big round of applause but generally as an industry we don't like that you know we like consistency we like reproducibility we like automation we like being able to do the same thing over an over and over again if you've ever worked in a place where there is a server under a desk or maybe in a rack somewhere that's running Windows 2003 Small Business Edition and you're not allowed to touch it do not put Windows Update on that or the payroll will stop working on pain of immediate gross dismissal you know and we have a name for these kinds of boxes that everyone is frightened to touch we call it snowflakes snowflake servers snowflake processes it's completely unique but if you go out in the snow and you pluck a snowflake out of a blizzard and you watch it melt on your hand you have just been part of a performance that will never ever be repeated anywhere your participation in that has created a unique human experience that nobody else will ever understand or be part of and maybe we can do the same kind of thing using code this guy here is Sam Aaron and Sam is the creator of a programming language called Sonic pi was anyone in the last talk in this room yesterday where Laura did her talk about programming with music and she was showing us had a program write computer programs whose output is not text or graphics it's music and tones and sounds and melodies and she ended up by you know doing this this wonderful kind of layering thing because sonic pie is a live coding music synthesizer I'll give you a very quick demo of how sonic pie works which I'm not gonna live code for you because I don't want this to get too meta now when you start sonic pie it gives you a prompt and you say play this note and it plays that note now sonic pie runs all your instructions in parallel unless you tell it not to imagine if JavaScript if you want things to happen one after another you have to put sleep instructions in and say we want to introduce some kind of delay to this and where it gets really interesting is we can go in and we can start putting loops around our notes and our musical patterns so we got 16 times do that and we've got the world's least exciting bass line going so let's crank up the tempo a little bit we're gonna say use beats per minute 240-foot all right we're getting somewhere and we're gonna change it because the sine wave is not a terribly exciting noise we're gonna use a built-in synthesizer here called Tex Soares now this is interesting but where it gets really interesting as you'll have seen in Laura's talk yesterday is when we introduce the concept of something called a live loop now live loops allow you to run multiple components of your program so I'm gonna put a light blue there around that baseline and then I am gonna drop another loop over the top of it [Music] the fizzbuzz now sonic pie is fantastic it's enormous amount of fun to play around with I've seen people do live coding with multiple you musicians that picture of the beginning was Sam on stage with the London Philharmonic Orchestra doing live coding in the Royal Albert Hall and you know it's an absolutely astonishing tool and just one of the brilliant and creative ways that we're coming up with to use code to do fascinating and unexpected things but I want to finish today I've talked you all about all kinds of things that other people did I want to finish by telling you about something that I did now you are probably familiar with the trope of the rock star developer because we've all read job advertisements from people looking for a rock star senior front-end rock star JavaScript engineer rock star senior Java software developer this has been endemic in our industry for years and last year Paul Stovall put this on Twitter he said to really confuse recruiters someone should make a programming language called rock star and I had this experience because I thought this is it this is my purpose this is why I was put here because what the world clearly needs is a programming language that allows you to write programs that are also bad 1980s heavy-metal songs and so rock star was born a dynamically typed Turing complete programming language for creating computer programs that are also song lyrics heavily influenced by the lyrical conventions of 1980s hard rock and pala balance now Rockstar was created in a bar as a joke that will become important shortly sad a bar with a laptop and a beer and thinking could you make a language where rock songs could compile to something now I used to work in VB script and Perl a lot and I've done work in Ruby so I'm used to languages which try and you know borrow a lot of elements from natural language and incorporate them into programming syntax so I thought all right first of all if you were write songs in it there's more than one way to do it like the Perl idiom attempt Tony you know so HelloWorld in rock star is say hello world or scream or whisper or shout these are all syntactically valid programming requires variables and assignment now you're probably used to in x equals five var my string the message now we don't need int because rock star is a dynamically typed language we are going to take those out we don't need semicolons on the end because if JavaScript can live without them so can we now the equals sign in the middle how do you sing that and those you know let's just put is X is five my string is hello world the message is flutter rocks because I forgot to update that that should say NDC rocks now there's this ongoing debate about casing you've had one of those arguments longer than an hour about Pascal case versus camel case versus get bad case versus underscore case and I shall Douglas Crockford the guy created JSON give a talk two years ago where he said we have all these stupid arguments what we want are variable names with spaces in them well guess what when you're inventing a programming language in a bar you can do anything you like so Rockstar has variable names with spaces and it's not a complete free-for-all there are three kinds of variables simple variables work like they do in JavaScript and Ruby common variables have to start with my you're the an a and proper variables need capital letters so we can write programs about dr. feelgood and black Betty and Billy gene and all these you know great characters who inhabit the world of rock and roll now initializing variables we normally do with numbers fizz is three buzzes five the limit is 100 I didn't want to do this because it doesn't sound terribly metal really and I thought how can you define a numeric literal without having to use digits in your source code and I had this idea what if we take the lengths of the words modulo 10 and we treat those as digits so ice is 3/5 the limit is a love-struck Ladykiller one that's 10 10 modulo 10 is zero zero we've got three we've got five we've got 100 without having to put digits in our source code it works with floating-point numbers as well and C decimal PI 3.14159 and JavaScript var pi equals we're kind of almost you probably got something close to that back out because hey JavaScript right in rock star my heart was ice a life unfulfilled waking everybody up taking booze and pills 3.14159265 3/5 easy right you gotta have to do arithmetic right now we have these common you know ways of talking glitch how much is it I the total is the price with the tax well what about the the net Anana that's the total without the tax how many do you need get me the quantity of the product how fast were you going well speed is the distance over the time you know we have these things it's easy but this mathematical convention also allows us to write a girl with a dream a man without a face the wings of the night and a whisper over the water we need comparison your love is a lie true or false well is it the whiskey ain't the answer my heart is stronger than steel and my soul is weaker than water as strong as a lion as low as a snake we'd each function syntax now the sort of simplistic version here let's have a function modulus it takes a number and a divisor so those are input arguments 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 is how you implement modulus when your building blocks are just addition and subtraction and loops and stuff now this works but we can do better right because midnite takes your heart and your soul and while your heart is as high as your soul you put your heart without your soul into your heart and give back your heart now at this point I'm about three beers in I have a parody specification that is just complete enough to implement fizzbuzz and I have fizzbuzz in Rockstar I stick this thing up on github and I'm just like hey everyone introducing Rockstar proposal for a turing-complete programming language and I think this is gonna be funny for like three hours you know it gets 2,000 github stars overnight it makes the front page of hakkon news and just kind of starts this buzz it made it into a Boing Boing magazine Cory Doctorow wrote a thing about it in there it made the front page of Reddit people and reddit we're actually saying complimentary things about it the weirdest thing that happened is I got an email from classic rock magazine which is a real music magazine that is nothing to do with computers saying what's this Rockstar thing that we keep hearing about so I wrote a little thing for like an email interview for them and I'm thinking like this can't possibly get any weirder and then people start filing issues against my parody specification and I'm looking at these and you know some of them are just ideas like what a fool the numbers go up to 11 and I'm like don't know that arithmetics hard enough as it is but some of them are like this undefined behavior and I'm like what do you mean there's undefined behavior why do you care and they're like I built a rock star compiler in Scala over the weekend and it has edge cases like you did what and within about a week there was a Scala interpreter so I would have built a compiler for in rust somebody had built a rock star to Python transpiler and the fascinating thing is all of them had managed to do like 95% of it just based on this random stuff I came up with in a bar as a joke and some of it makes no sense and you know if I'd known it was ever gonna be real I'd of course have done it differently but programming is like that you know now I really liked the idea of Dylan Beattie the creator of rock star and I didn't think I'd done enough work at this point to really earn that and I also wanted rock star to be you know scholar and Rustin and Python are all very well but I want it to be something accessible something that anybody could just open up in a web browser and write some Rockstar code and see what it did and so this time last year I basically spent about five weekends we teaching myself how to build compilers and parsers and meta-circular evaluator x' and stuff and i built a rock star interpreter in javascript which is definitely the stupidest dumbest thing i've ever done and it's online and it is here it is at code with rock star calm and everybody here in this room is welcome to go and try this put some code in there and you will then be a rock star developer now I just want to shout out one thing the logo here in the top left I wanted to borrow some like real over-the-top access 1980s rock and roll heavy metal influences and I looked at dudas priest and Iron Maiden and Motley Crue and all these kinds of people and then somebody said have you thought about Microsoft consumer products 1980 to 1982 and I was like that is exactly what I want that logo type is perfect so thank you Microsoft for letting me recycle your old logo be green now I do have some certified Rockstar developer stickers to give away here at NBC so come up afterwards with your code with Rockstar comm code on your phone and I will certify you you will become a member of the world's most prestigious developer program but to end the talk today I'd like your help in something now I showed you some examples in there of like hello world and Pete that just looks like a painting and the chef hello world chocolate cake that could just be a cake and if you like the the test of whether Rockstar really succeeds as a language is can you perform a rock star program and have people just think it's a bad heavy metal song from the 1980s and so with your indulgence I'd like to close NBC and this talk by performing live fizzbuzz in rock star [Music] takes your heart and your soul while your heart is as high as your soon put your heart without your soul into your [Music] give back your heart you remember the fizzbuzz riff [Music] [Music] [Music] [Applause] [Music] [Applause] [Music] thank you very much in DC thank you for coming thank you for your time thank you for listening who's going to pub gun if you thought that was silly we got way more stuff in store if you don't if you're coming to pub gun I will be emceeing tonight we got 12 amazing speakers lined up with five-minute funny talks there are still tickets on sale if anyone doesn't have plans tonight Pupkin oh if you are not coming to PubCon thank you very much I will see you somewhere out on the road have a wonderful weekend see you soon bye-bye [Applause]
Info
Channel: NDC Conferences
Views: 876,773
Rating: 4.9500728 out of 5
Keywords: Dylan Beattie, Code, programming, art, NDC, London, 2020, Sonic Pi
Id: 6avJHaC3C2U
Channel Id: undefined
Length: 60min 48sec (3648 seconds)
Published: Wed Feb 26 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.