Toby Smith

Posts for June 2013

Javascript Arguments

25th June 2013

It’s always tempting to optimise code before you need to. With Javascript I think it’s basically worth following some best practises as you go along, and then doing the “proper” thing of working out where the big holes are.
The issue I have with NOT considering speed as you go through, is you end up with death by a thousand cuts. Internet users (Netizens?) are incredible fickle about speed.

So I’ve been taking reasonable efforts to make the code work fast. I recently stumbled across an article mentioning that using “arguments” was bad.
Specifically that:

function (a) {
return a;
}

is considerably better than:

function () {
return arguments[0];
}

Now, I only use the arguments variable if I want to work with a variable (and potentially large) number of arguments. Utility functions and what have you. The alternative to the above would be to assume one parameter that was a list. Like so:

function (args) {
return args[0];
}

The cost here is building a list each time you call the function. I wanted to see what’s actually faster here and so I extended a JSPerf to examine:
http://jsperf.com/named-arguments-vs-arguments-array/2

Moral of the story: if you want to use variable number of arguments in utility functions the use of the arguments variable is better than building a list.

Homemade udon

4th June 2013

Every-now-and-then I think it’s worth putting a little extra work into dinner.

In “Space Brothers”, they get to a point where they start making some udon noodles. Mutta-kun says it’s easy, but just takes some time. Sounds like a plan!

So, off to the Japanese shop to get some stock ingredients (kombu etc.). In the end I just got a bottle of pre-prepared stock (it was cheaper), and some Japanese grape soda. The grape soda is irrelevant. It’s just delicious. If you get the opportunity to try some, definitely do so. (Calpis/Calpico too!).

Made the noodles according to various recipes online. (I used a mixture of 00 and plain flower). The dough was a lot more satisfying to knead than bread dough. Wrapping the dough in plastic, and then in towels to then stand on it just ended with the plastic tearing and the dough touching the towels. As I didn’t have proper zip-lock bags, I just muscled it to the right consistency.

Toasted sesame, mirin, soya-sauce, pak-choi, mushroom, carrot, spring onions, boiled egg and home made noodles: makes a delicious dinner.

Even better was the “sashimi” made from the excess noodle dough the next day.

I bought nori, but forgot to add it. Oh well. I guess that’s for next time eh! 🙂

Definitely worth the effort, and really not as hard as you might imagine. Biggest issue was slicing the noodles, as I didn’t really have any sharp/fancy knives. I bet you’d have an easier time of it! Highly recommended. Give it a go!

Udon Soup

http://www.thjsmith.com/feed">RSS Feed
  • Terms of use
  • Privacy Policy