• About
    • About

Steve Cooper's Personal Blog

  • Five languages for talking about programs.

    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.

  • Modifying large codebases in dynamic and static languages

    April 5th, 2008

    I’ve been wondering recently about dynamic languages, and static languages, and the relative benefits.

    I’m struggling with this question because I write C#3 by day, and am learning python in the evenings. I’m only writing small python scripts at the moment and I’d like to write larger pieces, but I’m concerned about how easy it’ll be to make certain types of change.

    For example. You’ve got 100,000 lines of code. You also have a logging function that’s looks like this;

    void Log(string message)

    And it’s called about 200 times in your code. You decide you need a severity; so you change the signature to

    void Log(string message, LoggingSeverity severity) { .. }

    Now, how long does it take to find all the calls to the Log() function that need to be updated? Under C#, about ten seconds. Once every call has been fixed, the code is almost certain to work correctly.

    Consider, on the other hand, the python function

    def log(message):
    …

    What happens if you change the signature to

    def log(message, severity):
    …

    There is no way to tell where the log message is called. You’ve just introduced 200 bugs.

    It’s made even worse by duck typing; maybe you have two loggers — a deployment logger which writes to a database, and a test logger which writes to stdout. You update the database logger so it has severity. Your tests continue to pass, but your deployed system will fail.

    So it seems to me that static languages give you much more power to make changes to large codebases. I’d love to know if, and where, the mistakes are in my thinking.

  • Du Hast Milch

    March 20th, 2008

    Du Hast Milch

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

    [link](http://coilhouse.net/2008/03/19/du-du-hast-du-hast-milch/)

  • IObit SmartDefrag — windows program to defrag drives

    February 23rd, 2008

    For the last few months, I’ve been using [IObit SmartDefrag][sd]. It
    is a freeware defrag program that keeps your drive running
    fast. Basically, you install it and it runs in the background, like a
    librarian silently alphabetising your book collection. Your machine
    can find and load files faster. Anyway, it feels like my machine has
    stayed fast, where I would have expected it to slow down over
    time. Anyway, it’s freeware, it seems to be reliable, and it’s kept my
    machine fast. Can’t go wrong.

    [sd]: http://www.iobit.com/iobitsmartdefrag.html

  • Stephen Fry, blogging and podcasting

    February 20th, 2008

    So, just in case you didn’t know about Mr Fry’s [blog][] and new [podcast][] — you’ve been told.

    [blog]: http://stephenfry.com/blog
    [podcast]: http://www.stephenfry.com/podcasts/

  • Impractical, Uncommon Lisp.

    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][blog1], and [lisp, the beautiful hydra][blog2].

    [blog1]: http:2007/04/02/a-programming-language-only-a-mother-could-love/
    [blog2]: http:2008/01/21/lisp-the-beautiful-hydra/

    Childhood Nightmares
    ——————–

    When I’ve had time, I’ve been attempting the problems in [Project
    Euler][pe]. 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][pcl]. (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.

    [pe]: http://projecteuler.net/
    [pcl]: http://www.gigamonkeys.com/book/

  • Samurai Dog Armour

    February 11th, 2008

    samurai_dog_armor_1.jpg

    Fun oddness; [Samurai Dog Armour](http://feeds.feedburner.com/~r/PinkTentacle/~3/233241950/)

    >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](http://feeds.feedburner.com/~r/PinkTentacle/~3/233241950/)

  • The pleasure of single-tasking

    February 8th, 2008

    _Over Christmas, I spent six and a half hours driving from York to
    Pembrokeshire, to stay with Clare’s parents. What should have been a
    hellish drive was significantly more pleasant than expected. I’m going
    to talk about why, and make a wider point about life hacks._

    Long-distance driving, especially somewhere you’ve never been before,
    can often be nasty. You have to juggle several things at once —
    planning the route, controlling the car, talking to your passengers,
    etc — and you have time pressure, too. For me, this means stress.

    Two things, I think, made the journey much more pleasant;

    1. I drove an automatic,
    2. I used GPS to navigate.

    This offloaded several tasks from my brain; I no longer had to plan a
    route; everything was handed to me in simple-to-follow
    left/right/straight on choices, and if I made a mistake (which I did a
    couple of times) the GPS just routed round it, giving me a new route
    which got me there.

    The automatic gearbox also made things easier. That part of my brain
    that would normally be making sure I was in the right gear was no
    longer occupied.

    Life was simpler, so life was sweeter.

    Joel, of the [‘Joel on Software’][jos] site, uses the analogy of
    automatic transmissions when he talks about some [benefits for
    programmers][bfp] (scroll to ‘Automatic Transmission Wins
    the Day’). The wider point really is that freeing up your mind from
    one type of detail is like juggling with one fewer ball; it’s much,
    much easier.

    [jos]: http://www.joelonsoftware.com/
    [bfp]: http://www.joelonsoftware.com/articles/APIWar.html

    So this is my wider point; anything fully automatic (I mean really and
    truly don’t-make-me-think automatic) makes your life less stressful.

    The flipside, of course, is control. You always sacrifice a little
    control to the system. You lose precise throttle control in an
    automatic car. You lose control of exactly what stocks you own if you
    buy an index-tracker ISA.

    I think this scares people, but really shouldn’t — this level of
    detail will probably tire you, stress you, and give very little
    benefit over the automatic method.

    I’ll finish with a fantastic quote from [Alfred North Whitehead][anw],
    co- author of the [Principia Mathematica][pm];

    [anw]: http://en.wikipedia.org/wiki/Alfred_North_Whitehead
    [pm]: http://en.wikipedia.org/wiki/Principia_Mathematica

    > It is a profoundly erroneous truism, repeated by all copy books and
    > by eminent people when they are making speeches, that we should
    > cultivate the habit of thinking of what we are doing. The precise
    > opposite is the case. Civilization advances by extending the number of
    > important operations which we can perform without thinking about them.
    > Operations of thought are like calvary charges in a battle–they are
    > strictly limited in number, they require fresh horses, and must only
    > be made at decisive moments.

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

    February 6th, 2008

    I’ve just discovered [‘It’s all text!’][iat], 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][st]. When you save the file or close the editor,
    it copies all the text back into the web page.

    [st]: http://www.sublimetext.com
    [iat]: https://addons.mozilla.org/en-US/firefox/addon/4125

    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

    January 28th, 2008

    I’ve just bought a copy of [sublime text][st], 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][st] 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][elisp]

    3. **The support is amazing.** It’s written by Jon Skinner, an Australian who left his job at [Google][gg] 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][wr], 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][download] is 1.01, and already it’s stuffed with goodies.

    Anyway. Enough. [Go get it][download].

    [download]: http://www.sublimetext.com/download
    [elisp]: http://www.gnu.org/software/emacs/elisp-manual/html_mono/elisp.html
    [regex]: http://en.wikipedia.org/wiki/Regular_expression
    [wr]: http://hogbaysoftware.com/products/writeroom
    [notepad]: http://en.wikipedia.org/wiki/Notepad
    [vi]: http://en.wikipedia.org/wiki/Vi
    [emacs]: http://en.wikipedia.org/wiki/Emacs
    [st]: http://www.sublimetext.com/
    [gg]: http://www.google.com/

    Update: Here’s a copy of my enhanced Markdown package, which I use to write prose: [Download link](http://www.stevecooper.org/documents/Markdown-Enhanced.zip) — unzip it to your Packages folder. In the file `Markdown – Enhanced.sublime-options`, the first line describes the extensions which will open and use this format. Change it to change the file types (.txt, .fiction, etc) which will use this package.

←Previous Page
1 … 4 5 6 7 8 … 18
Next Page→

Create a free website or blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Subscribe Subscribed
    • Steve Cooper's Personal Blog
    • Already have a WordPress.com account? Log in now.
    • Steve Cooper's Personal Blog
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar