Archive for the ‘computing’ Category

What’s Twitter for?

Wednesday, February 25th, 2009

Discounting the last week, my last blog post was on 24 October, then 3 July, then 18 April. Prior to that I was posting a couple of times a month. So what happened to my blog in 2008?

I started using Twitter.

Twitter has been getting some mainstream press lately, mostly though celebrities using it — especially Stephen Fry and Jonathan Ross. As with any new communication medium people are asking: what exactly is it good for? On the Twitter website the synopsis is: "What are you doing?" Well, that doesn't quite describe how I use it. Here's what I use it for.

I use Twitter for semi-realtime conversations.

It may have started out as "What are you doing?" but really, that's just the starting point. Sometimes you really do say what you're doing and if your friends find it interesting, they can comment on it. And not only what you're doing — what you're reading and thinking too. I made only two "QOTD" blog posts last year because I was using Twitter to point these out instead.

Using TwitterFox, which makes my followings instantly available, it's more immediate than a blog and its comments which you have to dive into a feed reader to follow. It's also more uniform than blogs-with-comments, in the sense that the original message and its replies have the same status — they are both just tweets, whereas a blog post is somehow more important than the comments attached to it.

But at the same time it's less immediate than, say, Milliways, or IM. There was a gaping hole between realtime chat and blogging in terms of immediacy and Twitter fills that gap, which I think is why it's so popular. Nobody really wants to know what you are doing every minute of the day and of course letting them know can be dangerous. But it's for sparking discussion and carrying it on, in a way that's in the present yet not demanding that you pay constant attention.

Static typing and correctness

Wednesday, March 19th, 2008

I've been pointed to a post by Joel Spolsky advocating Hungarian notation so that code that fails to properly sanitise strings "looks wrong".

Here's Joel's example. The idea is that you prefix the names of all string variables and functions returning strings with either "s" or "us" depending on whether they're safe or unsafe respectively. Then assignments that have "s" on one side and "us" on the other just look wrong.

us = UsRequest("name") // ok, both sides start with US
s = UsRequest("name") // bug
usName = us // ok
sName = us // certainly wrong.
sName = SEncode(us) // certainly correct.

Well I can think of one pitfall already. How do you mark whether a function expects safe or unsafe data in a way that makes wrong code look wrong?

us = UsRequest("name") // okay
RandomMangler(s) // okay
RandomMangler(us) // errm... wrong?

If you're using a language that supports it, there is a far better way. (more...)

QOTD XIV

Monday, July 30th, 2007

From the outside, the type systems of languages like Haskell and ML tend to look like a sort of archaic ecstatic religious rite. The bleeding mendicants pause as they shuffle past, sing a verse in praise of the purifying pain of strong typing, then prod themselves with pointy sticks and progress along their lonely road.

Bryan O’Sullivan, commenting on his own quotation of Yaron Minsky. I’ve heard people complain about Haskell’s type system as being too strict, but once you figure out how to get things to type check, you can actually use it like a miniature theorem prover. Which is, essentially, what it is.

Oh yeah, and it’s my birthday today.

Codata

Monday, July 16th, 2007

On Planet Haskell today, sigfpe posted a fairly readable (i.e., hopefully comprehensible to non-experts) essay about Data and Codata. I intend to do a talk on this topic someday, but in the meantime, you might find this enlightening.

QOTD X

Monday, April 9th, 2007

The other critical component of Ajax is Javascript, the programming language that runs in the browser. Microsoft saw the danger of Javascript and tried to keep it broken for as long as they could. But eventually the open source world won, by producing Javascript libraries that grew over the brokenness of Explorer the way a tree grows over barbed wire.

Paul Graham. Microsoft is dead, apparently. It certainly no longer taints my computer — I wiped Windows in favour of Ubuntu Feisty last week. The change affected my life so little that I never got round to blogging about it.

Change is the root of all evil (apparently)

Monday, April 2nd, 2007

Being the functional programming nut that I am, I couldn’t help but chuckle at this.

An analogy

Tuesday, February 20th, 2007

Suppose everyone communicates via scribes, who write in ancient Egyptian hieroglyphs, and Microsoft is the only company who trains them.

Now there do exist some talented linguists who can figure out approximately what they’re writing. That’s what the Rosetta Stone was about, except in this analogy there’s no Demotic or Greek alongside, only the hieroglyphs and a scribe to tell you what they mean in English. Unfortunately, after they send the scribes away, the linguists can never be sure that they’ve got it right, especially since Microsoft can change the language as they like simply by changing the curriculum. As soon as new scribes start writing in this new language, the old scribes will stop being able to interpret some messages you receive because they don’t know about the changes in the language.

(more…)

Milliways and the equivalence of programming languages

Friday, January 26th, 2007

It’s been known since the time of Turing that what’s computable in one reasonably powerful programming language is computable in every other one. As a result, we can say that large classes of programming languages are ‘equivalent’ in the sense that they can emulate each other. However, not all programming languages have natural equivalents of all the others’ features.

This is the idea behind Greenspun’s Tenth Rule:

Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.

The usual corollary is “including Common Lisp”. We could say the same for C: most C compilers are implemented in C and compile themselves. Similarly, the Glasgow Haskell Compiler is written (mostly) in Haskell. Actually, given that C is the implementation language for so many interpreters, it’s easy to see that one could, in principle, write a program in language X by directly creating the abstract syntax tree and passing it to an “evaluate” function, all in C.


(more…)

QOTD VII

Monday, January 15th, 2007

Found on Wikiquote:

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

— Brian Kernighan

The essence of functional programming

Friday, January 5th, 2007

Here’s an interesting toy language/Turing tarpit for you: Lazy K.


You may already have seen Unlambda, which is essentially the lambda calculus in programming langauge form. (Actually, as its name suggests, it doesn’t actually have any lambdas – it’s really based on the equivalent SKI combinator calculus.) However, Unlambda is a horrible dirty – ahem, I mean impure functional language because 1) it isn’t lazy and so programs in it can sometimes gratuitously fail to terminate, and 2) it has an exception to the evaluation rules (the d ‘function’) and side effects (the .x function prints the character x). Also, in Unlambda version 1 there is no way to do input.


Lazy K is no easier to write programs in than Unlambda (that’s hardly the point, is it? :). But it solves all these problems: it is lazily evaluated; there are no side effects; and you can do input.


(more…)