Sunday, April 22, 2018

A Recipe for Writing a Recipe Website

So, about that first recipe website I keep bringing up...

My stint in CS grad school wound up coinciding with my greater exploration of Epicurious.  Since I was working part-time at Starbucks and I didn't have classes every day, I had ample time to cook more and search for new recipes.

As I was new to programming, and it was the early 2000s, I also thought it would be a great idea to put up my own simple web page (...and that code still exists on some random hard drive in my house).

Because I was taking a class on XML transformations at the time, I decided to store all of my recipes in XML and then run them through an XSLT transformer to spit out the HTML everyone sees on a web page.  For the uninitiated, XML was a data format that was expected to encode information in an easily interchangeable format that was also human readable.  Today it's rarely if ever used for newer projects as it turned out to be too verbose and restrictive in its required structure.

So, yeah, XML recipes, but it worked.  Because I got side-tracked by other concerns - namely software engineering in a professional setting - the original website fell by the wayside.  But, it was for all intents and purposes, my first actual completed software project.

And then, much as my cooking career did, my self-directed programming career began wandering in the desert.  I always planned to spend my weekend learning something new.  My typical grand scheme was to use Ruby to write a personal finance site similar to the old installable Quicken application.  Every once in a while, I'd make headway, but would then lose motivation for the next few weeks, at least, in part, because I couldn't convince myself to put in two solid hours on Saturday and Sunday toward my goal, so why even bother putting in any time at all?

This leads me to a brief digression.  Though I'm sure it's prevalent in other professions, the expectation that developers should code in their free time is ingrained in them starting in school.  I'm not sure if it's due to the fact that there are many mythical computer scientists who started programming as hobbyists in middle school or if the industry is seen as so fast-changing that we need to spend more than a typical work cycle keeping up, but it's an expectation.

It's also a dumb expectation.  The word 'passion' is thrown around too much in the software engineering industry.  What's wrong with just being good at your job and furthering your company's business goals as a result?  Why not expand the breadth of your life experiences rather than lock yourself in a room for an additional 4-8 hours per day and slowly slide toward becoming an insufferable bore in order to satisfy some vague definition of 'passion'?  I've heard about companies that turn down potential applicants because they didn't have personal GitHub repositories.  That may lead to a very specific culture, but is that really the type of culture you want to foster?

I have no problems if people want to spend time outside of work on their professional development.  I mean, that's what I'm doing here, but why should that be an expectation?

So, anyway, I didn't get very far on the personal website.  I'd still try some sort of extra-professional learning from time to time, but I was always demotivated by learning a new language or framework simply to solve a set of contrived problems or to write yet another simple blog site.  If I was going to learn a language, I needed to do so in the context of an actual problem rather.

Technically, with the creation of this recipe site, I'm still not really solving a problem that doesn't already have an existing solution, but it scratches a few itches for me -

The problem with most recipe websites is, well, they're blogs.  That's not a problem in itself, but the fact that everyone wants to monetize their blog is.  This means the page load times are incredibly slow as the blogs retrieve external ads for display.  This also means that, in order to actually get to the recipe, I have to go through an entire blogger's backstory before arriving at the recipe, since the more text I have to scan, the more ads I have to see.

While I'm not opposed to this as a business strategy, I don't want to deal with this on every recipe site I cross.  The easiest method for me to get around this is to use existing blog templates built for recipes and write my own ad-free blog for reference.  Blogs, though, aren't designed to index information in the same way, say, a cookbook is expected to do so.  Blogs are generally date oriented.  True, we can actually get around this with some labeling and other simple steps, but this is where the programmer in me begins to bubble up.

Before proceeding, it's probably helpful to review my goals, both for your clarity and my own so I can explain why I'm writing a recipe website.  These are my goals in order:
  • Create a website that stores my compilation of recipes for easy reference.
  • Use the website as a means to maintain a small software project and keep my skills up to date.
  • Use the website as a means to practice some of my other creative endeavors, like drawing.
  • Create a section on the website that explains tools and techniques that may be able to assist new cooks to avoid the pain I faced in my culinary travels.
  • Possibly find a way to make money off the site, in a non-intrusive fashion.
If I just concentrate on the first goal, and possibly the third, fourth, and fifth, then a blog probably gets me where I want to go.  It's the second goal that throws a wrinkle in the execution.

