19

It's Thanksgiving in the United States tomorrow.

Please describe your favorite method of cooking turkey in the form of runnable code using your favorite language. For example in Java with java.utils.concurrency.

48 accepted

In C:

while (fork());

Place turkey on your favorite multi-core CPU array, execute above code.

As a bonus, you can use the leftover forks later to eat the turkey.

43

In the perversely overengineered Turkey framework, released for Thanksgiving 2008:

void CookTurkey() extends CookFood implements CookLargeAmountsOfFood,  
FamilyGathering throws FamilyMemberDrunkException, BurntTurkeyException, 
ArgumentOverHowToCookTurkeyException, HouseOnFireFromTurkeyException {
    TurkeyOven oven = TurkeyOvenFactory.createTurkeyOven(Temperature.Hot);
    try {
        iEdibleBird turkey = EdibleBirdFactory.createEdibleBird(Bird.Turkey);
    } catch(TurkeyDroppedOnFloorException tdofe) {
        CurseWord profanity = new CurseWord("#&@$@$#");
        profanity.say();
    }
    Cook cook = Cook.getSingletonInstance();  // Our cook is one-of-a-kind.
    TurkeyResult result = CookFood(turkey, oven, cook);
    if(TurkeyResult.getResult() == CookingResult.Burnt) {
        throw new BurntTurkeyException();
    }
    FamilyMembers.getSingletonInstance().eatLargeFeast(turkey);
}
32

I tried to cook a turkey in Lisp, but I only ever got back a brand new turkey, fully cooked. The original was still in the oven. Then, since nobody was looking, the garbageman came and took it away.

31

I don't really get involved in the cooking process (my wife would balk at that). So, I would handle it afterwards like this:

Assembly language:

       mov si,turkey    ; point fork at turkey
       mov cx,capacity  ; stomach capacity
next:  lodsb            ; load single byte
       int 29h          ; consume it
       loop next        ; repeat until done (CX=0)
       jmp couch        ; watch football
25

I fear for the programming industry if these unoptimized solutions are anything to go by.

Here's a (fairly) language-agnostic approach, just rewrite for your particular language:

this.Visit(Mom);

In these asynchrony times (recent C# news, case in point), I'll rewrite the above code to be asynchronous:

var ft = this.Call(Mom, c => c.Order(Turkey));
var t = await ft;
21
#!/bin/bash
NUSERS=`ls /home|wc -l`
wget http://market/turkey
dd if=/dev/salt bs=2 count=1 >> turkey
dd if=/dev/pepper bs=1 count=1 >> turkey
dd if=/dev/rosemary bs=20 count=1 >> turkey
mv turkey /var/oven
/etc/init.d/oven start
sleep 60m
/etc/init.d/oven stop
mv /var/oven/turkey .
split -d -b $(( `cat turkey | wc -c` / (NUSERS-1) )) turkey meat
17

Of course, in Python you wouldn't actually cook anything, just do:

import turkey
14

If you have Boost, you should use boost::turkey.

13

Real programmers stuff a turkey via SQL injection

10

Naturally, in PHP you wouldn't actually try to solve the "cook the turkey" problem.

You would instead try to hide that it, in fact, is raw and eat it anyways. Actually, whether your mouth is filled with turkey or something entirely else doesn't really matter, as you will chew on it and swallow happily nevertheless.

If your stomach would fail at some point, you would try to remember what you did earlier by doing what you did before, but at some points in the process, would stop, and look at what you have at hands. Once you have taken the peek, try to figure out how the salmon ended up in your fork, and start the process all over again.

Don't get me wrong; PHP is my current language of choice.

9

Here's an algorithm developed by a few grad students a while back:

if(broke) {  // Can this branch be optimized out?
    goto seminar;
}

seminar:
free(turkey);
8

Well, it depends if Jon Skeet is the programmer or not.

He only needs to look at the turkey and it cooks.

The rest of us, not so much.

6

I wouldn't waste time writing custom code, I'd buy an off the shelf turkey system.

5

In delphi:

try
  turkey.Prepare();
  turkey.Cook();
  turkey.Serve();
except
  on e: EDinnerIsRuined do
    pizzaLine.Order();
end;
5

REAL programmers would use good old C-x M-c M-xmasdinner

4

I'd give an answer, but my internationalization skills aren't up to par

3

Simple one in C#

public class Cook<T>
{
    public Cook(T what_to_cook)
    {
        what_to_cook.Prepare();
        what_to_cook.DoCooking();
        if(what_to_cook.ServingReady())
                what_to_cook.ServeAll();
        else
                what_to_cook.PrepareServing();
    }
}

public class MakeItHappen
{
     Turkey t = new Turkey();
     Cook<Turkey> ct = new Cook<Turkey>(t);
}

public class Turkey : ITurkey
{
     public void Prepare(){...}
     public void DoCooking(){...}
     public void ServingReady(){...}
     public void SaveAll(){...}
     public void PrepareServing(){...}

}

public interface ITurkey
{
    void Prepare();
    void DoCooking();
    void ServingReady();
    void ServeAll();
    void PrepareServing();
}
3

First, I ask the client how they like their turkey done.

2
$ cat plate | grep turkey | eat &
2

Chef's like Perl because nobody else can read their recipes. :P

1

Hmmm, you guys better check localization very carefully :)

1

I don't have one for Turkey, but I do have one for Canadian Goose:

oven.setTemperature(200);
sleep(15 * 60);
oven.add(goose);
oven.add(brick);
while (!brick.isTender()) {
   sleep(300);
}
oven.remove(brick);
oven.remove(goose);
goose.dispose();
0

Complainings about me in dinning table,

  1. In delphi: "Don't only use your hands to eat!" ( Got it? Mouse only? )

  2. In C#: (This is to someone creative to make a joke about visual studio)

  3. In java: "Why it is taking you so long.."

PHP

$parts = explode($turkey, "bones");
for($parts as $part)
    eat($part);

OMG, i'm not good at this..

0
<?php

$bird = new Turkey();
$oven = new Oven();

if( $bird->isFrozen() )
  $bird->thaw();

$oven->preHeat(Turkey::COOKING_TEMP);

$bird->season( array(Kitchen::ROSEMARY, Kitchen::SALT, Kitchen::PEPPER) );
$bird->stuff( new StoveTop() );
$oven->cook($bird);
0

stty cooked >/dev/tturkey

0

en-GB answer (2008 only):

sleep 28d
cook turkey