Wouldn't it be cool if you could pay $20 or so to hop on a quick call and talk it through with a real chef?
I argee, while I personally don't cook, I would definitely love to be able to call a professional when needed.
Calling is especially nice too. I sometimes find asking help inconvenient because it will take my friend hours to respond, and calling them seems too unnecessary/costs too much social credit.
Main idea: When you have a question and are googling around for an answer, you're basically searching through a space of information, and seeking an answer to your question in this space. Sometimes you're able to find your answer quickly. Sometimes you aren't. But if you are able to ask someone for help, they'll often be able to just tell you the answer right away. This is helpful and is analogous to an O(1) lookup in programming.
In elaborating on this, I will start by discussing what Big-O notation is, and then I will talk about how it applies to asking for help.
Big-O
Math
In programming, Big-O notation is a thing.
Actually, no. It's not a programming thing. It's a math thing.
Imagine you have the function
f(x) = 2x^2 + 7x + 22
. I'm not sure exactly how to phrase this... but approximately how fast doesf(x)
grow? Well, we could just squint and look the highest order term, which isx^2
here, and say that it has quadratic growth.And then we can say that
g(x) = 7x^3 + 4x^2 + 9x + 88
hasx^3
as it's highest order term, which we call polynomial growth.And for
h(x) = 6x + 2
, it's linear growth.Saying that
h(x)
grows linearly isn't as precise as saying that it grows according to the expression6x + 2
. However, it is easier to say when chatting casually. We can use phrases like "this grows linearly" and "this grows quadratically".Programming
In programming[1], we apply Big-O notation to something called time complexity. Basically, we want to know how long it will take for a function to run.[2] Is it going to take linear time? Exponential time? Etc.
For example, the following function[3] will take linear time to run. We're iterating through the list, item by item.
On the other hand, the following function will take quadratic time to run. We're iterating through the list... but for each element in the list, we iterate through the list again.
Here's a different example. You know that game where someone asks you to guess a number between 1 and 100 and will tell you if your guess is too high or too low? The strategy[4] is to start by guessing 50, then maybe they tell you it's too low, so you guess 75. Then they tell you it's also too low, so you guess 87. So on and so forth.
The idea is that, for each of our guesses, we want to reduce the search space by as much as possible. Initially the search space has a size of 100. Imagine that we guessed 10 and were told that we're too low. Now we know that the answer is between 11 and 100. This only reduced the search space by 10 though. Instead, if we guess 50, we can cut it in half.
And by cutting it in half with each of our guesses, we can arrive at our answer in logarithmic time. Which is much faster than linear time (ie. performing an exhaustive search by going one-by-one).
There's something cool though. It's called constant time. Let's go back to math for a second here. How fast does the following function grow?
Well, um, it doesn't.
Ok, now let's jump back to programming. How long does the following function take to run?
I won't describe why it is the case since I think that'd be too much of a tangent, but just take my word for it: the code is able to grab and return the last element ~immediately.
So for example, if
list
is[1,2,3]
, it'll grab3
just as quickly as it would grab100
in a list of 1-100. As an imperfect analogy, imagine that you have 10 apples in front of you. You can grab the third apple just as quickly as you can grab the 10th.[5]Asking For Help
When you have a question and are googling around for an answer, you're basically searching through a space of information, and seeking an answer to your question in this space.
<thead>
For example, earlier today I was seeking an answer to the question of what the purpose of the
<thead>
HTML element is.The space of possible information includes things like, oh, I don't know:
Given that I'm not a rock, I can use my judgement and infer that walking over to my bookcase and opening up Surely You're Joking Mr. Feynman is unlikely to lead to me figuring out what the purpose of the
<thead>
HTML element is. Similarly, I'm100-ε%
confident that opening my refrigerator is not going to yield the answer I'm looking for. By not being a rock, you can narrow down the search space by a massive, massive, massive amount.As seen in the diagram above, there are a bunch of places I can look where it's plausible that I find an answer to my question:
Still, exploring this space isn't always fruitful. It wasn't for me.
<thead>
, but to my surprise, it didn't have an answer to my question.<table>
, and it too didn't have what I was looking for.googledduckduckgoed[7] around. Still no success.html-table
. Still no success.At this point, a lesser[8] web developer would have given up. But being the stallion that I am, I grit my teeth and continued my stackoverflowing.
Soon after, my efforts were rewarded. My curiosity was satiated as I discovered that aside from accessibility and semantics, there are in fact concrete reasons to use
<thead>
:Anyway, this post isn't actually supposed to be about
<thead>
. The bigger point is that there was actually a decent amount of friction in finding an answer to my question. And, relatedly, if I was able to just ask someone, it'd be much easier. AnO(1)
lookup instead of anO(?)
lookup.Of course, this doesn't mean that asking for help immediately is always what you should do. I'm just pointing out an advantage.
In practice, most people recommend spending
N
minutes looking into it yourself before asking for help. My impression is thatN
ranges from, say, 10 minutes to 120 minutes in most contexts. And I usually endorse this recommendation. Seek to overcome the obstacle of trivial inconveniences, a good hacker must.[9]Quinoa
Let me tell you about what drove me to think about this.[10]
I had this startup idea to let people pay to video chat with chefs. Like, suppose your chicken always comes out dry and you want to do better. Wouldn't it be cool if you could pay $20 or so to hop on a quick call and talk it through with a real chef?
In discussing this with people, I was told (universally) that there's no need: you could just google it or go on YouTube.
Which got me thinking. I think there's a lot of truth to that. However, sometimes it's just kinda difficult to do so. For cooking chicken breasts, it's relatively easy to find good guidance.
But what about, I don't know, using a meat thermometer? I actually ran into difficult with a meat thermometer myself. And despite my well above average google-fu, I just wasn't really getting the clarity I wanted. So maybe there's demand here? I'm skeptical and gave up on the idea, but it's possible that the opportunity is real.
One of the people I spoke with is a popular food YouTuber, Helen Rennie. As a benefit for her Patreons, she offers to respond to emails about cooking questions. I took advantage of this, and it was pretty awesome.
I watched this video of hers on quinoa and sent the following email:
And I got a response addressing all of my questions! Awesome!
I'll spare you the details, but they're just things I wouldn't really have been able to easily figure out on my own. So then, the
O(1)
lookup, in addition to being a really awesome experience, yielded me a resolution to my question in a situation where theO(?)
alternative would have been intractable.Note that this is further down the ladder of abstraction (I think?) from what we were talking about before (how fast an abstract mathematical function grows).
In proportion to it's input. In the worst case scenario. Although best case time complexity and average case time complexity are also things that people care about.
Note to my fellow JavaScript programmers out there: I'm using
function
andvar
in an attempt to make this more easily understood by non-programmers and non-JavaScript programmers.Well, at least that's the strategy if you assume the number between 1 and 100 is chosen at random. That isn't always the case though.
Imagine you guess 50, then 75, and then 87. You might anticipate that the person who chose the number wants to mess with you. So instead of guessing 94, then 97, then 99, and then 100, you might just want to guess 100.
And this is why computers will never be smarter than humans.
Just kidding.
Now, if there were 100, the length might be kinda long and so the 100th might take you longer since you have to take a few steps to your right, but if we imagine that you have really long arms, which metaphorically, the computer does have, it'd be just as easy to grab the 100th.
I didn't think to do it at the time, but in retrospect, I probably should have checked out the W3C spec. But funnily enough, I just checked it out, and to my surprise again, it didn't really give me what I was looking for.
Y'all need a better marketing department.
Or, alternatively, someone with better things to do on a beautiful Saturday afternoon.
I don't actually endorse that post I link to: How To Ask Questions The Smart Way. Well I endorse a lot of what it says, just not all of it. In particular, I think a) the bar for asking a question should be lower (in most contexts) and b) it is too unfriendly.
Maybe it would have been better if I started the post off with this. It probably would have.