This, though, leads to conflict with my other goals when I'm not disciplined enough to keep the focus on all of my goals.  Why? Well here's my line of thinking on writing my own recipe website starting around November 2016.  Keep in mind that this wasn't my first iteration either, but the thought process laid out here is indicative of previous iterations of this project as well as iterations of other side projects.
  • I'm going to write a simple app and store my recipes on the site in a small database.
  • I'm going to use Google AppEngine to do it.
  • I'm not going to use Google AppEngine to do it, as the framework model they use is going to be too restrictive, so let me find another way.
  • I'm going to research other software as a service sites that will let me write a small app for free or really cheap.
  • Everything is either a pain to start up, acquire access to, or too expensive to use.
  • DigitalOcean seems to be a good place to run my site on the cheap.
  • I still haven't published any recipes.
  • OK, I'm starting to write code on a site called Codeanywhere, and it seems to be a great alternative to the need to write all of my code on my own computer.
  • However, the virtual machines it uses need to be re-initialized every once in a while and installing all of the necessary software is a pain.
  • I'll learn Chef to provision machines automatically.
  • I've learned Chef.
  • I still haven't published any recipes.
  • Why am I spending all of this time writing a program from scratch?  There's probably an open source one I can fork and customize.  Maintaining other software is a valuable skill to have in the industry, so it furthers my goal.
  • There is an open source alternative!
  • It's a bit outdated.  I should upgrade the components that are there.
  • I've learned a lot about code maintenance, upgrades, and Chef.
  • I still haven't published any recipes.
  • I should just write a static site generator so I can actually publish some recipes.
  • Doing so in Javascript will make it much more extensible.
  • These Javascript frameworks are more difficult than they need to be for my needs.
  • I still haven't published any recipes.
  • I'll just write a static site.
  • I've published a recipe!
  • I've learned about Jekyll.
  • I've published several more recipes!
And here we are.

Thursday, April 12, 2018

The Heuristics of Computer Science

In my last post, I took a dive into my cooking history from the teen years to present.  In this post, I'll visit my passionate relationship with programming and computer science.  Eventually, I'll get to the motivations for why I'm writing a recipe website, but probably not here.  Again this is a rehash of old content but fleshes out some of the details to make me look more human.

I wasn't always a fan of programming and its academic discipline, computer science.  When I was younger I knew my way around a DOS prompt and played the occasional computer game, but never really got into programming BASIC.  At the time, I don't think I was necessarily intimidated by programming, I just didn't understand what it had to offer.

By the time I got to college, I'd decided on mechanical engineering as a major and, as a result, needed to take a few rudimentary programming courses because even in ME, Software was the Wave of the Future ©.  I was actually pretty excited. I'd come to understand that programming allowed me to build tools from scratch and it could be used to augment analysis I'd do as a future ME.  Having these skills would make me a highly sought after recruit.  While those two previous sentences are true, my introduction to computer science (CS101) didn't help close the gap between my talent and my expectations and make those sentences a reality for me.

Though I knew my way around computers, I certainly didn't know my way around programming languages.  I was also thrown into a weed out class filled with a bunch of kids who'd been programming since they were 12 and a bunch who were ready to drop engineering for a different major in the next week.  I was eager to learn right up until I hit my first compiler error.  Though compiler message syntax is pretty straightforward once you know what you're looking at, it's not a stretch to say it comes close to looking like Greek to someone who's never met a compiler (or, if you're Greek it looks like Aramaic).  I would spend hours in the lab poring over what would later become obvious to me as simple compiler errors with absolutely no context of what I was exploring.  It's as though I was required to learn Chinese simply by staring at the characters.  When I asked a TA for help, the TA would simply circle the compiler output on the screen with his finger and state, "it's somewhere right...there," without explaining the output to me.  This is similar to asking someone what this character means and being told, "the clues are in the context of the characters you're staring at."

Another great point of confusion around CS101 was the fact that we were learning CS basics in a language called Mathematica.  The language itself wasn't the problem.  The problem for me was that we were constantly told, "it's not a programming language."  Since at this stage I understood learning a programming language as something similar to learning a second speaking language rather than a subset of pidgin English, I freaked:  "If I have to relearn everything when I learn a programming language, why am I even learning this stuff!"  Turns out, Mathematica had plenty of the control mechanisms and data structures "real" programming languages have, so I was actually learning to program, I just didn't know it.

Needless to say, the rest of my CS career in undergrad didn't pan out to be as illustrious as I'd hoped.  I slogged through a few more fearful moments before getting my degree and heading out to be a mechanical engineer.  I followed this path for a few years until the company I was at decided it wanted to rebrand itself as an internet company (similar to how everyone now is looking to score off the blockchain fad.  Or was).  As such, they started offering online tutorial classes for programming, and because I was now safely separated from threatening TAs with their Fingers of Doom, I decided to look into the tutorials.

Turns out I liked them.  I even had dreams of teaching myself programming and somehow sneaking into the industry as an autodidact.  Then I worried that no one would hire me if I didn't have proper credentials.  Then I realized I could go back to school for a CS degree.  I started taking a few classes at night, and when my company told me they wouldn't reimburse my tuition because the new degree wasn't relevant to my job, I decided to quit and go back to school full time.  Right at the end of the Dot-com boom.  My first fulltime day at school was September 10th, 2001.  Tim - OH MY GOD, WHAT THE HELL DID I JUST GET MYSELF INTO! - ing.

