Archive for the ‘Uncategorized’ Category

Five languages for talking about programs.

Monday, April 7th, 2008

Only one of which is a computer programming language.

At work, we’re designing a new product. It’s a process that involves non-technical users, IT managers, programming colleagues, me, and the computer. It involves a lot of talking, a lot of language. At one end, it’s making sure the users are happy with the system’s capabilities. While talking to them, we use non-technical language, diagrams, and demonstrations. Way at the other, it’s actually typing code.

This makes me think it might be useful to split the languages we’re talking into four;

User Langage: Non-technical, example-laden, visual, and concrete. This is where you get into general discussions, produce photoshop mockups of the system, draw rough-and-ready whiteboard pictures, write XP user stories, write user manuals.

Manager Language: Your manager needs to know the technical and algorithmic overview, but he doesn’t need to see every class that’s going into the design. This language is the language of high-level functional specs, some UML diagrams, conceptual diagrams.

Colleage Language: At this level, you’re going to have to assure yourself that the code you write and the code your colleagues write start meshing together. Precision starts being important, and a real burden. Probably where most of the real thinking goes on. I think one of the reasons Pair Programming works is because it forces you to get into a lot more of these types of discussion, which reduces the possibility that the team’s work won’t gel together.

Self Language: This is the idiosyncratic, outboard-brain style of writing that you get into to make sure you understand what you need to be doing. This can be personal pseudocode, notes-to-self, todo lists, or code comments.

Computer Language: The code itself.

I think a great deal of the actual design and thinking involved in creating new products goes on above the level of the computer language. When people discuss, say, “Python Vs Java” or “Ruby vs Lisp”, it’s valuable enough, but the choice of language probably isn’t that important in determining the success of the project. I think these language strata go some way to explaining why. Most of the communication goes on between people.

Du Hast Milch

Thursday, March 20th, 2008

Du Hast Milch

German advert for milk, with the tagline “Hard types need hard bones… drink milk!”

link

Hoverboards for sale.

Thursday, February 21st, 2008

Y’know, I love living in the future.

Take, for example, this hoverboard;

hoverboard

Yes, that’s right. A hoverboard. For about seven grand, from these guys

Impractical, Uncommon Lisp.

Wednesday, February 13th, 2008

A friend of mine, Rob Ahrens, asked me how my learning of the programming language Lisp was going. I thought I’d respond in an open letter.

Um, Hi, Rob.

I have two previous posts on lisp, A programming language only a mother could love, and lisp, the beautiful hydra.

Childhood Nightmares

When I’ve had time, I’ve been attempting the problems in Project Euler. Euler lays out a series of ~200 mathsy programming puzzles, things like ‘find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed one million.’ I’m using them as a way of trying out the language. At my side, possibly the only decent beginner’s book, Practical Common Lisp. (It’s also free.)

So far, I’ve finished 2 problems. Hmm. I’m pretty sure I could have finished more of them, more quickly, in almost any other language.

That, I think, is at least in part that lisp doesn’t come naturally if you’re used to non-lisp languages, things that bear a resemblance to C or BASIC. I’m having to go right back to basics, learning to construct things in a new way. Here’s the code I used to solve problem 2;

(defun fibseq (max)
  (let ((result ())
        (n-1 1)
        (n-2 0)
        (term 0)
        (i 0))
    (loop
     (setf term (cond ((= i 0) 1)
                      ((= i 1) 1)
                      (T (+ n-1 n-2))))
     (setf n-2 n-1)
     (setf n-1 term)
     (setf i (1+ i))
     (when (> term max) (return))
     (push term result))
    (print result)
    result))

