Thursday, May 14, 2009

[Poet] And go gets it

And go gets it
'Cept I don't.
I never do.

I begin
or pre-begin
or think
and muse.

But I do not do.

At least, I didn't do.

I always tried at first.
Always pushed and cajoled
hoped and cried
that I would finish.

But all dissolved to boredom.
To eeking and tweaking,
and hunting and fixing mistakes.
To dull dull dull,
the monolith grew.

Then I gained sophist
and saw the rolling story played
at school, at uni, at work,
of the repeated descent;
from lofty thinking mountain
to miserable dank undergrowth,
vast swallowing of the mountain hope.

But I am not repressed. I,
my creativity,
rebounds each time.
A quake, volcano rises,
dank foothills thrown to sky.

***

My wife suggests self-loathing, the
source from which the lava flows.
A reaction to familiarity,
and familiarity, self.

Do I greyly, merely
chase the new,
mesmerised by greener grass?
A fakery,
uncreatively
chasing foreign winds?

An inner, bitter remnant
suggests I quit.
Give up! And slide to mediocrity.
Sod the world, and hate it
endlessly.

I regard it as a clam regards the grit,
I will not yield.
If indeed, that is the choice.

Dare I dream?
Even if the dreams are worthless
in others' eyes?

Saturday, January 24, 2009

Synthetic synaesthesia, Part II: font-induced colours

Reading an old post that I didn't get around to publishing before, a new droplet has formed where the last one dried.

The gist of the first idea was to actively colour the letters on a page, to employ the brain's colour-recognition to improve spelling and reading ability. The flaw I found in reading further was that dyslexia and synaesthesia (seeing certain letters as coloured) are related.

In particular, this quote stuck out:

"My daughter, aged 11 is dyslexic and has grapheme-colour synesthesia. The colors negatively affect her ability to read and to spell, since some of the letters have the same color. E and U are both green, for example. She also tends to group the colors and hence inserts letters into words because she thinks their colors “go together”." - Mary G.

The Idea
Mary G's daughter seems to see spelling as a series of colours, and can thus happily swap E and U. However, there are likely to be other aspects of shape that affect the colour. For example, what colour is a spikier E, or a U with a wiggle in it? Intuitively, the changed shape would affect the letter's perceived colour, which might help Mary G's daughter. If an entire font was created based on a fairly standard font, in which certain letters had particular changes made, that girl and others like her might find reading easier, and might make recognising incorrect spellings easier too.

Flaws?
Inevitably, as this is based on intuition, I'm probably wrong. If the girl perceives all Es and all Us as the same colour, regardless of font or handwritten, this won't help.

Alternatives
One alternative might be to attach simple musical notes to the different letters, making sure they harmonise, but that problem groups like E and U do not sound similar. As she types, the flow of notes will be recognisably right or wrong for a given spelling.

Pointlessness
Admittedly, the girl could just rely on Word to correct her spelling all her life. She will also need to learn to spell when writing, and paper can't do customised sound effects.

But she could do a spelling bee with a little humming.

An email to Kyle Neath on IP and Capital

Reading That's My Property on Kyle's Warpspire blog, I saw some parallels with recent ponderings on capital versus cash flow.


Kyle,

Firstly, props for the blog, quite inspiring to see someone out there and getting on with things. Maybe I just like it because you're on my level. (I read your blog because you remind me of me - what a sentiment.)

Just been reading your thoughts on IP, and thought I'd draw some parallels with capital investment. I've been reading and thinking about capital, interest rates and salary, and it seems that the best thing is to try to turn a chunk of capital into an income, in a better way than just spending it in small chunks (mirroring your point on VC-hunting startups these days).

Suppose I have an idea. Not just any idea, but one of those 'this could change *everything* [for people like me trying to do what I'm trying to do right now]' ideas. The ones people get really precious about and fail to make use of for fear of exploitation. To me, that's like a chunk of money. Now, you can either use it as capital, and try to wring future returns out of it by renting it to other people (licensing), for which you need lawyers, or you can build your own company on it. Either way, it was only ever one idea, one chunk of money. It is limited in how much it can change the world, or get you early retirement.