Well, as we all know, the software engineering market seems to have recovered (just a bit).  It also turns out that my second round with CS was much better than my first.  I wrote a thesis on cellular automata and graduated with honors.  I even got a job before finishing school (turns out it was the worst job of my career and I was fired six months later, but that's probably a different blog post).  And, it was during my computer science renaissance that I wrote my first incarnation of a recipe website.  But that's definitely a different blog post.  Probably even the next one.

Sunday, April 8, 2018

A Brief History of Cooking

In an effort to establish a cohesive theme to my blog and motivate me to write more often, I've decided to pick one topic and write through it in a serial fashion rather than follow the stream of consciousness/writer's block flow I dealt with until now.  Because I've been spending a lot of time with my recipe site, I'm focusing on this as my first topic.  Some of it will be a discussion on design, some of it will simply be philosophizing, and some of it may wind up being a technical deep dive.

To that end, I'm likely to repeat some content from previous posts, but I hope the content will be more in-depth.  Where it's relevant, I'll probably double post here and in the README.md file that's housed in my source code repository.

Today's post is about my history with cooking and how it led up to my motivation to write a recipe site.  I've mentioned my history a bit in passing in the past, but I'm going to back up a bit and take a more in-depth view.

I've been interested in cooking since my teenage years.  Much of what I started out cooking was simple - frozen pierogi, enchiladas made from pre-cooked chicken and bottled sauce, and basic mac and cheese.  Still, given the typical teenager's typical lack of motivation, I find my initial efforts from those years commendable.

My cooking skills went on hiatus for my first three years of college, as dorms and 20-year-old roommates living in dilapidated apartments aren't conducive to culinary exploration.  However, I started again my senior year when I lived in a small apartment by myself.  It's not too much of a stretch to say my ambition outstripped my talent at that juncture.  I attempted to make relatively complex dishes like spinach and bechamel lasagna without really understanding how to boil water appropriately, and the results you'd expect followed.

Still, I forged on.  After graduating from college, I regressed a bit in my experimentation.   As I was living on a budget, I had my food routine down pat for the week.  My principal contribution to cooking from this era was a combination of fettuccine (I finally learned how to boil water), whole canned tomatoes, dried basil, and freshly grated parmesan that my roommate graciously shared with me when his mom would drop a bag of it off at our place.  It was a simple dish and my Monday night staple (along with a purchased baguette), but, unbeknownst to me, it held the keys to my cooking philosophy in later years.

Then, I started dating a girl who liked to cook with some frequency - at least when we wouldn't wind up getting too lazy and just go to Culver's for butter burgers - and discovered Epicurious.  Epicurious was fabulous (and, in my opinion, still is), but it led me back into the dark ages of college cooking with its detailed instructions to make everything from scratch and 4-hour sessions of culinary immersion.  Try as I might, I wasn't prepared to keep up, so my attempts at that time were very spotty.

I'd like to say that I reached my end state in the next few years rather than wandering around in a recipe wilderness and occasionally hitting on a bright spot in the forest.  But, considering that I haven't quite reached the edge of the wood today, I won't say anything.

However, I did gain a lot of experience:

  • I learned to trust myself more than a specific recipe.  I can generally look at a recipe now and determine if it's going to work as written or if it needs adjustment.  Sometimes I'm surprised that someone even bothered to write the recipe as written, as there's no way in hell it's going to work.
  • I learned I'm not a foodie.  Some people can really appreciate a fresh, vine-ripened tomato in the middle of summer and swear they can tell the difference between the bulk fruit shipped out in winter.  I'm not one of those people.  This has helped me determine where I can cheat on ingredients, and where I need to focus.  I do know my taste buds couldn't care less if the cheese is actually from the Parma region.
  • I'm not big on presentation.  I do want the food to look pretty, but if my lasagna falls apart while plating it, but still contains all the flavor I crave - oh well!
  • I'm a perfectionist when it comes to searching for recipes.  I've spent years tweaking a blue cheese pasta recipe in the hopes of coming close to matching something I ate at a resort in Wisconsin 17 years ago.  I keep looking for better and quicker variations on some of my old favorites.
  • I'm not a fan of making cooking a marathon event.  I don't mind spending an hour in the kitchen, but my sweet spot for cooking is 30 - 45 minutes.  If I can leave some things around for a few hours or a day - like bread, marinated meats, or olive dressing - that's an easy and delicious trade-off.  However, I'm never going to brag about making an all-day ragu sauce.  There are plenty of shortcuts I can take that meet the criteria of close enough.  
  • I prefer using general tools with a few specialty items that make cooking significantly easier (a cast iron pizza 'stone' and a mandolin are the two big ones that come to mind).
  • I prefer simple, more traditional food, but I'm not a traditionalist.  I'll make a Cuban sandwich with ciabatta bread.
  • If the above two bullet points offend you, please re-read the second bullet point.
  • I have some irrational need to develop X number of recipes for rotation across a year.  Typically, that number is 52 (for obvious reasons), but it goes up and down.  I'm reaching a point where I'm getting close to that number with a lot of recipes that I've made at least a few times.  It's taken a lot of experimentation and discipline to write down the recipes that I want to keep (as well as the discipline to jettison some of the dogs even if I really want to like them).  I'll admit that discipline has been spotty, so that's why this journey's taken me 20+ years to get to where I'm at.  I suspect when I hit my number and document my recipes (assuming I will this time.  But, hey, if I can blog with relative consistency, then I'll probably be able to hit a cooking target), I'll just add to what's there, because that's the beauty of food - there are just so many delicious varieties, so why limit yourself?