(defparameter allfib (fibseq 1000000))
(defparameter evenfib (remove-if-not #'evenp allfib))

; the answer!
(print (reduce #'+ evenfib))

I don’t print this here to demonstrate the clarity of lisp. In fact, the opposite. This looks like hell to me, at least right now. There is, no doubt, a far better way to do this. But I don’t know, and so I’m writing programs that are terribly inelegant. Nestled in the code above is a non-terminating loop with a break condition, because I couldn’t figure out how to do the equivalent of

while (n < 1000000)
{

Right now I feel like I did when I was ten, programming in BBC basic and using GOTOs. Hell, it knocks together working programs, right? But you don’t want to stay there too long. That feeling of childhood programming, though… there’s something compelling in it. Lisp tastes of nostalgia. Remember programming Logo? Or BASIC? Lisp is making me feel like that. At least for now.

Pretty soon, I hope to have mastered basic loops. Then I’ll be well on my way.

(setq subject (list ‘( ‘)))

Or, now I will talk about parentheses.

In my head, despite being entirely uncomfortable with while loops, I’m starting to see everything falling into a lisp syntax. The idea of just bracketing up your stuff into lists seems like a great first-draft syntax for everything — want to talk about data structures? write

(data
  (entity1 (attribute1 attribute2))
  (entity2 (attribute3 attriubte4)))

want to write pseudocode for a function call?

(func (param1 param2) ...)

want to write a todo list?

(do 
  (buy bread)
  (tidy (kitchen living-room bathroom))
  (get life))

Valentines day coming up?

 (get-count
     (make-list #'(lambda (i thee) 
                          (permute #'love i thee))))

Ok. Maybe not. (apologies to Elizabeth Browning there.)

But you get my point. I hope. Those brackets are just fine for everything. I’m starting to understand why hardcore lispers want to do everything in lisp. My brain is infected with brackets.

But for right now? I’m going to learn to do a for loop, and then we’ll see.

Samurai Dog Armour

Monday, February 11th, 2008

samurai_dog_armor_1.jpg

Fun oddness; Samurai Dog Armour

This suit of dog armor — identified by antique Japanese armor dealer Toraba.Com as the only known and certified authentic example of its kind — is believed to have been created for the pet of a wealthy, high-ranking and presumably eccentric samurai or daimyo (feudal lord) in the mid to late Edo period (mid-18th to mid-19th century)

link

It’s all text! — Firefox Add-on.

Wednesday, February 6th, 2008

I’ve just discovered ‘It’s all text!’, a firefox add-on that makes it easier to edit text on the web.

It’s a pretty simple idea; any textareas (those boxes used for composing email, writing forum posts, editing wikis, etc) get a little button;

It’s All Text Screenshot.

click the button and it’ll let you edit the same text in a proper text editor. When you save the file or close the editor, it copies all the text back into the web page.

All of this means it’s a lot easier to edit text on the web; especially useful for emails and, well, blog posts. ;)

Sublime Text Editor Review

Monday, January 28th, 2008

I’ve just bought a copy of sublime text, a very pretty text editor for Windows. I’m a bit of text editor geek, but I think it’s justified, with the amount of time I spend typing. Between coding and writing fiction, I spend hours and hours a day typing, so a good text editor is as important as a comfy chair, a good monitor, or a cup of tea. It’s just not civilised without.

sublime text screenshot

If you spend much time writing text, you may want to have a look. I’m using mine for both programming code, and for fiction.

These things make it well worth it, in my opinion;

  1. It’s gorgeous. Text Editing shouldn’t feel this good, says the website, and it’s absolutely right. The colour schemes are lovely, especially Chocolate Box, which is shown on the screenshot. If simple text editors like Notepad feel like using a bic biro, and emacs and vi feel like using a technical pencil, sublime text feels like using a fountain pen.

  2. It’s functional. As a programmer, you expect the ability to do serious things to your text. Sublime comes bundled with syntax highlighting for many languages, a python plugin system, a build system, it’s own macro language, regex searching, snippets, sorting… there’s lots here. The ability to write python programs means that it’s going to be possible to write, well, absolutely anything you need. And you don’t have to do it in emacs lisp

  3. The support is amazing. It’s written by Jon Skinner, an Australian who left his job at Google to write the editor. I wrote him an email yesterday suggesting a feature. Twelve hours later, he’s written the code and put it into the next beta. Twelve hours. And the reply email was chock-full of details he didn’t need to include, and an apology about the tardyness of the reply.

  4. Full-screen mode; It has a full-screen mode that lets you blow the window up to occupy every available pixel, which makes it great for writing without distraction. If you’ve looked at rudimentary full-screen editors like WriteRoom, you’ll know the idea; replace your cluttered desktop with a single text entry window. Sublime Text does this, but still has the advanced functionality of a heavyweight text editor.

  5. It’s only just begun. The current version is 1.01, and already it’s stuffed with goodies.

Anyway. Enough. Go get it.

LaTeX build server in Ruby

Wednesday, January 23rd, 2008

So — I’ve been writing functional specs at work in LaTeX, a system for writing documents in a code-y markup language. Seems to fit nicely with being in a programmer headspace. The only thing, really, is that you have to compile your document. A bit of a ballache. But — I’ve also been learning Ruby, and found it easy to knock up a program that sits patiently waiting for you to save your .tex source file, then recompiles it in the background.

So, if you want to use it, here’s how it works;

  1. modify the script below to point to your own latex distribution and source file.
  2. run the script to start the ‘build server’
  3. open your .tex file, make a change, and save it.
  4. watch your ruby program spring to life and compile to a .dvi file
  5. Open that .dvi file in a viewer; I’m using yap.
  6. make more changes to your .tex file. Every time you save it, the .dvi file will be updated, and yap will reload it, giving you instant feedback on your changes. It’s just like a wysiwyg editor! almost!

enjoy;

#
# LaTeX build server!
#
# Steve Cooper
#

file = "c:\\documents and settings\\steve\\Desktop\\bulk-activation-specification.tex"

cmd = "\"C:\\Program Files (x86)\\MiKTeX 2.7\\miktex\\bin\\latex.exe\" --interaction=nonstopmode \"" + file + "\""
print "Compilation command:\n  #{ cmd }\n\n"

class String
  def mtime
    File.new(self).mtime
  end
end

lastmtime = file.mtime

while true
  currentTime = file.mtime
  if (currentTime > lastmtime) then
    print "file modified at " + currentTime.to_s
    lastmtime = currentTime
    print "Compiling " + file + "\n"
    system cmd 
  end
  print ". "
  sleep 1
end

Seasick Steve; top mississippi blues at Leeds Met

Thursday, January 3rd, 2008

We stayed in over new year and watched Jools Holland’s Hootenanny. Possibly the best act on it was a bluesman called Seasick Steve (home) (w’pedia). He is the bastard hillbilly child of Tom Waits and John Lee Hooker.

Anyway, he’s playing Leeds Met on the 31st and we’ll be going. Anyone fancies coming along, I think it’ll be a fine night of good music. Doors at seven, we’ll be getting a train around six, I suppose. Call me.

I are drunk and full of pudding…

Tuesday, December 25th, 2007

and listening to my brother-in-law’s ‘Metal Christmas’ album. Mmmm… christmassy.