Capital is limited. Much better is a flow of income. Saving £200 a month is better than investing £20,000, after four or five years. In a similar way, I treat ideas like a flow, not capital. I have some great ideas I'm wild about, but if I haven't done anything with them myself after a while, I will give them away. More ideas will come, formed and shaped by the experiences I have.

Ideas are always over-valued. Google was founded on one idea, sure, but they built on that initial investment with many, many others, and a lot of hard work.

I'm hoping to build a portfolio of the ideas I have, not to boast or to sell, but to convince someone, someday, that these things do not stop falling out of my head, and that it's worth paying me for a time so that I focus on *their* problems. Until then, I'm working on refining the filters, stimuli and breadth of search space available to my imagination so that what does fall out of it always improves in quality and usefulness.

I am, however, always wrong to some degree. Where am I wrong here?

Phil

Friday, January 16, 2009

Duck-typing vs static with interfaces

Reading Jason Baker's thoughts on the issue, here is my response:

Personally, I've been pondering duck typing vs interfaces for a while. It seems that the choice is between a catch-all (duck typing) and a square hole (interfaces). Interfaces are great for static languages, but are more restrictive at design time than going for duck typing. At the same time, duck typing means that an increasing number of tests are needed to make sure the system copes with different usage.

But what if we restrict ourselves to web services? A datastream (MIME, xml, etc) is passed in, and the service provider has an SLA contract for expecting it to 'work'. But since we're dealing with externally supplied input, we do all our input-checking at the start, to make sure it's all sanitised. After that, we have effectively already done the checking we need (if we've done it well).

Now, do you take the static+interface approach, because you already know what the input is like, or do you take the duck-typing approach, because we've already sanitised the input, and have our TDD tests aligned with our input sanitisation?

My answer would be to go with duck-typing here. If we've defined our SLA well, we have excluded non-compliant input data, which will be turned down at the point of reception into the system. Thus we can dispense with the overheads of interfaces, since we can (Atwood style) throw hardware at the interpreted language speed issue.

Friday, October 31, 2008

Catch them in the URL net.

In The Problem With URLs, Codinghorror ponders how to regex his way to catching URLs mixed in with user's text.


The whole discussion becomes about either how to write a better rule or regex, or whether to force users to delimit their URLs properly (with angle brackets, square brackets, bbcode tags...)


But this is foolish. 


Parsing text for things like URLs is a similar problem to trying to detect spam - the inputs are as varied as people can imagine them. So stop trying to deal with it using a series of fixed and universal laws!


Suggested algorithm:


  1. Get the feasible string: from the beginning of what you think might be a URL to the first space (or illegal character), allowing for i18n - you can use your regex here - and a list of any open parenthetics in the paragraph ( (,[,< etc).

  2. Generate a series of the possible URLs from it, by dropping each of the characters from the end that could be wrong:
    " Give me a URL (like http://www.example.com/querya?b)(ideally)? " becomes:

    1. "http://www.example.com/querya?b)(ideally)?"

    2. "http://www.example.com/querya?b)(ideally)"

    3. "http://www.example.com/querya?b)"

    4. "http://www.example.com/querya?b"

    5. "http://www.example.com/querya"


    and any other variations you find useful.

  3. Assign each one a rating based on:
    • whether there are unbalanced parentheses inside

    • whether the parenthesis would balance open ones in the paragraph - in this example the open bracket would be balanced by this close bracket, so that lowers the scores for a. and b.

    • whether the URL is sensible - "blah.com/)" is less sensible than "blah.com/"

    • any other good/bad valuation you can think of


  4. Rank the options

  5. If the top two (or more) options are very close or equal in ranking, then test for the existence of each by just polling the URLs in ranked order until you find a real one. If you adjust the threshold of how close is close, you should only be testing in rare cases. If you don't like polling, just pick one, you can't out-unwit every idiot or mistake.

  6. Finally, return the selected URL


There are endless ways to improve it beyond even that - you could even try balancing the parentheses such that your wikipedia article has its missing bracket fixed. At some point, perhaps, it becomes a bit pointless, but if this is all in a library and isn't too slow, nobody need rewrite it again, and the users are happy.


For me, the power of the method is in using ranking to allow unlikely options - unless you can separate all the possible inputs on a Venn diagram (which you can't here), then some rules will work for some sets of inputs, and others for others, and you'll never find a complete set that works for all of them.


In short, regexes only work for uniform and predictable input on their own


Other fun games:


  • consider trying to find wrongly-typed URLs and correcting them for the user

  • providing suggestions on 'better' URLs (did you mean .com instead of .vom?)

  • suggesting (and automating) the use of tinyurl or other URL compacting services for long or multiple-line-spanning URLs


Droplet or sign of a coming flood?

Friday, October 24, 2008

Interface-defined variables (or A quick idea on hybrid or diluted type systems 2)

Having expounded a vague hope in A quick idea on hybrid or diluted type systems, I came to realise that what I was really doing was defining a series of interfaces.

We can already define objects via interfaces:
ISomeInterface MyProperty = new ClassImplementingISomeInterface();


What if we limited ourselves to only defining any method or property with interfaces? Thus I would have a class MyClass, with properties IStringable NameString, IEnumerable<inumber> NumList, etc. That way the class would be maximally flexible, as we would be making the properties make only the minimum requirements of the inputs. Of course, if I pass an object that implements an interface derived from that required, it can still be cast into the minimum required interface.


Excellent, a dynamic and gregarious acceptance of many different static types - some of the innate strengths of dynamic languages in a statically-typed one.


Web Services


Let us step back from a moment and consider how this would help in the world of web services. A web service needs to be forgiving in what it will accept, and strict in its output, if it is to be used by the maximum set of other web services. If we assume that the input and output are various flavours of xml, then the static type is equivalent to the exact DTD of an xml doc, and the set of interfaces is, well, unknown.


In looking at REST interfaces, I came across a discussion of how to handle the inevitable change of interface versions when providing a RESTful API. Kalsey decides, in the end, to provide a version tag in the xml output file, containing pointers to the current, previous and latest API versions, with date-based URLs to provide access to specific versions of the API interface.


If, instead, we consider a request on a REST URI as a request for certain data conforming to a certain interface, then we can skip versioning. We define, instead, a series of smaller interfaces, and allow the user to request any subset of them. Thus my request xml should supply input data in an xml form that can be cast into any of the simpler interfaces, given an xml-generated object.

Stack Overflow Collab

Stack Overflow is new hub for the exchange of coding knowledge, built to leverage the innate tendencies of coding types to want to be right, to want to solve problems, and to gain kudos. So it has attracted many coders in search of recognition, and shows the important trait that its backers (Jeff Atwood, Joel Spolsky etc) are willing to follow the curve of user feedback. Thus SO is a community responsing to individual problems.

The Open Source movement, by contrast, has built up from existing partnerships (largely from the Real World) forming relaxed coding collaborations. The larger projects have then acquired others from across the net who were interested and got involved. The key here is that OSS is a community responding to a collective demand.

So how about filling in that great Venn overlap of community drawn by solutions to individual problems, and the productivity of a community solving a larger problem together? In other words, SO, give us a collaboration hub. Surely it's the ideal place for the inexperienced to participate at the fringes of an OSS project, and for experienced coders to progress up the kudos chain by contributing work and experience to a project, rather than a single point of expertise.

The system, interface, ranking, discovery and how it all overlaps with the overflowing stack of questions and answers on SO are subsidiary issues. But since people's individual project gave rise to problems, which gave rise to the need for SO, let the circle complete, and the solvers coagulate and combine to produce new projects.

I came, I saw, I solved, I wondered about the project, I got involved, we collaborated, we solved, we progressed, we share the story, we conquer.