spacer
{Arrest This Man, He Talks In Maths } spacer

Blog : Archives : Homepage

With your feet in the air, and your head on the ground . . .

spacer
spacer

{Thursday, December 16, 2004}

 
"So... in an HTML analogy, your code now has a "style sheet" instead of you typing in the modifiers for every individual tag you use, every time you use it? (You load the main program once, then switch the parameters without re-performing the vast majority of the task?)"

I don't really know CSS (:-p) so I'm not sure how apt the analogy is, but my guess is this is pretty different. The optimizations don't make my code "cleaner" in an aesthetic sense, and they don't reduce my effort in writing the code - the purpose is just to make the code run faster, i.e. reduce the computer's effort in executing the code.

The best metaphor I can think of for the memory allocation situation is this: let's say you're a professor, and before every lecture, you need a lot of material put up on a board, which you'll lecture from. Fortunately, you have a TA to help you with this task (the subfunction you call, metaphorically speaking.) Now, you would probably think the easiest thing to do would just be to give your TA the relevant info that needs to go up on the board each time. So you do that, and classes go fine, but at the end of the semester you notice you've gone way overbudget due to "TA expenses". It turns out the TA has been going out and BUYING A WHOLE NEW FREAKING BLACKBOARD for every lecture. Now, that's obviously not very efficient. But you don't think it would be very efficient to lug the blackboard over to the TA before each lecture, either. Fortunately, there's a simple solution: just tell the TA where the blackboard is, and ask them to just go write on it. In a language like "C", this is simple to do, with something called a "pointer" - you pass a pointer to a big chunk of memory into a function instead of sending the whole thing, and everything's groovy. Matlab, trying to be simpler and easier to use, doesn't want to confuse you with pointers, so you can't do this. What I did was figure out a trick to let me (effectively) pass a pointer . . . and thus, metaphorically, cut out the cost of the TA buying a new blackboard (allocating memory) for every lecture.

posted by Miles 8:55 AM

Comments:
Teaching may be a royal pain in the ass sometimes, but you're *very* good at it.

Just for the record.

Now can you teach me all about the neural pathways, fasciculi, nuclei, topography and physiology? 'Cause my actual teachers apparently can't.
 
that's a pretty rad analogy for pointers. and yeah, that's exactly what matlab is doing. most "high-level" languages have done away with explicit pointers. java for example uses pointers nearly exclusively. in c referring to data by address is the special case, i.e. in c to use a pointer requires the use of an operator, '*'. the "special" case in java is reference by value, leadingly called a primitive.

an html analogy might not be that goofy. a hyperlink actually is a pointer. when you're composing a document and create a link, you simply put the address of the page in an anchor tag, exactly the same way in which you'd pass the address of the matrix to a matlab function or the location of the blackboard to a ta. the alternative to reference by address would be to include the content of that link inline with the rest of the first document's html. which would be a lot more typing.

i'm stuck in kathmandu where a maoist strike has closed nearly everything down, so there's nothing to do but post nerdy shit on people's blogs and wait for my flight to australia on wednesday. :)

jimmyk
 
Post a Comment
spacer