I've just watched Susan Blackmore giving a talk at TED, prompted by a New Scientist article. In it she effectively proposes that what makes us human is that we are mimics. In fact our ability to mimic others is so extraordinary that we have become the progenitors of another form of life.
But I have one niggling doubt about her hypothesis and the idea of evolution in general, and that is: how is it possible to distinguish a replicator that is blind and lucky and one that actively ensures its own survival?
Take the meme for a two pence coin for example. Clearly, it has been quite successful. There are probably millions of them in circulation and they fulfil their 'function' very well. Of course the physical coin is only an embodiment of the meme (the same way we are embodiments of genes); but we can use the coin as a proxy for the meme.
So how can we tell if the two pence coin actively ensures its own survival, to be passed down its generations, or has just been lucky enough to survive this long? In other words can we tell if the meme for a two pence coin has a directed purpose?
Firstly, we have to distinguish being lucky from having a purpose (to make sure it replicates). For example a piece of 3.5 billion year old rock just dug up from the ground, has probably just been lucky to have stuck around for so long. What about the chemical reaction that started life all those billions of years ago? Now we're not so sure, luck has undoubtedly played a part, but there must be something else that keeps the life replicators alive through the ages. In a word: feedback.
More specifically feedback with the replicator's environment. The replicator tips the survival odds in its favour by affecting the very thing that produces those odds, its environment. Now it becomes simpler to see how this could evolve, as any replicator necessarily uses resources from its environment in order to reproduce itself. This forms a feedback loop which the replicator can use to its advantage. Note that the replicator doesn't initially actively set out to change its odds of replicating, it just gets lucky with one of its feedback loops.
And this is my main niggle with the way evolution is portrayed, in that an organism (replicator) becomes as fit as possible in its niche over its evolution. It's not the whole story, the whole story is that the replicator changes it's niche because it's stuck in a feedback loop with it. So in a sense the niche becomes fit to the replicator.
So where does this leave our humble two pence coin? For sure, the meme has affected millions of humans (its environment) and we all buy into the delusion of what it can do for us and what it stands for.
May it live long and prosper.
Friday, 14 August 2009
Thursday, 5 March 2009
Computers
I often wonder what I would be doing if I didn't program computers for a living. I have had several influences in my life that have directed me this way.
My first was my dad's Hewlett Packard calculator. I must have been four years old when I got my hands on it. Of course I had no idea what it was really for. But I could read numbers. I quickly learned that I could add numbers and I understood that. But some of the keys mysteriously produced what seemed to be random digits and that really piqued my curiosity. By playing around I worked out that the same keys would always produce consistent results, so somehow they did something meaningful, I just couldn't imagine what. So I asked the oracle: my father.
He did some drawings and explanations of trig, and I think I half understood it, not bad for a four year old and I also half understood how the numbers on the calculator related to it. Of course to grasp that I had to understand what fractions were about: no problem apparently.
So the stage was set, the combination of buttons, numbers and patterns was intoxicating.
The next big moment was due to my uncle. He'd recently bought a ZX81 one of the very first home computers. And on a visit to his, he let me play on it. I was probably nine years old. He showed me a program showing a four stroke engine and a flight simulator. I found the visual aspect of it was enthralling, it was like nothing else I'd seen. And the computer's size and mysterious symbols on the keyboard appealed to me. But it was when my uncle showed me a program that he'd written to simulate two steam engines crashing together, that I was hooked. Steam engines were of course my other passion! Seeing that program gave me the same thrill as playing with the calculator: the symbols may be weird, but they could be deciphered and understood and I could even create my own mini-world with it.
The thought of that black ZX81 swam around in my head, until I could nearly contain it no longer, I just had to have one. I would wait a year until the next Birthday/Christmas came along. I was writing my first program in hours, and that was it, I became a programmer.
Of course time passed and bigger and better things always come along. I saw 'The Computer Program' not long after and saw the BBC Microcomputer in action for the first time. It did everything my computer did but better. It had colour, sound and I could even create dancing men on the screen if I wanted. It was amazing. I yearned for one, but I had no excuse, I already had a computer. And a beeb was very expensive too. So I waited and waited. Until my parents caved and bought me an Acorn Electron. Not a beeb but good enough to spend hours, days and weeks, writing programs for it. I learned assembly language and how computers ticked and soon realised there was a huge unfathomable pit of learning that I could do...
My first was my dad's Hewlett Packard calculator. I must have been four years old when I got my hands on it. Of course I had no idea what it was really for. But I could read numbers. I quickly learned that I could add numbers and I understood that. But some of the keys mysteriously produced what seemed to be random digits and that really piqued my curiosity. By playing around I worked out that the same keys would always produce consistent results, so somehow they did something meaningful, I just couldn't imagine what. So I asked the oracle: my father.
He did some drawings and explanations of trig, and I think I half understood it, not bad for a four year old and I also half understood how the numbers on the calculator related to it. Of course to grasp that I had to understand what fractions were about: no problem apparently.
So the stage was set, the combination of buttons, numbers and patterns was intoxicating.
The next big moment was due to my uncle. He'd recently bought a ZX81 one of the very first home computers. And on a visit to his, he let me play on it. I was probably nine years old. He showed me a program showing a four stroke engine and a flight simulator. I found the visual aspect of it was enthralling, it was like nothing else I'd seen. And the computer's size and mysterious symbols on the keyboard appealed to me. But it was when my uncle showed me a program that he'd written to simulate two steam engines crashing together, that I was hooked. Steam engines were of course my other passion! Seeing that program gave me the same thrill as playing with the calculator: the symbols may be weird, but they could be deciphered and understood and I could even create my own mini-world with it.
The thought of that black ZX81 swam around in my head, until I could nearly contain it no longer, I just had to have one. I would wait a year until the next Birthday/Christmas came along. I was writing my first program in hours, and that was it, I became a programmer.
Of course time passed and bigger and better things always come along. I saw 'The Computer Program' not long after and saw the BBC Microcomputer in action for the first time. It did everything my computer did but better. It had colour, sound and I could even create dancing men on the screen if I wanted. It was amazing. I yearned for one, but I had no excuse, I already had a computer. And a beeb was very expensive too. So I waited and waited. Until my parents caved and bought me an Acorn Electron. Not a beeb but good enough to spend hours, days and weeks, writing programs for it. I learned assembly language and how computers ticked and soon realised there was a huge unfathomable pit of learning that I could do...
Friday, 5 September 2008
Parallel Programming 1
I've recently been thinking about how to write a text editor. I've written one or two in my time, so why write another? Well, mostly as a programming exercise and because I can.
In thinking about how to do this in a new and novel way and most importantly: efficient way, I came up against some mental hurdles.
In any programming project there is a translation that has to happen between what's in the head and what comes out on the page. Somehow the model in your head has to be coded into a model inside a computer. This process is hard.
So how to write a text editor from scratch? Inside my head, I have a document, a mouse and keyboard and type away. What's so hard about that? Well the problem is one of representation. Let's break it down.
First the document has to be modelled. Well, its a bunch of text contained in a set of lines. This translates to an Array in code. Good. The size of the array gives you the number of lines and each element of the array contains a line of text. Well, maybe.
The problem is that of wrapping, ideally we want our text to continue on to the next line when we type, if we reach the edge of the screen (or window). Ok, so we can use a big string of text to represent our entire document instead, and wrap to our heart's content. Good. Well maybe not.
The problem with a big string representation of text is that for a given position in the text, you don't know what line on the screen you're on. And you need this information in order to position the insertion point (cursor) correctly. It gets worse, characters on a modern system all have different widths, an i is skinnier than an o, so if we have a line of text in an array, we don't even know where to put the cursor horizontally without taking all those widths into account. Ok, so we write functions to work all these things out for us.
Ok, so we plumb for the big string representation, keep a note of the character position in this string to represent the insertion point and run a bunch of functions when we need to work out screen positions etc. The problem with this, is that it's inefficient. Any time we change any bit of text, we need to recalculate the whole lot to display it on the screen.
So how can the efficiency be improved? The answer is to have a good model in the first place and to only re-calculate the absolute minimum in response to a keystroke for example. This is hard, primarily because we have to take a lot of cases into consideration, and re-calculate differently based on each case.
The answer will be in my next blog.
In thinking about how to do this in a new and novel way and most importantly: efficient way, I came up against some mental hurdles.
In any programming project there is a translation that has to happen between what's in the head and what comes out on the page. Somehow the model in your head has to be coded into a model inside a computer. This process is hard.
So how to write a text editor from scratch? Inside my head, I have a document, a mouse and keyboard and type away. What's so hard about that? Well the problem is one of representation. Let's break it down.
First the document has to be modelled. Well, its a bunch of text contained in a set of lines. This translates to an Array in code. Good. The size of the array gives you the number of lines and each element of the array contains a line of text. Well, maybe.
The problem is that of wrapping, ideally we want our text to continue on to the next line when we type, if we reach the edge of the screen (or window). Ok, so we can use a big string of text to represent our entire document instead, and wrap to our heart's content. Good. Well maybe not.
The problem with a big string representation of text is that for a given position in the text, you don't know what line on the screen you're on. And you need this information in order to position the insertion point (cursor) correctly. It gets worse, characters on a modern system all have different widths, an i is skinnier than an o, so if we have a line of text in an array, we don't even know where to put the cursor horizontally without taking all those widths into account. Ok, so we write functions to work all these things out for us.
Ok, so we plumb for the big string representation, keep a note of the character position in this string to represent the insertion point and run a bunch of functions when we need to work out screen positions etc. The problem with this, is that it's inefficient. Any time we change any bit of text, we need to recalculate the whole lot to display it on the screen.
So how can the efficiency be improved? The answer is to have a good model in the first place and to only re-calculate the absolute minimum in response to a keystroke for example. This is hard, primarily because we have to take a lot of cases into consideration, and re-calculate differently based on each case.
The answer will be in my next blog.
Wednesday, 20 August 2008
All Change Please
Nothing lasts for ever. It really doesn't. Choices are made, things change. We are awash in a sea of change. This change is fundamental to the fabric of the universe. Nothing is ever at a standstill, from the quantum foam of virtual particles to the ever expanding universe. We are made from change.
Change is inescapable. So why is it so resisted by some of us? Life, in a word. The sheer fact that life persists in this ever changing flux, means that in some sense it thwarts change. This is survival, a fight against change. And being alive, we have the survival instinct. This instinct to survive permeates our very essence. We are born with these instincts, but some need to be learnt and this learning can be imperfect. We learn to fear change because it threatens our survival.
Because of the barrage of change around us, we learn to assess risk to our survival very quickly, even as babies. The assessment of risk is about crystal ball gazing, looking into the future and imagining what might happen. It's an uncertain science by its very nature, some things are more certain than others and can be more easily imagined and played through.
It's uncertainty that builds fear of change. Of course uncertainty isn't really a thing, it's a process, dynamic. This means uncertainty can be reduced. There are several ways to do this. Firstly, is improve your internal modelling of the future, by gathering more information. Ask other people about their experiences, research it. Secondly, find new ways to model it, use your imagination to its full potential, allow yourself to get engrossed in the details of your future - this will increase the certainty that you can beat change and survive. Thirdly, take the risk. This can be done in stages, so that the change (risk to survival) is manageable.
Lastly, have a goal. This works on the assumption that we all constantly strive for something better (see Boredom). If the thing or future is tantalising enough, we'll be prepared to take a greater risk for it. In other words, if we can improve our chances of survival in the longer term in exchange for some uncertainty in the shorter term, then we generally will.
So the goal has to be good, appealing. Goals are of course imaginary and so you need to employ your imagination to its fullest and create an attractive risk. And of course, this doesn't have to be a solitary activity. If you can share it with others, all the better.
Change is inescapable. So why is it so resisted by some of us? Life, in a word. The sheer fact that life persists in this ever changing flux, means that in some sense it thwarts change. This is survival, a fight against change. And being alive, we have the survival instinct. This instinct to survive permeates our very essence. We are born with these instincts, but some need to be learnt and this learning can be imperfect. We learn to fear change because it threatens our survival.
Because of the barrage of change around us, we learn to assess risk to our survival very quickly, even as babies. The assessment of risk is about crystal ball gazing, looking into the future and imagining what might happen. It's an uncertain science by its very nature, some things are more certain than others and can be more easily imagined and played through.
It's uncertainty that builds fear of change. Of course uncertainty isn't really a thing, it's a process, dynamic. This means uncertainty can be reduced. There are several ways to do this. Firstly, is improve your internal modelling of the future, by gathering more information. Ask other people about their experiences, research it. Secondly, find new ways to model it, use your imagination to its full potential, allow yourself to get engrossed in the details of your future - this will increase the certainty that you can beat change and survive. Thirdly, take the risk. This can be done in stages, so that the change (risk to survival) is manageable.
Lastly, have a goal. This works on the assumption that we all constantly strive for something better (see Boredom). If the thing or future is tantalising enough, we'll be prepared to take a greater risk for it. In other words, if we can improve our chances of survival in the longer term in exchange for some uncertainty in the shorter term, then we generally will.
So the goal has to be good, appealing. Goals are of course imaginary and so you need to employ your imagination to its fullest and create an attractive risk. And of course, this doesn't have to be a solitary activity. If you can share it with others, all the better.
Beating Boredom
Boredom is great. I think generally it is seen in a negative light (strange how many words seems to fall in the negative and positive categories: sadness, hate, happiness, love). In fact I would say boredom is one of the really defining traits of being human. Generally it denotes a lack of interest in whatever is going on at a moment in time. Often when lack of interest kicks in, our minds wander on to other things that we would like to do and this seems to intensify the boredom we feel: it is a motivator.
This is an interesting mechanism. Boredom allows us to disconnect from what's going on around us and allow us to dream a bit. Children generally don't deal well with boredom, they can become agitated and downright obnoxious. But as we get older we learn to tolerate it, and this is seen as maturity (a positive word). In learning this tolerance we can become complacent to the point that we stop recognising that we're bored and just accept things as they are.
Maybe we should be more like children. I don't advocate shouting or moaning 'Are we there yet?' or kicking up a fuss whilst waiting for a bus. But allowing ourselves to dream and create options for ourselves, to think about what we want next from life. And, also to enlist others in stopping our boredom. Maybe you'll find out they're bored too.
Boredom can also occur at different levels. You could have a completely comfortable life, a well paid job, a nice house to live in, good friends and family. So on a micro level, there's no boredom, you're content and occasionally interested in your life. But you still get twinges, nothing changes, you're just playing the same routines in different combinations. Being content just doesn't cut the mustard. You're bored, at a macro level.
The way out, is to acknowledge the boredom, revel in it. Allow yourself to disconnect, and then start dreaming of something more exciting. This will of course increase the boredom, until the point where you do something and start carrying out those dreams. It may take time, but if you dream enough, the motivation builds and eventually something happens.
This is an interesting mechanism. Boredom allows us to disconnect from what's going on around us and allow us to dream a bit. Children generally don't deal well with boredom, they can become agitated and downright obnoxious. But as we get older we learn to tolerate it, and this is seen as maturity (a positive word). In learning this tolerance we can become complacent to the point that we stop recognising that we're bored and just accept things as they are.
Maybe we should be more like children. I don't advocate shouting or moaning 'Are we there yet?' or kicking up a fuss whilst waiting for a bus. But allowing ourselves to dream and create options for ourselves, to think about what we want next from life. And, also to enlist others in stopping our boredom. Maybe you'll find out they're bored too.
Boredom can also occur at different levels. You could have a completely comfortable life, a well paid job, a nice house to live in, good friends and family. So on a micro level, there's no boredom, you're content and occasionally interested in your life. But you still get twinges, nothing changes, you're just playing the same routines in different combinations. Being content just doesn't cut the mustard. You're bored, at a macro level.
The way out, is to acknowledge the boredom, revel in it. Allow yourself to disconnect, and then start dreaming of something more exciting. This will of course increase the boredom, until the point where you do something and start carrying out those dreams. It may take time, but if you dream enough, the motivation builds and eventually something happens.
Labels:
boredom,
excitement,
imagination,
interest
Tuesday, 19 August 2008
Conciousness Delayed
I read in New Scientist recently something along the lines that, the impulse to move a finger is created somewhere in the brain a full seven seconds before the finger actually moves. It was something like that anyway. In any case it set me thinking.
It stands to reason that the signals or potentials around the brain take a finite time to be 'processed'. This processing is massively parallel and happens asynchronously. It would also seem reasonable that different pathways take different times to process. For example the auditory pathway may be quicker than the visual pathway, which has to handle greater and more complex information. But, in our concious mind things happen simultaneously. The sound of a plate smashing happens at the same instant you see it hit the ground. The only way this could happen is for the processing in the auditory pathway to be slowed down or delayed and then somehow synchronised with the results of the visual pathway.
This idea could be extended. Maybe our entire concious experience is delayed? By delay I don't mean micro seconds or seconds, but longer. How could this make sense? Surely, this concious experience is needed to in order to react in a timely manner to our environment? Maybe not.
It's obvious that a lot of what goes on in our bodies is ultimately out of the reach of conciousness. We cannot affect the functioning of our liver for example, by thinking about it. But what if everything were out of the reach of our conciousness? What if everything we did was simply driven unconciously. Then, the delayed conciousness wouldn't be so problematic. Instead it would be more like a replay of what just happened outside of conciousness. This severance of the equality of conciousness with reality, would allow the brain to take as long as it likes to create the concious experience, while still processing reality 'out there' in a timely manner.
So what's the point of conciousness? Do we need it? My guess is that it's something to do with social cohesion, language and identity within the group. In other words, consciousness allows us to report our internal world to others.
It stands to reason that the signals or potentials around the brain take a finite time to be 'processed'. This processing is massively parallel and happens asynchronously. It would also seem reasonable that different pathways take different times to process. For example the auditory pathway may be quicker than the visual pathway, which has to handle greater and more complex information. But, in our concious mind things happen simultaneously. The sound of a plate smashing happens at the same instant you see it hit the ground. The only way this could happen is for the processing in the auditory pathway to be slowed down or delayed and then somehow synchronised with the results of the visual pathway.
This idea could be extended. Maybe our entire concious experience is delayed? By delay I don't mean micro seconds or seconds, but longer. How could this make sense? Surely, this concious experience is needed to in order to react in a timely manner to our environment? Maybe not.
It's obvious that a lot of what goes on in our bodies is ultimately out of the reach of conciousness. We cannot affect the functioning of our liver for example, by thinking about it. But what if everything were out of the reach of our conciousness? What if everything we did was simply driven unconciously. Then, the delayed conciousness wouldn't be so problematic. Instead it would be more like a replay of what just happened outside of conciousness. This severance of the equality of conciousness with reality, would allow the brain to take as long as it likes to create the concious experience, while still processing reality 'out there' in a timely manner.
So what's the point of conciousness? Do we need it? My guess is that it's something to do with social cohesion, language and identity within the group. In other words, consciousness allows us to report our internal world to others.
Programming the Web
I do a lot of web programming at work, with a combination of PHP, HTML, CSS and Javascript. Once you've understood how each language works, using them together is no problem. The thing is, is that really all these components of web programming were designed separately from each other and bolted together. This makes for ineligant code, to both program and read.
There are several things that spring to mind when coding web pages: the need for escaping, the differing syntaxes, the similarity of Javascript and PHP. Wouldn't life be simpler if these components were unified?
The answer is to employ the block notation of C like languages (such as PHP and Javascript). This could be used to immediately simplify HTML and make it less verbose. For example an ordered list might look like:
ol {
li{First item}
li{Second item}
}
Given good identation, this is already more readable. Also this ties in a lot better with the other three components and their syntax. How are HTML attributes to be done? Again the answer is to pinch the notation for functions in PHP and Javascript:
table (width: '25%'; border:'2px') {...}
So the semantics here are that parameters are in round brackets whereas code or children are in braces. The parameter syntax is very similar to that of the existing CSS syntax, so this can also be brought into the fold:
#div (
text-align: 'left';
position: 'absolute';
)
Note the round brackets. This scheme allows us to get rid of the escaping nonsense and to remove the sense of these disparate components being bolted together. How so? Well luckily most HTML tags are different from PHP and Javascript keywords. For example you could do the following:
html {
body {
for ($index = 1; $index<=10; $index++) {
echo 'This is body line '.$index;
}
}
}
This example shows how you can freely mix HTML markup and PHP code together, without having to escape from one to the other. This makes for clarity in reading and reduces the semantic baggage when trying to decipher code. Here's an example which would mix all the components together:
html {
head {
script{
function sayHi() {
alert('Hi there!');
}
}
style {
.box (
background-color:#009966;
)
}
}
body (bgcolor: 'red'; text: 'blue') {
div (onClick: sayHi(); class: 'box') {
'Click me';
}
}
}
The only exceptional thing here is how to handle blocks of text in HTML. These would need to be escaped in some fashion, so as not to be confused with PHP code. I'm not 100% sure how this should be done. A simple way, as shown in the preceding example, would just be to enclose the text in quotes. Another way would be to have an explicit 'text' tag, but then you may as well use the 'echo' statement in PHP.
How would such a file be used in practice? The ideal of course would be for a web server like Apache to read the file and execute it straight off, emitting the result as conventional HTML/CSS/Javascript. A second easier solution, is to write a compiler which would convert the new format syntax into the conventional style. The converted pages would then be used as normal.
Lastly, is the issue of Javascript/PHP. It would be wonderful, if there wasn't a need to learn two separate languages with very similar syntax. Why not go the whole hog and produce a hybrid of the two? Maybe easier said than done.
There are several things that spring to mind when coding web pages: the need for escaping, the differing syntaxes, the similarity of Javascript and PHP. Wouldn't life be simpler if these components were unified?
The answer is to employ the block notation of C like languages (such as PHP and Javascript). This could be used to immediately simplify HTML and make it less verbose. For example an ordered list might look like:
ol {
li{First item}
li{Second item}
}
Given good identation, this is already more readable. Also this ties in a lot better with the other three components and their syntax. How are HTML attributes to be done? Again the answer is to pinch the notation for functions in PHP and Javascript:
table (width: '25%'; border:'2px') {...}
So the semantics here are that parameters are in round brackets whereas code or children are in braces. The parameter syntax is very similar to that of the existing CSS syntax, so this can also be brought into the fold:
#div (
text-align: 'left';
position: 'absolute';
)
Note the round brackets. This scheme allows us to get rid of the escaping nonsense and to remove the sense of these disparate components being bolted together. How so? Well luckily most HTML tags are different from PHP and Javascript keywords. For example you could do the following:
html {
body {
for ($index = 1; $index<=10; $index++) {
echo 'This is body line '.$index;
}
}
}
This example shows how you can freely mix HTML markup and PHP code together, without having to escape from one to the other. This makes for clarity in reading and reduces the semantic baggage when trying to decipher code. Here's an example which would mix all the components together:
html {
head {
script{
function sayHi() {
alert('Hi there!');
}
}
style {
.box (
background-color:#009966;
)
}
}
body (bgcolor: 'red'; text: 'blue') {
div (onClick: sayHi(); class: 'box') {
'Click me';
}
}
}
The only exceptional thing here is how to handle blocks of text in HTML. These would need to be escaped in some fashion, so as not to be confused with PHP code. I'm not 100% sure how this should be done. A simple way, as shown in the preceding example, would just be to enclose the text in quotes. Another way would be to have an explicit 'text' tag, but then you may as well use the 'echo' statement in PHP.
How would such a file be used in practice? The ideal of course would be for a web server like Apache to read the file and execute it straight off, emitting the result as conventional HTML/CSS/Javascript. A second easier solution, is to write a compiler which would convert the new format syntax into the conventional style. The converted pages would then be used as normal.
Lastly, is the issue of Javascript/PHP. It would be wonderful, if there wasn't a need to learn two separate languages with very similar syntax. Why not go the whole hog and produce a hybrid of the two? Maybe easier said than done.
Labels:
css,
html,
php,
programming language,
web
Subscribe to:
Posts (Atom)