Food hacks

I don’t make much mention of it on here (see my other blog for somewhere that I do), but in my day job I’m a programmer. Counted amongst the weird and wonderful jargon that profession entails is the word hack.

There’s a particular sort of hack I’m particularly good at. Quick, and usually somewhat dirty, solutions that use what’s available in unexpected ways. Reactions to them can be anything from “Ooh, that’s neat” to “AIEEE! MY EYES!”, but they usually get the job done a lot faster than the alternatives. I don’t use them all the time, but I probably use them a bit more often than I should.

This post is basically an example of me transplanting that technique to my cooking. The results are… unusual.

Without further ado, some recipes.

Recipe 1: Macaroni and Cheese

I just got back from a trip to New York (well, technically Jersey City), to visit my girlfriend, Victoria. We both cooked while I was there, and one of the things she cooked was her macaroni and cheese recipe. It’s essentially the macaroni and cheese analogue of my brownies – do the simplest thing that can possibly work and the results are delicious.

Ingredients
  • Macaroni
  • Milk
  • Cheese (Victoria uses a Longhorn-style cheddar. “Lord knows what you call it on that side of the ocean” — Victoria. I used a mature english cheddar)
  • Something to serve it with. Victoria uses stewed whole tomatoes, I just used a hot sauce.

I don’t really know the proportions for this – I think it’s basically “make enough macaroni to serve the requisite number of people then add milk and cheese until it looks right”. Cooking is equally straightforward – cook the macaroni until it’s slightly underdone, cube the cheese, put the cheese, milk and cooked macaroni in a greased glass dish and bake until it looks cooked (at around 200C I think).

So, yesterday evening I thought “Hmm. What to make for dinner? Oh, why don’t I give Victoria’s macaroni and cheese recipe a go?”

I went to sainsburys to buy the ingredients only to discover, admittedly somewhat unsurprisingly, that they did not have any macaroni. This made me sad:

Oh well, macaroni is just pasta, right?

Hack 1: Penne and Cheese

Exactly the same as the macaroni and cheese, but with penne instead.

Result: Surprisingly nice. The macaroni is a bit better, but the penne is entirely acceptable here. It just has a slightly weird shape for it.

Anyway, I have a really evil recipe that I felt like making tonight:

Coney Island Fries

There seem to be approximately a million different distinct recipes each claiming to be coney island fries. Most of them involve some sort of meat. I call these coney island fries because the pub whose recipe I reverse engineered them from did. They’re evil because they’re really tasty but contain no redeeming nutritional or culinary value. I try to avoid making them too often, but occasionally I succumb.

Ingredients
  • Oven fries
  • Cheddar cheese
  • Guacamole
  • Thai Sweet Chilli Sauce

Recipe: Cook the oven fries as per normal. When they’re nearly done, add large quantities of grated cheddar. Serve with guacamole and way more sweet chilli sauce than can possibly be good for you.

Result: Mmmm.

So, having decided to make it I went to sainsburys for ingredients. Result: No oven fries.

At this point I was feeling like it was sainsburys’s mission to thwart me.

So, I wondered what I could substitute for the fries in order to get something resembling success.

At this point you would be right to have a sinking feeling…

“Ah ha”, I thought, “I have leftover penne and cheese at home, don’t I?”

The rest, as they say, is history.

Hack 2: Coney Island Penne

I hurried home to put my diabolical plan into action.

Ingredients
  • Leftover penne and cheese
  • A handful of frozen corn
  • Guacamole
  • Thai Sweet Chilli Sauce

Recipe: Heat up penne and cheese. Add frozen corn because I’m feeling guilty. Serve with guacamole and sweet chilli sauce.

Results: Well, hmm. Not exactly good per se. Interesting, certainly edible, and not nearly as bad as one might fear, but kinda inferior to its constituent recipes – I wouldn’t say no to eating this again, but I’d take the penne and cheese or the coney island fries over it any day.

Oh well. I did say it was a hack.

This entry was posted in Food and tagged , on by .

Learning Scala

Some questions for people who are learning / have learned Scala: What languages did you know beforehand, and how easy did you find learning Scala in comparison to these? Are there any languages which you found knowing particularly helpful when picking up Scala?

An explanation follows:

Scala seems to be a relatively hard language to learn for some people, not so much for others. Part of this is its complexity – it really does have a lot of little features – but I’m wondering if more of it might be its approach. It’s a language with two major inspirations – object orientation (in the peculiar flavour of it Java practices) and statically typed functional programming, and I’m not sure how easy it is to understand the language unless you understand where it’s coming from in this regard.

