D$Web

Help, I'm trapped in an ugly website...
home | squawk | programming | π
u: p:
2010 06 27 - google is a local maximum

First there was the Web, and people put up pages but no one knew where anything was. Then people put links on pages to other pages, so that if you already found a page you wanted, you could find other, similar pages. So people would put up pages full of just links they liked, or links relating to a certain subject.

Out of this the directory was born. Yahoo hired librarians to catalog the web. But the web grew too quickly*.

* I haven't done any research into this, and it's probably incorrect.

Then came the full text keyword search engine. The idea was that the web page you want, or the links that point to it, will have similar words to the query you use to search for it. This works well, especially when the owners of the page you are looking for optimize it to be found by the queries you are most likely to make.

Still, sometimes pages don't contain the words people would use to search for them, and sometimes your query is too complex for keyword searching.

"I'm looking for a story I saw about a reality simulation. The main character, who may have been named Mike, died (game over) and woke up to discover that the real world is populated by genderless humanoids (angels?), and that not all characters in the dream that had been his life were real people. Another character might have been named Valerie."

What you really want is an AI that knows every page on the web, understands exactly what you are looking for, and wants to help you find it.

In the meantime, cataloging sometimes helps. I find Delicious very useful for finding things I've already seen, but it's limited by how much thought unpaid users are willing to put into just what a page is about. Duck Duck Go sometimes clarifies what different meaning of a term you want when you search for something like architecture. And I wouldn't be surprised if someone takes advantage of Mechanical Turk or some other form of cheap labor to build a bigger and more useful directory than Yahoo could with its army of college-educated, professional salaried librarians.

2010 05 02 - no loop for you

I made a little headway in the Clojure book today. One interesting point is that, since there aren't regular mutable variables, regular loops wouldn't be very useful. So the loop statement is like a function, where you recursively call it with new parameter bindings:

