2010-09-29

imagining the big G

When the inventor of concepts like "cyberspace" and the originator of cyber-punk and steam-punk talks about the most influential Artificial Intelligence the world has ever seen;

I listen.

Google’s Earth

We’ve seen nothing like it before, and we already perceive much of our world through it.
We’re citizens, but without rights. 
One thing I do take issue with though, is the idea that people should be divorced from their wild youth.
Nor do I take much comfort in the thought that Google itself would have to be trusted never to link one’s sober adulthood to one’s wild youth,
I think that future generations (or my generation) will just be more accepting of 'wild' behaviour, given that the majority of it will be discoverable by anyone.

One can hope anyway.

2010-09-28

Further down the rabbit hole

I was just reading Ben Hutchison's blog post on functional programming:
study-functional-programming-or-be-ignorant/

and I've come to a very similar realisation, with one notable additional point

lisp.

After watching some of the Structure and Interpretation of Computer Programs lectures,
my ideas about software, programming, data and computation have all been significantly changed.
The lectures focus on the theory of computer science using lisp.

In lisp, everything is (can be) represented as a list. This includes the source code, the interpreter, the environment, as well as data structures. The biggest change to my thinking occurred when they showed that something as fundamental as the list can be defined using closures and no other data structure. Something that I thought was an atom, built in, written in assembler; was actually definable in the language using other constructs.

This actually blew my mind.
It meant that all you needed was closures, and function application.
In the scheme example they showed in the lecture, it looked something like this:
(define (cons a b) (lambda (x) (x a b)))
(define (car x) (x (lambda (a b) a)))
(define (cdr x) (x (lambda (a b) b)))

The key is returning a when you call car(head), and b when calling cdr(tail).

I was so excited by this, I decided to implement it in a language I actually understood. ie NOT lisp.
I've been playing a bit with clojure and elisp, as well as haskell and I've been reading about F# and OCaml; But I keep coming back to scala, so I implemented it in that:
type consT[H, T] = ((H,T) => Any) => Any
def cons[H,T](a:H, b:T) : consT[H,T] = x => x(a,b)
def car[H,T](x:consT[H,T]) : H = x((a:H,b:T) => a).asInstanceOf[H]
def cdr[H,T](x:consT[H,T]) : T = x((a:H, b:T) => b).asInstanceOf[T]
 Most of which is actually type annotations, which ensure that the methods are completely generic. This is in contrast to lisps dynamic typing.

Some simplification is possible, but it's still not really the scala way:
type consT[H, T] = ((H, T) => Any) => Any
def cons[H, T](a: H, b: T): consT[H, T] = _(a, b)
def car[H, T](x: consT[H, T]) = x((a, _) => a).asInstanceOf[H]
def cdr[H, T](x: consT[H, T]) = x((_, b) => b).asInstanceOf[T]
If scala were to have some more advanced type inference or dynamic typing, it might look something like:
def cons(a, b) = _(a,b)
def car(x) = x((a,_) => a)
def cdr(x) = x((_,b) => b)
But it's pretty clear that that's not likely.

The beauty of it is, the lisp and scala uses of the above code is pretty similar.
something like this in clojure/lisp:
(def a (cons 1 (cons 2 3)))
(car a)
(car (cdr a))
(cdr (cdr a))

in scala:
val a = cons(1, cons(2, 3))
car(a)
car(cdr(a))
cdr(cdr(a))
So while the library side of things may be more complicated in scala, (also type safe), the actually usage is no more complicated at all.

2010-09-24

follow it through to the end

Developers should follow a piece of business functionality through to the end.

Going through every stage of requirements, design, implementation, testing, delivery.
Whatever process you are using from waterfall to agile, it doesn't matter.

The alternative is technology silos where each developer is assigned their own section, which leads to the abdication of responsibility:
"I only did the EJB bit"
"I only deployed the service"
"I just installed the thing"
etc

with no one being responsible for actually solving the business problem.

I might actually understand what a monad is

Monads are NOT elephants.

Monads aren't burritos.

Monads aren't even bullets.

Monads might be some kind of factory.

But after reading jquery-is-a-monad, it became clear that describing what monads are like, is NOT as useful as describing what things are monads.

In order to make a useful monad metaphor, the reader must be familiar enough with the subject that it helps understand monads more, not just confuse the issue.

no one explains objects in this fashion, no one says "objects are like buses" or "objects are like straitjackets"

After reading jquery-is-a-monad I think I might actually understand what a monad is!

then I came across what-is-a-monad, which makes a LOT of sense;
but would it have if I hadn't read the above descriptions first?

practising what exactly?

I was just reading another of steveyegge's blog posts from 5 or so years ago
http://sites.google.com/site/steveyegge2/practicing-programming
and he's talking about practising-programming, in a similar way to many other blog posts have.

There's one point that is mentioned here, and other places too that I have to disagree with.
...merely doing your job every day doesn't qualify as real practice.
I think it actually depends on what exactly you're practising.
For example, are you practising programming in a language you already know?
If so, you could try different approaches, or libraries or something

One thing I try to 'practise'/study is learning new technologies (or languages).
I take different approaches to learning each new technology, and monitor how easy/hard it is.

I think that counts as practising as much as any deliberate exercise.

I guess it all depends on what your job actually is.
If your job is to pump out as much code as possible, then practising programming itself is probably a good idea.

But I view my job (as a software developer) differently.
For the most part, my job consists of learning a technology or language or program or system that I know nothing about, and configuring or programming or modifying in some way.

The key part is the learning.

I'm practising learning.

it's for reading text

I bought a kindle 2 a few months ago, and I've enjoyed reading books, papers, etc on it.
Almost everything has been in pdf form though,
and the pdf fonts are not always optimised for e-ink reading (actually never optimised).

Yesterday I wanted to read an interesting blog on it, so I dumped the text from the website into a text file and loaded it up on the kindle.

I'd forgotten how much better the built in fonts are on the kindle.

Since then I've been converting all my pdfs to mobi format using calibre.
It converts the text perfectly, and almost all the images. The formatting can be pretty skewed though, which sucks for long lines of code.

Still, it's a hell of a lot better than reading the pdfs directly.