Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Saturday, October 20, 2012

Programming Languages Should be Unnatural


I have always thought that the notion of making programming languages more like natural ones is absurd. Without a truly formidable amount of artificial intelligence, practical natural-like programming languages amount to eschewing symbols for words, which more adds inconvenience than clarity (I'm looking at you, Applescript). If anything, I feel natural languages should be made more like artificial ones than the other way around. In very technical disciplines, this is actually done after a fashion: they adopt a precise specialized jargon to help combat the inherent ambiguities and limited vocabularies of context dependent natural language.

Thursday, September 1, 2011

The Evolution of Lines

Good evening, ladies and gentlemen...

Bang Goes the Theory had a segment using the repeated freehand tracing of a single line to illustrate some of the basic mechanisms of evolution. It lacked any selective pressure, so I whipped up a program to add some. I started with ten perfectly straight lines, each of which had ten offspring with a small chance of containing replication errors (1% to shift each pixel one place right or left). From that pool of one hundred, I then chose the ten that most resembled my target shape and repeated the process. To keep it simple, I didn't require the line be continuous (in fact, it's not technically a line as there's only one pixel for each vertical position on the image). I used the sum of the horizontal distance squared for each pixel from it's target x value as a measure of fitness. You may recognize the final shape, which took 2,200 generations to settle upon. Its efficiency could be increased dramatically as the algorithm employed was crude.

This is a lot less involved (asexual reproduction for a start) than many genetic algorithms I've written, but it's much less abstract.