 Hello everybody, let me be the first one to welcome you all to Singapore. Who in here likes raising their hand? All right, all right. Who in here does not like raising their hand? Huh, okay. I'm here to talk about magenta. And by magenta, I do not mean, oh, I need to turn this on. Sorry, it's not my clicker. By magenta, I do not mean magento. I do not mean magneto. I mean magenta. Or in general, all the magenta spectrum. This talk is a very new thing for me. I've never given this talk before. I've never talked about anything that's anywhere related to what I'm going to talk about. So I'm slightly freaked out about this. Usually I give very technical talks. This talk is very, very meta. I've not really given a meta talk. And it's not just about magenta. It is also, as you might see from this picture, or not, about abstraction. And I did some research about abstraction. I interviewed famous Ruby developers. One said, too much magic. You mean in general? It can make a lot of stuff simpler to understand, but it can also go too far. I did that research during another talk today. So, but it's for real. Let's talk about abstraction. I think abstraction is a principle that is the basis for science. And who doesn't love science? Who doesn't love science? Cool. Science rocks. Abstraction is a principle that I think you find in all fields of science. One part where this was very inspiring is in architecture. In architecture, Christopher Alexander published a book, The Pattern Language, which is actually the sequel to another book called The Oregon Experiment in the 70s, which defined general purpose patterns that you can use in architecture that are not bound to a specific type of building that you can use on small scale. He talks about interior design or designing your house or actually designing a district, designing a city. And this inspired another book you might or might not have heard of that was influential in computer science called Design Patterns, Elements of Reusable Object-Oriented Software. I actually keep forgetting that name because everyone calls it the Gang of Four book. It came out in 94 and it defined general purpose design patterns to be used in software development. And that, for me, that's what I think of when I speak about abstraction in software development. And picking the right abstractions is crucial. And in computer science, everything is an abstraction. Everything. Unless you actually speak about transistors and go on about how the electrons fly in there. I mean, even that model is an abstraction on some level. But when we program, we don't really think about the transistors, which is what everything in the computer is made of. So if you don't know a transistor is basically a not end gate. And out of a not end gate, you can create any other logical gate with which you then can use to build an ALU or anything else that runs in your computer. But I guess most of you don't actually think about transistors. Does anyone actually think about transistors when they write their rails application? Okay, that guy. Okay, maybe this is, so that is why I talk about abstraction. So you might understand this concept that lets you get away from the thinking about transistors. And especially in computer science where the abstractions are very abstract and are there right from the beginning, maybe in contrast to some other sciences. Sciences, is there a plural? There is a lot of room for interpretation, how to interpret such abstractions, which abstractions to use and so on, which in my view makes it actually very similar to art and to math. Which you could now have this whole discussion where people like to point out that programming is like an art and I think a lot of that stems from the fact that we can choose and express easily with different expressions. There are different ways, different things we do for abstracting when we program. One thing we do is we abstract away semantics. We have abstraction levels where we do not think about, ooh, this represents, I don't know, a user in our database. And if we abstract that away, that allows us to have generic algorithms. If you don't know what an algorithm is, it's the word used by programmers when they do not want to explain what they do, what they did. Anyone know what that is? Quicksort? Quicksort, yes, it is Quicksort. And Quicksort does not care what it's sorting as long as it knows how to compare it. And that's what I mean when I talk about generic algorithms. Generally, we assume that sorting a list is a solved problem or an error or whatever. So we just call dot sort and then on an array and that's abstracted away and sorts everything for us. And that is very powerful because we don't need to re-implement the sorting algorithm for our web application. There are other types of abstractions. There's data abstraction. And if you look in the past, this was actually a very big debate. There was a paper written about this and published in 1967, data less programming that was quite influential there. It stated that the big problem we have right now is that when you start in your program, the first thing you do is you think about the data structures and then you're bound to these data structures and this might cause big problems later on when you wanna change these data structures. Now we still have these problems kind of when you choose your database layout and it leaks into your public API that you use single table inheritance or whatever. But we got very far away from this by now because of all the progress that was made. Back then that was for every little small thing you implemented. You first need to choose the data structure. When I learned programming, I read a book that first pointed out that it's really important to start sitting down and think about your data structures before you actually start writing any code. And I don't know about you but that's not how I write code today. The paper goes on to suggest that we need programming languages that allow us to write code in a way that it does not imply the data structure that there is a universal interface and then you later can pick the data structure. And I think that especially with dynamically typed languages and so on, we have come very far into that direction where you can start just implementing, writing some business logic and then filling in the gaps with the data structures. There's a second kind of abstraction or a third kind that's control abstraction. Basically, when you execute something on the CPU, it isn't, it's just machine instructions. And if you want to manage a large portion of machine instructions, machine instructions, you need good abstractions. And this started with basic concepts like subroutines and there were big debates in the 60s and 70s about how to structure them and big standards. And out of that came, for instance, a very famous paper, go to statement considered harmful. That is a big part of the debate. How do we abstract code away? What should you actually, how should you actually manage subroutines? I think not much of that paper remains today except for the fact that we generally do not use go to, except maybe if you do see, I actually submitted a patch to MRI that was accepted where I used go to. I followed the general coding guidelines. But I think we shouldn't get caught up in go to. There's actually a bigger picture here. And in just five years after that paper, another paper came up, or actually, Dijkstra's go to statement considered harmful was not a paper, it was a letter. But this was actually a paper by James Morris, Jr. Protection in Programming Languages where he talks about isolating parts of code from each other and then having means of communicating between those parts. This is the basis for modularization, for having, for dividing your program in reusable modules. In this paper, he actually goes on a lot about how to technically enforce this. I think it is not necessary to enforce rules. It is necessary to adhere to them. He actually tries to develop a system where you can hand out data that belongs to your module and you can encrypt it or sign it so nothing else can mess with it. And I think all that is not really necessary. But out of that paper came important ideas. You should be able to reason about modules and isolation, which then in turn is the basis for tools like unit tests or in general having libraries that you can reuse. And I think it's very important to look at where all this comes from. We take a lot for granted from that, but there's also a lot we simply ignore. Like the idea that global variables are harmful also came up in the 70s. And I still see programs everywhere that use global state and that later on comes to hunt people and makes it really hard to scale things or to rearrange things. But, so thinking about this, we have data abstraction on the one hand and we have control abstraction on the other hand. If we combine the two, one programming methodology that comes to mind for me that also came out of the 70s is object-oriented programming. I think that does both. Who's still listening? Cool. Who knows what this guy is? Yes, two people. This is Ellen Kay, the inventor of Smalltalk. Also, this picture is ideal for starting a new internet meme, Ellen Kay holding things. Anyway, he said object-oriented programming to me means only messaging, local retention and protection and hiding of state process and extreme late binding of all things. And when you think about it, this basically describes both data abstraction and control abstraction. There's an interesting side story. There were, so he worked at Xerox PARC together with Dan Ingalls, Gila Braca and a few others and they developed Smalltalk 80 and they got a visit from this guy. Who knows what that is? Steve Jobs. Okay, so you don't? And about this visit, there is this interview with Steve Jobs where he said that when he went there, they showed him three things and he didn't see the first thing, which was object-oriented programming. He didn't even see the second thing, which was network computers. They actually had all the computers there in one network because of the third thing they showed him and that was a graphical user interface. And the fascinating thing for me about this story is all three things are about abstraction. We make the rules. We make the rules by deciding which abstraction we choose and which rules apply for these abstractions. By the way, so this is from a software world and they have like a hover title like XKCD. I'm not sure can you read this? Yes, back there. Those people aren't listening anyway, okay. So the hover text is getting your haircut, a rebellious one. Anyway, some rules enable good programs and those are principles that we use most of the time to write programs, abstract them. Single responsibility principle comes to mind where one object should have a single responsibility and if it has two responsibilities, you should split it up. Two nights ago, we came up with the zero responsibility principle and I'll use that from now on in all programs I write. Another one that very much plays into abstraction is the Liskoff substitution principle which says any subtype of a given type should be able to be used as a full substitute for that type. Law of demeter about you should only know things about your friends, friends describing objects close to close to the object you're talking about. It's very important to keep in mind to not abstract too early. So I maintain Sinatra as was pointed out and from time to time I get an issue or a pull request that tries to refactor one part of Sinatra. It's like the first thing people do when they wanna contribute to Sinatra and this pull request takes the list so Sinatra has these lists like get and then you give it a path, post and then you give it a path or a pattern, et cetera, et cetera and so those are all methods that all basically look the same so the first thing people do is ooh, this screams do not repeat yourself. Let me refactor that and then get a pull request like that and then the person who wrote this page is actually in the room I think. Anyway, that's totally fine. I would have probably done that myself a while back way before I joined Sinatra but I think this abstraction is very unnecessary. It doesn't actually buy you anything. All these methods are one-liners and if I look at this, if I look at this code I need to think about what's going on here so this is generating code and then up there that makes way more sense to me I look at that and I instantly see what the methods are and instantly see where they go and code is way more often read than it is written. Yeah, so I politely declined those pull requests which is sometimes hard, sometimes easy. Okay, so in Ruby we use a lot of inheritance as an abstraction. We use classes. It's the basic abstraction. We use an object-oriented programming. Here's the thing to think about there is inheritance a good abstraction because we use inheritance for two things. We use it for type hierarchy and we use it for implementation sharing. We use a common base class for our controllers so that our controllers all behave the same. We have cookie-based or pool-based sessions in REC inherit from the same class so because they are of the same type and this basically boils down to the argument do subclasses equal subtypes so do they have to adhere to the, do they have to follow the list of substitution principle and so on and it is very interesting for me what some programming languages do that simply do not have inheritance. In Go interfaces are used for type hierarchy and composition is used for implementation sharing and this for me is a very intriguing concept to go for separating out the two. Strong external abstractions allow weak internal abstractions. One of the most amazing things when we move from one monolithic Rails app to a distributed app, a distributed app is you can actually write crap code. If it's just a very small app that is easy to rewrite, easy to test, easy to think about, you do not have to follow any principles as long as the external interface is well-defined. You can even switch programming languages however you want. Abstraction can also be a security issue. Almost all attacks that I've seen rely on switching the abstraction level where someone else didn't think that they should switch the abstraction level. The Heartbleed attack, people thought we have SSL so we're safe and I think about higher levels like on my passwords encrypted or whatever but if you can attack SSL, you can just read all the traffic and you can just read the passwords from there. So that's switching an abstraction level. You can also switch an abstraction level the other way to the extreme of social engineering where someone goes in and says, yeah, I'm the repairman, I need to check the service and you just grab the hard drive or someone actually entered fake numbers for the FBI in San Francisco in Google Maps and then when people would search for the phone number of the FBI that would call his fake number, he would proxy the call and record it. That is just an abstraction level that people probably didn't think about when they thought about how to make the telephone line safe. Abstraction, as I said, the UI is an abstraction. You talk about metaphors and principles and paradigms. Let's talk about color because after all this talk is supposed to be about magenta. Color is light. Light comes from electrons. Electrons in an atom or around an atom that are in an excited state. An excited state means they have more energy than they need. An excited state in an electron means they're on outer shells further out than they're supposed to be and then at one point they just jump towards the core and they release a photon. And depending on how far they jump that gives the photon more energy and that will lead to a shorter wavelength which will then lead to a different temperature to a different color. In the spectrum we can see this part of the spectrum, the flying photons which are released by it. This is the visible spectrum. Humans, most humans have what is called trichromacy. That means in our eyes we have color cones for three different colors, red, green, and blue. And these colors are sensible to certain wavelengths. So we have a certain sensation in them depending on the light that enters our eye. So if we have blue light then we have an extreme sensation in the blue color cones and where weak sensation in red and green and if we have red light then we don't have a sensation in blue, et cetera, et cetera. We can also imagine it here, simplified. So these are the color cones. So it's from cold to hot. So if we have a sensation in red, we see red. We have a sensation in green, we see green, we have a sensation in blue, we see blue. If we have a sensation in both red and green we see yellow because our brain assumes that imagine the x-axis being the wavelength. Our brain assumes that we see light with the wavelength that corresponds to yellow. So what happens if we have a sensation in blue and red? Mathematically it should be right in the middle so it should actually be green light but we don't have a sensation in green cones so it can't be green light, can it? So brain is maybe confused about this and it doesn't actually show us green light, instead it makes up a new color, magenta. Well, what actually happens if we have a sensation in both red and blue but not in green is probably two light sources hitting us at the same time but does that mean, is magenta real? And this principle with the three different color cones actually resulted in how we implement color, how we treat color. If we use magenta in a website we give it the color that we add red light and add blue light but no green light. And this directly translates in how our monitors work. They're actually just red, green and blue dots. Interestingly, if a satellite takes a picture it actually takes three pictures shortly after each other for the different colors and then planes move too fast and you get a picture like this. So you could argue this is a leaky abstraction. A lot of information is actually lost from the original light source. So imagine the periodic table. I'm going all over here. Imagine the periodic table of elements. One way to figure out which element you're dealing with is by pumping it full of energy and then it starts glowing. And as I said, if it starts glowing that means electrons are jumping shells releasing photons, not protons, photons. My big fear with this talk is that someone comes up to me after this talk and says that I was completely wrong with what you just said. So judging from the light that comes off at such an element you can actually find out what element it is. This is a periodic table for looking at the light spectrums. This is really important when you think about space. Space is big. You might think the way down the road to the chemist is big but that's just peanuts compared to space. Give you some perspective. Earth compared to all the other planets and suns and so on. The interesting thing here people don't often realize when it comes to space travel is so the ISS flies something slightly more than 100 kilometers above Earth so that's, I don't know, 10 times the height that normal planes fly at. So if you look at the second picture if we would draw the ISS in there it would seem like it's actually on Earth because the distance is too small. The distance between Earth and the moon is large enough to fit all planets from our solar system in. So it would be somewhere here. This is how far they went in the 60s. Now we don't even make it here. It's just something to think about. But anyway, I was talking about light. So light is very interesting when you want to decide how old the star is. There's this thing, I think it's called a Hatsprung Russell diagram or something where you basically have the light color down here that's emitted by a star and then you can enter it in the graph and these are different paths they can take. So if you take, so this is a star somewhere here you have the luminosity and the color and then if you have those two you can put it on this map and then you can figure out what stage this star is in. You have different paths you can take. This is the normal sequence where you go from the youngest up here to the oldest down here and there are also other things in there so you can't just judge from the color but it helps a lot figuring out how old the star actually is because the older a star gets the more iron and the more heavier metals are there because of the fusion happening with the stars. But that's just an excursory thing that how we store color is a leaky abstraction because you cannot get back to the color spectrum to the actual frequencies from a JPEG file. But the thing where this becomes way more obvious is tetrachromacy. I think I got that right. There are four different color cones and you might think what's the use case? Why would we encode in four different color cones or in four different colors? So one use case is if you have a startup that rather than targeting humans it's targeting birds. Actually for most mammals this is irrelevant because most of them only have two different color cones so their brain doesn't even show them magenta. But birds actually have a fourth color cone and it's gray in here it would be a different color so we can't visualize that with just three colors because it's outside our visible spectrum. So birds, I'm not writing software for birds. We need a new HTML standards for designing websites for birds. No, the interesting thing is actually some women have four different color cones and because there's no large data set on that the estimates are that they're either two to three percent of all women or fifty percent of all women. What's pretty sure is nearly all men have three color cones and that is because of the genes. Color cones are inherited on the X chromosome so you can get three per chromosome so if you have one Y chromosome, one X chromosome you can have three maximum. Those are actually the names of the gene in case you want to patch your gene. Someone did that, published it on GitHub and someone sent a pull request to the genome. But if you do the math, women in theory could have up to six different color cones and so a lot of women, even if it's just two percent of the female world population we're still talking millions of women. So why have we never really talked about this? Because they're mostly dysfunctional. Mostly women only see as many colors as men do but there are at least two confirmed cases. One recently and one in the 40s when the theory first came up where women definitely had four different functional color cones and that allowed these test subjects to see millions, millions of more colors than the normal human being. Imagine having four different color cones. Not only can you see more colors you can also have more scenarios where your brain invents new colors. There's a standard scenario which might probably be magenta but you could also have those to have a sensation or other combinations. So is this a leaky abstraction? Why are those dysfunctional? Why are the color cones dysfunctional? I have my own theory that I'm going to share with you. I have not done much research except for reading Wikipedia and watching a BBC section on this but here's my idea why. We don't see colors with our eyes. We see colors with our brain. It's like, whoa, brain. And our brain adjusts colors. This is for instance, if you take a picture in here like I see that someone's shirt is white but if you take a picture without changing the settings, okay, nowadays our cameras are pretty smart but the light would be colored by whatever the color of the light up there is and then you need to adjust the white balance. Our brain does all that. It can even turn green into blue or yellow if all the context around it is also some sort of green. And interestingly, we start seeing color in the first three months of our life after birth and experiments with toddlers that were not able to speak yet, that were three, four months old showed that they see colors with the left side of their brain. The left side is active when they see colors. Now, we don't see colors that we don't have the abstract concept for so the color vision develops, we get the concept in our brain and then we can differentiate the colors. I kind of come back to the toddlers in a second. But first, wow, a double rainbow. How many colors does the rainbow have? Seven, six, five, four, a trillion. Yes, it's gradients. We see seven colors because we are trained to see seven colors. When this toddler learns to speak, the color perception, the part of the brain responsible for seeing color moves from the left side of the brain to the right side of the brain. This, I think, means that color perception is linked to language. Has anyone here been at Rubicon for Australia, not the last one, but the first one? There was a keynote by Dave Thomas there? No? That's, okay, some, oh, the Australians. Because I can repeat something from the keynote, so it might be boring if you had already seen it. He had a section in there about the Himba tribe from Namibia. They are well known for putting clay in their hair and for having a different concept of colors. So the Limba only know four different colors. And the interesting thing is they draw the lines between colors at different points than what we do it. So dark blue, red, green, and purple for them are the same color, and some shades of green and blue are a different color, and so on. They actually translate it with black and white and say things like, the sky is black, the water is white. So they do not have as fine-grained a color concept that we have, and it actually differs from our concept. So there was an experiment with them where they measured how quickly they can tell apart colors. So they showed them a circle, different colors in the circle. Hope you can see this. So where is the square that has a different color? Yes, everyone's pointing at this, I think. I hope. Anyone not seeing that? Okay. And you should check this out, the BBC video. They actually have a really hard time finding the square. Most of the tribesman actually point at the wrong square first. It takes them a long time to concentrate and see where it is. On the other hand, if you show them this one, they instantly point out the one with the other color. Can you see it? Anyone? It's this one. You actually see it better on my screen, but it's still hard. I see it instantly because I watched the video. They simply don't have the concepts. The abstract concepts of color, abstraction happens in our minds. And I think this is true for all abstraction. Object-oriented programming is not something that happens on our CPU. It's something, it's a way that we think about programs. It's a way that allows us to quickly grasp how to model a problem. It's a way that allows us to communicate programming. UI happens in our mind, not our computers. Our screen just shows us red, green, and blue dots. Our mind turns it into a button. And our mind is trained for these abstractions. Anyone who has parents or grandparents that grew up without a computer and now have to sit in front of one, those people usually don't have the abstract concepts to easily grasp and understand UI that we use today. Who knows what this is? Anyone? Yes, this is Douglas Adams. And he said that anything that's in the world when we're born is a natural part of the way the world works. Anything that's invented between our 15th and 35th birthday is exciting and revolutionary and can probably get us a career. Anything invented after we're 35 is against the natural order of things. You can take this further. Most of the things we take for granted, the way the world works, are abstractions. Countries are abstractions. There's no physical... Like, countries is not something in the physical laws. This doesn't mean countries don't exist. They exist as abstractions in our minds and are very powerful for that and enable us to do things. And don't let me get started on religion. They exist in our collective minds. This is the important part, that we share these abstractions. And extending the abstractions that we share and changing these abstractions is a basic principle of innovation and progress. It's what's referred to as a paradigm shift sometimes. So, is magenta a color? Should we vote? Who is in favor of magenta being a color? Okay. Who's in favor of magenta not being a color? It's a mix of two colors or something. Green. Magenta is green. Down with the middle color cone. So, actually... So, the argument goes for people claiming magenta is not color is, here is the visible spectrum. I had it earlier. The rainbow. Now show me magenta. Well, actually the visible spectrum is more like this. On the outer line is the frequency. And then if you mix multiple light sources, multiple single frequency light sources, you get extra spectral colors. Those are... is everything what is not on this line? So, if you say magenta, which is down here, is not a color, that means everything in here isn't a color either. Which kind of plays into my art teacher telling me that white and black are not colors. But I think claiming that everything here is not a color, you just redefine how color works, what the definition of color is. So, I actually personally think, yes, magenta is a color. But then again, color is nothing that really exists, except for in our minds. It's when you think about... there was a visualization that recently went around the internet that this is a real unmodified picture of some virus under an electron microscope. And it was brown, and the skin had skin color, or something that was sitting on some cell, I don't know. So, which color do atoms have? They don't. Because what we see is photons, not atoms. It's electrons jumping. It's something our brain adds to the light. There's one last thought I want to leave you all with. Vote for Pedro. Thanks. Mantis shrimp eyes. 16 cones, I believe, 12. Something like that. I'd love to see the universe through their eyes. So there's another interesting part. Our color cones are actually able to see ultraviolet light. But because of the wavelength of ultraviolet light and the form of our lens, the ultraviolet light usually does not reach our color cones. So if you have your lens removed for medical reasons, you start seeing ultraviolet light. And it usually seems kind of white because all three color cones are sensible to it. But the blue one is more sensible. So, you see it a whitish-blueish. Also, you don't have your lens, so you have a hard time focusing. Like, actually not in your brain, but actually focusing on things. But you see ultraviolet light. Okay, any other remarks or questions? Yes? I have too many slides. Ah, wait. Some more. Basically, I just wanted to clarify that the colors... It's not the colors that show what atom it is. It's the absence of the color that actually shows what atom it is, right? Ah, or yeah, it's what's present in there. It's the black parts. Because the atom absorbs or... No, so this is not the light that's reflected by something. You cannot tell what an element is if you shine a light on it and then see what's reflected because they can only reflect whatever light source falls on them. This is actually the light they emit when you pump them full of energy and they start glowing themselves. Because I was watching one documentary about how they determined the atoms in a star. And the meter that they use actually detects the absence of these particular spectrums and it's the absence of the... I think that's basically equal to just what's easier to identify because it's also... Because our sensors work like our eyes so they don't actually see the frequency. So what they do is you actually use the wavelength. There's a thing where they send them through a magnetic field and then they fly in a curve and then you see how far from the entry point they land. And I'm not actually... I'm not a physicist. I don't know, but it's actually the light they emit. So the light spectrum, the light they emit depends on which jumps they have, the electrons, when they are excited, how far they jump. And so if certain elements have more shells and electrons on certain positions and some electrons are free and some are not, then you have different jumps. So that's also why you see that actually there is not a one-to-one mapping between frequencies and elements, but there are certain frequencies that a lot of elements have and certain frequencies that not all the elements have. With the dude. Cosmos, SciShow, YouTube or the television? The SciShow with the guy. So if you have any other feedback, feel free to hit me up later. I'm probably more relaxed now that I'm done with my talk. Thank you.