In particular one thing we’ve observed in #scala from people learning the language is that if you know both Java and Haskell (I presume an ML would work as well?), learning Scala becomes significantly easier. I had almost no trouble picking it up, but I know both. Ricky Clarkson seems to be in a similar boat in terms of Haskell + Java having helped. I presume others are too. On the other hand, people with Java background but not much FP seem to have more trouble and people coming from a predominantly ruby or python background have a harder time yet. (I don’t know what happens to people coming from a Haskell with no Java background. I’d expect a similar degree of confusion to the Java with no Haskell background).

Some of this is probably in terms of material – a lot of Scala tutorials, etc. out there seem to assume you already know Java. This is probably largely accurate but seems like a mistake in the long-term to me. On the other hand, I’d be really uncomfortable teaching Scala as a first language, so what languages *should* they be learning to prepare the way? Anyone tried learning it on the basis of, say, Ruby + OCaml?

So, what do we want people’s path into Scala to be? Should we suggest they learn Java first if they don’t want a bit of a rough start, or is there a better way?

This entry was posted in programming and tagged , , , on by .

Java collections and concurrency

This is a general tip about Java collections and concurrency. I’m not the best person to write about this, so I’m going to keep this post limited to a simple note, but it’s an important point which far too many people get wrong.

There are various methods in Collections such as synchronizedList, synchronizedMap, etc. These are for wrapping non threadsafe collections in a way that synchronizes important operations.

Don’t use them. Ever.

In a similar theme, never write code that looks like the following:

synchronized(myMap){
  doStuffTo(myMap);
}

Concurrency is not an afterthought. If you’re going to be doing concurrent programming you should be using datastructures designed for concurrent use. java.util.concurrent has a number of good ones. Further, you should avoid explicitly synchronizing if at all possible and have your structures be internally threadsafe. If you try to ensure thread safety by synchronizing on the structures you’re mutating you will

a) Make a mistake. Almost certainly. This will introduce bizarre bugs which you will have a serious headache tracking down.
b) Have worse concurrent performance than using a properly designed datastructure – e.g. a ConcurrentHashMap has finer grained locking, so it actually is possible for multiple threads to write to it in a safe manner.
c) Have really ugly code with synchronization logic spread all over the place. This is not a minor point – if your threading code is simple, it’s much easier to determine if it’s correct (although still not easy).

This entry was posted in programming and tagged , on by .

More Asus hilarity

So, Asus have managed to accrue some more black marks this week.

I called on monday to say “Hi, now that you’ve had a look on it could you give me a more useful answer about how long it’s going to take to repair my laptop?”

Their answer: “We can’t find anything wrong with it. Could you send us your power supply?”.

Ok, that’s something at least. I tested on every conceivable combo of power supply and battery, but I suppose it’s possible that the power supply conked out and the battery ate itself as a result and couldn’t recharge from it.

Anyway, I said no, could they just send me the laptop back, I’ll buy a new power supply. (Subtext: These people are so fucking slow that if we get into the sending random parts back and forth game I’ll never get my laptop back). And, incidentally, had they been planning to tell me this at any point?

“Oh, yes, we would have called you today”.

Fuck they would have. Asus and their subsidiaries have not once volunteered information without me having to drag it out of them. Anyway, they agreed to send it back.

Fast forward to today. They managed to score two black marks.

a) They delivered the power supply I purchased. To the wrong address. I very explicitly gave my work address as the delivery one, so they cheerfully delivered it to home instead. ‘Fortunately’ I overslept dramatically (I was at work till 11:30 laat night. :-( ) and was still there when the package arrived.

b) I still don’t have a laptop returned, so I called them up today. After much being on hold, getting randomly hung up on, and general intense annoyingness of their phone system it was confirmed that no they had in fact not made any note whatsoever of an intent to send it back. They claim it will be sent out today and should arrive tomorrow. We’ll see.

At this point I’m almost tempted to just buy a second laptop from Dell even if the new power supply works perfectly. The benefits of never having to deal with these people again are surely worth the price of a laptop…

This entry was posted in programming and tagged , on by .

Minor revelation about Scala existential types

So, I’ve just realised why Scala’s existential types are several orders of magnitude more powerful than Java’s wildcards.

   def swap(xs : Array[T forSome { type T; }]) = xs(0) = x(1); 

The type is not completely unknown, and is persisted across method invocations, so for a given fixed instance you can make use of that to perform operations that would be impossible with wildcards. In particular the following can’t work:

  public void swap(List<?> xs){ 
    xs.set(0, xs.get(1));
  }

This can’t work, because Java has no way of determining that the two wildcards in xs.set and xs.get are the same.

This entry was posted in programming and tagged , , on by .