user=> (loop [lst '(2 3 4)]
  (if (odd? (first lst))
    (first lst)
    (recur (rest lst))))
3

And for is a list comprehension:

user=> (for [i [1 2 3 4 5]] (* i i))
(1 4 9 16 25)
user=> (for [i [1 2 3 4 5] :when (odd? i)] (* i i))
(1 9 25)

Recur is tail-call optimized (so under the hood it's basically a loop), but regular recursive functions are not. I'm not sure why that is.

2010 04 27 - a bold new direction

I'm thinking of taking the visual design of this site in a bold new direction. Here is an example of how it would look.

2010 04 18 - doc strings on lambdas?

Just a little experimentation with Clojure's built-in forms.

(defn powfn [n] 
  "Returns a function to raise a number to the nth power."
  (fn [m] 
    (apply * (take n (iterate identity m)))))

user=> ((powfn 2) 2)
4
user=> ((powfn 2) 3)
9
user=> ((powfn 3) 3)
27


The doc string doesn't seem to be working. Also, I'd like to be able to do:

user=> (doc (powfn 4))
([m])
  Returns m raised to the 4th power.

But it seems doc only takes a symbol.

The forms I was experimenting with were found here.

2010 04 18 - shaving yaks and running ants

So I want to run this program, which looks like it plays a chord for a couple seconds:

; based on http://www.brettdaniel.com/files/2009/TestMidi.java

(import '(javax.sound.midi MidiChannel 
  MidiSystem MidiUnavailableException Synthesizer))

(defn test-midi []
  (def synth (MidiSystem/getSynthesizer))
  (.open synth)
  
  (def channel (nth (.getChannels synth) 0))
  
  (.noteOn channel 60 127)
  (.noteOn channel 64 127)
  (.noteOn channel 67 127)
  
  (Thread/sleep 2000)
  (.close synth))

(test-midi)

As mentioned previously, this didn't work. Apparently this is due to this bug. This evening I downloaded the latest Clojure source to see if it had been fixed, but apparently not.

A yak to shave on the way was installing Ant. When I tried to build Clojure it gave me the error "Files was unexpected at this time." Obviously this is a problem with spaces in the path C:\Program Files (x86). The solution, found at Installing Ant, is removing quotes in the JAVA_HOME environment variable. After doing that and setting the ANT_HOME variable, Clojure compiled. %ANT_HOME%\bin also had to be in the path.

2010 04 17 - interface'd

Tonight I worked through a little of Programming Clojure (the early part that I read a month ago and then forgot). It's mostly vocabulary review. Next up is section 2.2. Reader Macros.

A month ago I was messing around with Clojure's Java interoperability, trying to use the MIDI API. I ran out of steam when I ran into a bug that prevents calling methods on non-public classes. This caused a problem becaue I had a public interface and a factory method that returned a private implementation of that interface. Java interop is based on reflection, but it tries to make it look like it's not by trying to determine the visibility of the entity you're trying to call. So when I tried to call the method to play a note, it helpfully gave me the error:

java.lang.IllegalArgumentException: Can't call public 
method of non-public class

It looked like this was an official bug for which the fix is probably released by now. I'll look into that hopefully tomorrow.

2010 04 17 - meta-development

I've traditionally been bad at accomplishing any kind of goals. It seems I only stick to things when I have to. Work provides that kind of situation: when I'm there, there is something I'm supposed to be doing. If I don't get up, go to work, and do work while there, I'll get fired, and so I make progress.

Personal projects don't fare so well. If I could convert each started (or planned-to-be-started) but not finished project into a unit of currency, I could hire minions to finish them for me. The only things that seem to inspire discipline are fear, disgust, and spite.

Anyway, along the fear/disgust vector, if I don't learn to accomplish things, I'll be a loser forever. I don't know if I've been unable to give X hours a week to something, or if I actually haven't tried that approach. I believe I've tried "X hours at time T", which doesn't seem to work, because either laziness or spite cancels it out when time T actually arrives.

So, I'm going to try to establish the habit of giving 5 hours to software meta-development per week. By meta-development, I mean improving myself as a software developer, which is something I haven't put concerted effort into for most of my career. Four hours to be spent working on projects or studying (reading programming blogs doesn't count--that I do addictively anyway), and one hour blogging about it. The ratio may need adjustment. This weeks blogging begins in the next post.

2010 02 09 - Poetry

This is a neat format for a poem. I read it, but I can't tell you what it's about. My problem with poetry, just like my problem with lyrical music, is that I listen to the sound and rhythm, and ignore what's being said (even while reading, apparently).

Of course I know what it's about: verses shaped like facing concave triangles.

2010 02 02 - vim, dreams, code

Last night I went through the Vim built-in tutorial. I wanted to try hacking something together in Clojure, but I needed an editor that worked well for Lisp development and wanted to try something other than Emacs. It's a little weird not being in edit mode by default, but I suspect it's less work than switching between the mouse and keyboard. Anyway, learning the editor's probably a project in itself. I was fairly excited about it when I went to bed.

This morning I woke up from a dream where me and two other people were trapped in code, as functions that could only act when invoked. When I gained full consciousness, I had two ideas in my head for how to tackle a couple issues at work.

It's annoying waking up an hour early. It's not quite enough time to get back to any meaningful sleep, especially when I've got ideas in my head that need to get out. So I went into work early and got to coding. One of the ideas (a moderately clever way of preventing an edge case from wreaking havoc) panned out very well. The other (a theory as to what was making something crash) wasn't very helpful.

I could have used more sleep.

2009 11 21 - the game

I've been netflixing a bunch of Star Trek: The Next Generation episodes. I've seen most of them before, but it's been a while, and it's fun to rediscover the peices of the puzzle that I only vaguely remember.

The other day, I watched The Game, which is an episode about viral marketing that aired in 1991. Wesley Crusher, visiting the Enterprise on leave from Starfleet Academy, discovers everybody on the ship acting strangely and addicted to a video game. He meets a girl, recently graduated from the academy herself, and they work together to figure out what's going on.

When I last saw the episode, Wesley and his girlfriend were much older than me; and now they're much younger. This isn't depressing, but it is surprising. Most of the other characters still seem older than me. Yay?

This also reminds me of another type of game, which I just lost. And so did you.

<< older
To contact me, e-mail cathodion at gmail.com.