00:00:14.960
Hi, these are my slides. I came here a long way from Berlin. That is, if you want to walk here from Berlin, it would take you two and a half months.
00:00:22.199
The reason I'm mentioning this is because there seems to be a theme here. Who was here for last year's conference? Last year, the keynote speaker, Chad, was also from Berlin.
00:00:34.000
This is a photo of us, obviously in Berlin, hanging out on a camel—that's what we do in Berlin. So, next year, your keynote speaker will probably come from Berlin too; I guess it's just a given. Anyhow, I think we're already behind schedule, so let's get started with the talk.
00:00:51.559
I'm not actually going to talk about Sinatra, in case you didn't notice that's what I'm the maintainer of. I'm going to talk about abstraction on quite an abstract level. But I'm also going to talk about color, specifically magenta—not Magento, not Magneto, magenta or anything from the purple-violet spectrum.
00:01:09.080
This talk is very meta. I'd like to open with a quote that is kind of my motivation for talking about abstraction. Douglas Adams said, 'Anything that’s in the world when you’re born is normal. Anything that’s invented between the ages of 15 and 35 is interesting and new and shiny, and anything that’s invented after this age is against the natural order of things.'
00:01:21.000
I want to talk about computer science and color perception. This talk might be kind of confusing because I'm jumping back and forth between topics. So I thought I’d just start with a conclusion. Usually, you put the conclusion at the end, but I’m prioritizing it at the start to clarify what I'm talking about.
00:01:39.720
I think that abstraction happens in our minds. Abstractions shape how we perceive things, and changing abstractions is a basic principle of innovation and progress.
00:01:46.400
Abstraction, I think, is the basis of computer science. Would you agree with this? I see some nodding and head shaking. I actually think abstraction is the basis of science, and science rocks! Without abstraction in computer science, we would always be talking about transistors.
00:02:01.680
That's already an abstraction over how electrons move in a medium. But without abstractions, when I write my web app, obviously in Sinatra, I would just be thinking about the transistors I need to serve an HTTP response. Instead, we can write code like this without having to worry about the hardware it's actually running on.
00:02:20.280
Speaking of electrons, this is an electron, or this is an atom with electrons. The lowest energy that an electron can have is called the ground state. When the electron or atom has a higher energy than its lowest energy, it is said to be in an excited state. The states of the electrons are quantized—that's what we call quantum mechanics.
00:02:39.720
These electrons are excited, which means they are flying at a higher energy level, further away from the core. At one point, they jump back down to the ground state, releasing a photon. This is generally what we refer to as light.
00:02:57.199
Actually, only a fraction of that is what we refer to as light because that is the visible spectrum—the light that we can see. The frequency of light we see depends on how far the electrons jump, and therefore we perceive different colors corresponding to different frequencies within the visible spectrum.
00:03:13.240
Humans' vision works based on a principle called trichromy, which means that the retina in our eyes contains two types of photoreceptors: rods and cones. The rods are more numerous and sensitive but do not detect color, while cones, of which we only have about six to seven million compared to 120 million rods, are sensitive to color and are concentrated in the center of the retina called the macula.
00:03:35.840
There are three different types of cones that are generally responsive to different colors. This is a graph that represents the frequency and sensitivity of the different types of cones to light at various frequencies. The blue cones respond strongly when light of a particular frequency hits them, while other cones respond weakly.
00:03:54.960
The same principle applies to the opposite end of the spectrum, where our red cones respond, but our blue cones may not. You might notice I'm jumping around a lot; this is intentional, and I hope it all makes sense in the end. Patterns and algorithms are crucial in this discussion.
00:04:19.320
There was a very interesting book that I recommended to someone yesterday or the day before. It came out in 1977 and is called "A Pattern Language" by Christopher Alexander and others. It's the second book in a three-book series, with the first being "The Timeless Way of Building" and the third being "The Oregon Experiment." In this book, Anderson argues that to talk about architecture in general, from interior design to city planning, you need a common language to refer to the patterns you’re using, the style you’re using for building, and the principles behind them.
00:04:49.640
This was so influential that it inspired software developers to apply the same principles to software development. From this, a book emerged called "Design Patterns" by what is usually referred to as the Gang of Four, which was published in 1994. This is where we derive principles such as Singleton classes, Flyweight, and so on. A lot of the terms we use today to communicate about software come from this book.
00:05:10.399
There’s also a nice quote by Christopher Alexander, the architect, who wrote the forward for Richard Gabriel's book, "Patterns of Software," which came out two years later. In that book, he states, "I would hope to see examples of programs which make you gasp because of their beauty, and perhaps a more widespread knowledge of them in our culture so that lay people, like me, could also begin to grasp the beauty of programs."
00:05:29.200
For that, we need abstract concepts like those patterns to reason about software and to understand what beautiful software looks like. We need concepts like algorithms—where programmers use the word if they don’t want to explain what they did. Who can tell me what algorithm this is?
00:05:45.559
[Pause for audience interaction] Yes, it's the Quick Sort algorithm. Feel free to yell at me; I'm probably not going to take questions, so shout things out. This is Quick Sort, which has nothing to do with what the program using Quick Sort actually does; it’s just an abstract algorithm.
00:05:54.160
Let's talk about the cones again; these dots represent the cones and where they are on the slide represents their sensation or excitation. I simplified this, pretending that the cones are very distinct for certain frequencies. Initially, the cones do not perceive anything; it's dark.
00:06:14.560
Then red light comes in, and your red cone feels a sensation, causing your brain to recognize it as red. The same goes for green light; your green cone feels the sensation, and the same for blue. However, there are more frequencies than just red, green, and blue, so when you see yellow light, both your red and green cones will feel a sensation, and your brain will recognize it as yellow.
00:06:38.960
But what happens if both your red and blue cones feel a sensation while your green cone does not? In that case, your brain assumes that the sensation lies somewhere in between red and blue. Right in between red and blue is green, but it can't be green since the green cone is not activated. Thus, you could argue that your brain creates a new color outside the spectrum: magenta.
00:06:56.400
When I write CSS, for instance, the hash code for the color magenta indicates that it contains all the red light and all the blue light, but none of the green light. This representation is an abstraction of how we represent color on our monitors.
00:07:13.280
Monitors cannot actually produce all colors; they only have red, green, and blue dots; each pixel is made from these three colors. This could be considered a leaky abstraction. I'll get into this in more detail later, but an interesting observation is that when taking color pictures, some cameras take separate pictures for red, green, and blue.
00:07:31.680
An example of this is satellites; Google Maps utilizes a similar technique. If there's a fast-moving object, you'll begin to see different colors in the photo. In the realm of computer science, different kinds of abstractions exist.
00:07:47.680
The first abstraction we will look at historically is data abstraction. The first book I encountered on programming during my childhood discussed selecting the right data types or structures. The argument was that your data structure determines if a program is good or bad and whether it performs well or poorly.
00:08:04.560
This book suggested that before writing any code, you should think about the data structures you’re going to use. Who here does that? Raise your hands. Okay, I should talk to you all later because I don't typically do that.
00:08:29.520
In 1967, there was a paper arguing against that approach called "Dataless Programming," which stated that the way most people write software—thinking about the data types they will use before coding—can lead to trouble later when they need a different data structure.
00:08:52.320
The paper argued that programming languages should allow us to write code irrespective of the data structures we will use. Many of us now refer to this as keeping our business logic separate from our persistence layer or memory management.
00:09:12.560
Space; space is big. You just won't believe how mind-bogglingly big it is. You might think it's a long way down the road to the chemists, but that's just peanuts compared to space. Who here is fascinated with space? That’s more people than who thought about their data types—great!
00:09:35.680
But, back to data structures: There's a lot of space out there, but in that space, there are also interesting entities like planets and stars. Apparently, we're all supposed to be made out of star stuff, sometimes referred to as stardust.
00:09:57.520
As a side note, I like to geek out on things. If you disregard the space between the atoms in our bodies and just count the atoms, we’re actually about 38% star stuff because the rest is hydrogen, which is the base state—the atom that has not been created by fusion.
00:10:14.520
Now, you might say, 'Wait! What are we still talking about with abstraction?' Yes, at least I think so. Maybe because I'm referencing the periodic table. The interesting thing is when I mentioned how electrons jump towards the core and release photons.
00:10:39.200
The way they jump depends on how many quantum states an atom has, which is directly related to the number of protons an atom contains. As you may know, the numbers in the periodic table correspond to the quantity of protons.
00:11:00.240
From the emitted light of atoms while they glow, you can determine which kind of atoms they are, producing emission lines. Do you know what the emission spectrum of iron and a cat has in common? Yes, they both have Fe lines!
00:11:16.199
This is very useful for determining the composition of a star because stars fuse materials and have glowing atoms; we see the light they emit, and we measure the wavelength to create diagrams.
00:11:35.320
However, you can't use a normal camera for this but rather need a specialized one. The normal camera does not capture the wavelengths; it only saves values for red, green, and blue—just how we perceive them. This could become a leaky abstraction.
00:12:01.480
Besides data abstraction, there's also control abstraction. Today we take control abstraction for granted, yet those ideas were groundbreaking. The first idea of control abstraction was subroutines—a piece of code you can place elsewhere and call upon. This led to reusability and public debate.
00:12:17.560
In 1968, Dijkstra published his famous letter, "Goto Statement Considered Harmful." Then, in 1973, James H. Morris Jr. wrote a paper titled "Protection in Programming Languages," arguing that the ability to isolate programs into modules is vital.
00:12:35.960
In his paper, he also advocated for enforcing this isolation and discussed mechanisms to sign or encrypt data structures so that other parts of the code don't interfere with them. Today, this notion has evolved to the concept of public APIs—data you should manipulate compared to data you ought not touch.
00:12:54.080
The important takeaway is this: you should be able to reason about modules and isolation. To me, this lays the foundation for things like test-driven development, libraries, and reusable code in general.
00:13:16.319
Further developments in the '70s introduced ideas like global state and global variables, which should be avoided whenever possible. As I mentioned earlier, humans have trichromacy, while there is also a condition called tetrachromacy, which involves having four different cones. Zebra finches and goldfish are examples of species with four different cones.
00:13:39.160
Those four cones are sensitive to four different wavelengths. Although the last one likely isn't gray, we cannot distinguish what color it is—it might be ultraviolet. But what color would ultraviolet appear as? This allows them to see millions more colors. You could argue our screens are not designed for zebra finches and goldfish because pictures in red, green, and blue do not fully represent the world they see.
00:14:01.800
But it doesn't matter; we’re not making video games for zebra finches yet. Interestingly, this condition is also relevant among humans. A particular study outlines a method to figure out how many different color cones one has.
00:14:23.040
Depending on the source you reference, somewhere between 2% to 12% of all women might possess this genetic mutation where they can have more than three cones. Statistically, it could be up to 50% for women. Why women? The answer lies in chromosomal genetics.
00:14:43.600
Our cones are connected to genes on the X chromosome, specifically OPN1MW and OPN1W2, giving up to three different color cones. If someone has one X and one Y chromosome, they might just have up to three different color cones. But if they have two X chromosomes, they can potentially possess up to six different color cones.
00:15:05.720
To date, I found at least six confirmed cases of individuals with true tetracromacy, confirmed by the methods specified in the paper. The first confirmed person was identified in 2012, and this phenomenon allows them to perceive up to 100 million more colors than we do.
00:15:28.960
Interestingly, this condition also occurs in New World monkeys, where male monkeys usually have two different color cones while female monkeys possess three. A particular artist from San Diego has tetracromacy and paints the world as she experiences it. You might not easily see the differences in light, but there’s an abundance of pink in her work.
00:15:48.080
What’s fascinating is that these individuals don't just perceive more colors from the spectrum; having four different color cones might enable them to see colors that can't be identified with our typical systems.
00:16:10.080
Object-oriented programming (OOP): Who recognizes this guy? [Audience interactive session] Yes, come on! Any guesses? Santa Claus? No, it’s Alan Kay. When I first used this picture during a slide talk, the meme of Sean Cripps holding things was very popular. Has anyone seen that?
00:16:35.720
Just me? I'm the only one? Sean Cripps is a developer famously known for holding items. I created a meme of Alan Kay holding similar items. Alan Kay is often referred to as the inventor of object-oriented programming and many more concepts, including the laptop computer and graphical user interfaces.
00:16:53.280
However, he didn’t work alone; he was part of the team at Xerox PARC at the time. When a visitor came to see them, they showed him three revolutionary things, but he missed the first two: object-oriented programming and networking.
00:17:15.920
The third spark was the revolutionary graphical user interface. The GUI they showcased was Smalltalk-80, both a programming language and an environment in which to program it. Today, the successor to Smalltalk-80 is Squeak, which is still in use.
00:17:32.320
This was one of the first fully object-oriented programming languages, from which many core ideas of OOP originate. When discussing object-oriented programming, I was told that JavaScript isn't considered object-oriented because it lacks classes.
00:17:49.480
You could make a point about that; JavaScript may not be object-oriented, but it has nothing to do with classes because object orientation isn’t strictly about classes. Alan Kay believes that object orientation comprises message passing, hiding of state, and extreme late binding.
00:18:06.480
Thus, you could argue that object orientation results from combining data abstraction and control abstraction. Why are these cones dysfunctional? This is my interpretation based on various readings and resources.
00:18:21.680
It seems to me we don’t see colors with our eyes; we see colors with our brains. Think about it; our brains adjust colors. Light may appear red or blue, yet it looks white to me because my brain perceives it as white, regardless of its true color.
00:18:43.520
Additionally, it appears we don't perceive colors we lack an abstract concept for. There's a theory known as the Sapir-Whorf hypothesis or linguistic relativity, proposing that the language we speak affects how we perceive the world.
00:19:05.440
There are strong and weak versions; the strong version claims it determines perception while the weak version suggests it influences it. So how many colors are in a rainbow? Any guesses? Five? Seven? Ten? It's actually ten million; those are fine gradients.
00:19:27.920
There’s no border between one color and another, yet we see distinct colors due to how we've trained our brains. My brain has been trained to perceive green and blue; for instance, when we learn to speak, color perception shifts in the brain.
00:19:47.680
The area used for color perception before we acquire speech is then used for language. This indicates a potential link between language and color.
00:20:09.040
What I love most about programming is that we create the rules, and some of these rules enable effective programs, like the Single Responsibility Principle. Have you heard of it? Yes? No? Likewise, has anyone heard of the Liskov Substitution Principle? Can you define it?
00:20:35.680
You should be able to replace an object with one of its subclasses without issues? Not quite. The intention of Liskov’s principle is tied to types rather than classes. The principle states that if you have code designed for a specific type, it should work correctly with any subtype.
00:20:54.080
I would argue Liskov's formulation in 1994 wasn't particularly clear about classes even though it talks about types and subtypes.
00:21:19.040
There's a set of principles called SOLID, which comprises multiple principles. Does anyone know which principles they are? Yes, gold star! One of the principles I endorse is: don't abstract too much too early.
00:21:39.920
Occasionally, I receive pull requests for Sinatra that attempt to replace inline methods with code generating those lines only two lines shorter, which complicates readability in my opinion.
00:22:01.760
Strong external abstractions permit weak internal abstractions. Envision distributed applications. At TravisCI, we're a fully distributed application. The best part is if you develop small applications doing a singular task.
00:22:19.200
Having a well-defined interface over HTTP enables you to use any tech you choose; you could write terrible code because if a problem arises, it can likely be rewritten in a day or two.
00:22:37.040
So, is magenta a color? Any takers? Yes? No? So these are the colors we observe in general; only the colors on the outermost line have a singular frequency. The areas where green is absent represent my reference for colors.
00:22:54.920
We need to rush a bit through inheritance. Inheritance can be used for multiple purposes, such as type hierarchy and implementation sharing.
00:23:14.560
Classes are utilized for type hierarchies and for sharing implementations; recognizing when to employ which can become quite complex, especially with mixins.
00:23:32.720
I believe both use cases are valid; however, I think Ruby programmers should embrace composition more, as merging type hierarchies with implementation sharing can be quite complicated.
00:23:53.840
You can even have type hierarchies without inheritance, as seen with duck typing.
00:24:09.680
Are we doing it right? That’s something we should seriously consider. As I mentioned earlier, classes are not essential to object-oriented programming.
00:24:26.960
Color abstractions lead us back to why I keep referencing color in this talk. There exists a theory regarding language evolution in relation to how we perceive colors.
00:24:43.520
This particular book sparks considerable debate—not because everyone disputes it, but mostly about the order in which we learn colors. Many languages, especially during their early stages, do not have distinct terms for green and blue.
00:25:04.480
This makes it more difficult to differentiate between green and blue. This theory outlines the various stages of civilization and the associated color terminology. For instance, the Himba tribe in Namibia has a distinct vocabulary for colors.
00:25:23.760
To demonstrate, they conducted a test showing two pictures with varying colored squares—they were tasked with identifying the square with a different color. Initially, they struggled to identify the square after some time, but when shown another specific scenario, they quickly pointed out the dissimilar square.
00:25:42.960
This highlights how abstraction can metaphorically blind us, sometimes masking our ability to see and analyze as clearly as we can.
00:26:05.360
Abstraction becomes a security concern, whereby shifts in abstraction levels can lead to systems being exposed in ways builders of the system did not anticipate.
00:26:31.680
Often, attacks exploit these transitions. Conceptually, SSL is secure; however, the implementation may lack essential checks. For example, the Heartbleed attack involved moving down to the implementation level.
00:26:53.840
Alternatively, an attacker may switch up, leveraging the tendency for users to reuse passwords across services and thus logging into their iCloud accounts to access their private photos.
00:27:12.640
In one example, a hacker falsified entries for the US Secret Service and FBI on Google Maps, creating a proxy that rerouted calls to the FBI about a supposed terrorist threat, ultimately recording the entire conversation. Such examples illustrate how abstract concepts can lead to serious vulnerabilities.
00:27:32.480
Abstractions exist solely in our minds. Business logic isn’t something the computer apprehends. It engages only with transistors. Business logic exists as concepts in our minds, as do object-oriented programming paradigms, colors, and UI elements.
00:27:55.680
This doesn’t diminish their significance; these concepts hold contextual relevance in our cognition.
00:28:11.040
In conclusion, abstraction occurs in our thoughts. Every abstraction shapes our perspective and changes; these alterations are fundamental drivers of innovation and progress. Thank you, and may the force be with you.
00:28:53.839
You.