aleks Gorbenko

aleks Gorbenko

{a_G} | Meditations on Strategy and Tech

20 Mar 2016

How Coding is Like Cooking

I am sure if you have ever been interested in learning how to program, you came across the metaphor about the algorithm, which is a core element of programming.

Author: Algorithm is similar to a recipe of a dish. It is a sequence of instructions you have to fulfill to get the desired result.

I don’t disagree with it, on the contrary -  I just want to take this metaphor one step further…

You see… I used to cook

Professionally, I mean. My educational background is hospitality management and by nature of the business, we had to learn the basics of cooking on the first course. I did learn how to chop properly there (yes, just like Jamie Oliver does in this video). I was also lucky enough to be offered a full scholarship for the culinary course after my first year, which I obviously accepted (who wouldn’t?).

At a time my…

aleks_cooking_skill = 0

and it just happened that there were 6 of us on the course. Everybody were older by 5-10 years than me. Moreover, I knew that a couple of them were already great cooks. I will have to put more effort than the rest to learn the theory and the techniques.

Fast-forward 6 months. The course is done, the practical exam is passed (we had to cook 4-meal course for 4 people anonymously). I came 3rd. Was I satisfied? No. Did I feel like I am a good cook now? No, not really. I was just a small kid who knew how to make some Mother Sauces and have learnt the names of the cooking methods.

One thing that annoyed me was that I knew theoretically how to cook something, moreover - I knew practically how to cook various things, but I still didn’t have this skill to put everything together on a plate! Or make the presentation look beautiful. Creating on my own a great combination of flavours, colors, aromas on a plate was a very very hard task for me. At some point, I thought “Is this creative flair absent in me or what?!”

But well…I kept working, I had one internship, second, where I was exposed to a Michelin Star cuisine. I was good at following and replicating things that other chefs showed me, and I noticed that my…

def skill_up(n)
 n = n + 1
end

skill_up(aleks_cooking_skill)

I could feel that I am getting somewhere. At home, I can produce better-looking and better-tasting dishes. I think less hard about “how I am going to cut and cook products”, instead - I just do it.

So why I am telling you all this

I wanted to build up a bit of context for you to show where I am going with all this.

Having remembered all my time spent in the kitchen I have related my experience of learning how to cook to how I learn to program now with Ruby.

Various programming languages are like different cuisines. You got Ruby, Python, C, C#, just like you got French, Italian, Cantonese, Lebanese cuisines.

In each language, you might have some frameworks: Node.js, Angular.js, Ruby on Rails, Flask, etc. It can be compared to regional cuisines - Cuisine Lyonnaise in France, Napoli Cuisine in Italy, Sichuan Cuisine in China. The list can go on…

What is more or less common in between all of the cuisines? The equipment that you use. Pans, pots, spatulas, whisks, you name it. Some large, some are smaller. Same in programming, isn’t it? We have very similar/same language constructs in languages: Modules, Classes, Methods and others.

To sum up the parallels, here is quick comparison:

Coding

Languages: C#, Python Frameworks: Node.js, Ruby on Rails Data Structure: Classes, Methods Special constructs: Procs (Ruby)

Cooking

National Cuisines: Russian, French Regional Cuisines: Sichuan(China), Napoli Equipment: Pans, Pots Local Specialty Products: Harissa

Getting back to cooking…  I did work in the kitchen as a chef for a bit less than 2 years in total (and I include my 5-6 months on the culinary course here). I was still working for 2 more years in the hospitality industry after my kitchen endeavors and was exposed to 3* Michelin Star restaurants, which definitely helped to develop further the food creativity. It helped. I got there. I skill_up‘ed my cooking skills quite nicely.

Am I great cook today? Probably not. A good one - I think so. And so does most of my friends or whoever tried something that I have cooked. Am I able to produce something that looks nice and tastes great without really thinking about it? Something nice out of “whatever is in the fridge”?  Yes - for both. And I know that now. But I wouldn’t believe that when I started that one day it would be as effortlessly as it is today.

It will be the same with programming. I might be clumsy with code now, but with time and practice, I will be able to code as habitually and creatively as I can cook today. My code will be modular, it will be clean, it will reflect SOLID principles, it will be well-commented, the loops won’t be infinite, I will not miss this darn end at the end of the code block. I will not…well I still can burn an omelette sometimes… so I will make mistakes in code. I know that too.

But I will remember:

Author: Practice makes perfect habit.

OK, now:

aleks_coding_skill = 0

skill_up(aleks_coding_skill)

P.S I fucking hate perfectionism. I might explain why later.