In school, I studied systems engineering. I went to an odd college where we learned how to put a system together mathematically, modeling just about everything as a resistor-inductor-capacitor circuit or a spring-mass-dashpot. Because it all boiled down to math that looked the same. This holistic view gave me fresh eyes and I love the hammer-like feel to it.
So when I got out of college, I started to look for nails. Oddly, I actual found some. That led to embedded systems where that same math becomes surprisingly important. I was really good at this! My niche education was going to be useful!
I was still a fairly junior engineer so I explained my plan and process for solution to a senior engineer. i described the math parts, showing a little of my work but glossing over areas that needed to be done. At the end of my show and tell, the senior engineer took all the fun parts away from me and told my manager I didn’t know what I was doing.
See, he called a part of the system the “plant” and I never used those words. And when he used them, I didn’t recognize what he meant. I was a couple years away from my systems courses so part of the problem was my forgetfulness but, at my school, the professors I had called that part the “transfer function”, “system”, or the “process”. The literature tends to use these somewhat interchangeably (not precisely interchangeable, a book usually chooses a term and sticks with it).
It took a long time and a lot of math (and working code) to show I did know what I was doing. Even after that, I didn’t like this senior engineer, he felt so petty. Now I kind of understand what happened- I waved my hands and he probably though the project was too large and important to leave in such untried hands.
This is why I get stressed out when people are nervous about not knowing words. I mean, there is jargon and certainly that plays a role in making people feel like outsiders (and idiots). But sometimes, the words don’t seem like jargon, they are just words and everyone else knows what they mean, I’m just too dumb to understand.
Ahem. No. Words have meaning. Learn the words; understand the meaning. Then you have their power.
Words have incredible power but the most amazing thing about the world today is how easy it is to learn what the words mean. So let’s look at the word algorithm. I’m not going to look it up on Wikipedia for you, feel free. I’m not even going to Google it so I could be wrong in some tiny piece of semantics that are to follow. Watch me not care, I understand the meaning of this word: an algorithm is the word a man uses to mean a recipe.
Oh, I should not read the feminist blogs before writing my own, especially since the connotation is not true. On the other hand, an algorithm tends to be technical, usually related to computers or math based things; a recipe is something one follows when cooking dinner But at the heart, they share a lot: a list of requirements, a list of steps in phrased for the skilled reader, an ideal outcome.
Say I wanted to make cookies. My lackadaisical cookie making method requires a ratio of somewhere between 1:2:3 (butter: sugar: flour) and 2:3:4. Add other things like eggs, salt, baking soda or powder (depending mostly on type of sugar but also other flavoring agents), flavoring agents (vanilla, chocolate chips, peanut butter, orange rind, etc.) to taste. Mix then bake for 5-15 minutes depending on cookie size at 300 to 365F (convection) depending on cookie size and desired texture.
That is neither a good algorithm nor a good recipe. It is a useful direction but not at all a destination. (If you ever want a cookie recipe from me, get it as soon as you can because I won’t remember a recipe the next day.) I’d call that description of how to make cookies a pattern. It is a very loose way to go about it, leading to generally good results. As design pattern: cookie it works pretty darn well (for me).
Of course, if you have no idea what you are doing, it will be a disaster, it assumes a lot of knowledge from the user, knowledge that usually comes from experience. (Ahem, even that mix step hides a ton of potential information though if you take it on the surface, just mixing the dough however you feel so moved, the results won’t be bad).
So as a recipe, a cookie recipe might be:
Simple vanilla cookies recipe
1/4c butter (softened) 1/4c white sugar 1/4c brown sugar 1 egg 3 tsp vanilla 3/4c flour 1/2 tsp salt 2 tsp baking powder Cream butter and sugar. Beat in egg. Add vanilla. Add flour, baking powder and salt. Put on cookie sheet with silpat (or greased cookie sheet), each cookie should be about 1 tablespoon worth of dough, rolled and then flattened. Bake at 325F for 8-10 minutes. Makes approximately 2 dozen. Suggest serving with small bowl of chocolate buttercream frosting for DIY inverse oreos.
I think there is a enough details there that just about anyone can follow that. I suppose I used the standard “cream butter and sugar” jargon and that might be meaningless to some. And I didn’t say to preheat the oven. I kind figured you’d know how to do that. That you maybe had made cookies at some point in your life. What an odd assumption on my part.
I could create an algorithm to create simple vanilla cookies. Let’s see. Since I write software, this is a lot like writing a program to tell a robot how to make cookies.
Simple vanilla cookies algorithm
1. Measure 1/4c butter, heat to soften. 2. Mix in 1/4c brown sugar and 1/4c white sugar until mixture is creamy and has no granular pieces of sugar of remaining. 3. Beat in one egg until fully mixed. 4. Add 3 tsp vanilla, beat until fully mixed. 5. Add 3/4c flour to top of bowl (do not mix in). 6. Add 1/2tsp salt and 2 tsp baking powder to flour. 7. Gently stir dry ingredients together then mix with wet ingredients. 8. Scoop a cookie, about 1 tablespoon at a time. 9. Roll dough into a ball, place on greased cookie sheet leaving about >1 dough ball worth of distance on all sides. 10. Flatten dough ball into a disk about 1/4in high. 11. Repeat 8-10 until all dough is used. 12. Place cookie sheet in preheated convection oven at 235F. 13. Wait 9 minutes, remove. 14. Serve with chocolate buttercream.
Ok, that is a little detailed in spots but you can see how it contains all the same information as in the recipe but in a different format. It isn’t a better format or a worse one, just different. I could have shown it as a flowchart and it would still have been an algorithm. In fact, anything you can represent as a flowchart is probably an algorithm.
Usually, though, algorithms lead to things other than cookies. In pure math, an algorithm might lead to an single answer. Say you want to give someone change… they buy 10 cents of lemonade and hand you a $5 bill. For one algorithm, you (or the cash register) calculates the difference between their purchase and then you given them the difference. It seems so simple, of course that is how anyone would do it. Well, no, the other school of thought for creating change (another algorithm that can be used) is to count up from their 10 cents, handing them pennies until they get to a number divisible by 5 (none), nickels until they to a number divisible by 10 or 25 (none), dimes until they get to a number divisible by 25 (four), quarters until they get to dollars (two), then the number of dollars (four). The whole time counting it out: lemonade was ten cents, twenty, thirty, forty, fifty, seventy five cents, one dollar, two, three, four, five.
Both of these change-creating algorithms are valid. They can both be proven to work. Ok, that is one area where algorithms are different from recipes: proofs. I mean, I can experimentally determine that my cookie algorithm works but doing it. But can I prove it will always make cookies? I don’t know how to start to show that given the conditions described, it will always work.
But in the math and computer world, an algorithm is usually developed so that it works under certain conditions and can be considered optimal in some way. How it is optimal, that is an interesting question (fastest? least possibility for error? least memory used?). When people say they study algorithms, they not only learn all the different ways to sort through a list of data, they also learn how to determine how one way is better than another and under which circumstances.
Well, as usual, I’ve totally forgotten the point of this post. And I find myself strangely hungry for cookies. I hope there was a point. If not, well, I hope you have cookies too.