Tag: programming

Quines

:quine: /kwi:n/ /n./ [from the name of the logician Willard van Orman Quine, via Douglas Hofstadter] A program that generates a copy of its own source text as its complete output. Devising the shortest possible quine in some given programming language is a common hackish amusement.

<xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”&gt;
<xsl:output method=”xml” encoding=”utf-8″ />
<xsl:variable name=”s”></xsl:variable>
<xsl:template match=”/”>
<xsl:value-of select=”substring($s,1,148)” disable-output-escaping=”yes” />
<xsl:value-of select=”$s” />
<xsl:value-of select=”substring($s,149)” disable-output-escaping=”yes” />
</xsl:template>
</xsl:stylesheet>

quite amusing, yet ultimately boring as it always reconstructs only itself. it would be cool to add in some mutation, but apparently the problem is not so easy to solve:

It may be that the problem is not amenable to being solved by evolutionary methods. There may be too many local maxima, which give fair to middling scores, but no good way to step from a local maximum to the global maximum without ever getting a lower score.
It may be that the randomprog and mutate functions produced too many offspring with syntax errors or other obvious problems, so that it would have taken longer to generate an optimum solution that I had patience.

JohnnyVon, being rooted more firmly in the (simulated) world of physics and biology, might fare better.


JohnnyVon is an implementation of self-replicating machines in continuous 2D space. 2 types of particles drift about in a virtual liquid. The particles are automata with discrete internal states but continuous external relationships. Their internal states are governed by finite state machines but their external relationships are governed by a simulated physics that includes Brownian motion, viscosity, and spring-like attractive and repulsive forces. The particles can be assembled into patterns that can encode arbitrary strings of bits. We demonstrate that, if an arbitrary “seed” pattern is put in a “soup” of separate individual particles, the pattern will replicate by assembling the individual particles into copies of itself. We also show that, given sufficient time, a soup of separate individual particles will eventually spontaneously form self-replicating patterns. We discuss the implications of JohnnyVon for research in nanotechnology, theoretical biology, and artificial life.

in love of functional languages

i’m increasingly falling in love with xslt. i kinda skipped functional languages in school, so i’m happy to pick them up via angle brackets now. some recursive stuff is pretty nasty, but that is more a function (can you pun yourself?) of my lack of understanding..
in other news, saxon now has support for XSLT 2.0. yummy. some of the new features

  • regular expressions for text nodes
  • a grouping function xsl:for-each-group
  • casting via xsl:import-schema
  • multiple document output

knee-deep xml

i have been researching XUpdate, client-side XPath queries, XML databases and xsl:fo today. it strikes me that very very few open source projects really make use of XPath, XQuery or versioning of XML fragments. doing XSLT is not exactly innovative these days, time to move a bit closer to the cutting edge again. In search of small pockets of structure, as jon once said.
2 side notes: when i dimly remembered “small pockets of structure”, i googled for it, and my backup brain was the 2nd hit. jorge notified me about being #1 now, but i get reports from the us that they get a different hit for it. is google doing location-based ranking now?

From agility to fitness

as part of my presentation on open source software engineering, i pondered the benefits and pitfalls of the open source method. it occurred to me that the main advantages accrue in the long run, while the main problems are apparent in the short term. the challenge thus becomes how to breed the open source method with other methods, like agile methods, for the desired outcomes.

short-term issues

  • constantly changing resources (“footprints” in the code, “rewrite orgies”)
  • (often) no monetary incentives (who takes care of docs and testing?)
  • lack of control (unreliable feature sets and delivery dates)
  • conflicting goals (“do a bit of everything”)

long-term benefits

  • Collective code ownership (merit drives reviews)
  • Embrace change as the basic motivation (evolutionary fitness)
  • Rapid feedback is a natural consequence (user innovation networks)
  • (Potentially) very large talent pool (hedging, competition drives up quality)

in a nutshell: in the long run, darwinian pressures will guarantee an adequate solution. in the short term, agile methods achieve some of the same effects while satisfying budgetary and time constraints.
wyona tackles these issues by:

  • striving for generic functionality
  • short product cycles
  • frequent synchronization points with the main line
  • enticing customers to seek out scale (by sticking with standards)
  • enticing customers to donate back aggressively
  • developing customer projects in the open whenever possible
  • seeking out coopetitive opportunities
  • deriving customer value by relentless commoditization of the value stack

uh, the last few items reek of consultese. fix them with the bullfighter.

Beyond agile?

im speaking about open source software engineering at university of st. gallen tomorrow. the main tenet of my slides is that the agile methods and open source camps can learn from each other as they share many concepts.
btw, you can tell that i converted the slides to pdf with a unixy program (openoffice): they are all pixelated. i only see this with latex docs and unix output, really a pity.

virtual xml

Using the ObjectXPathNavigator over an object graph provides the power and flexibility of the XML programming model without the overhead of having to serialize an entire object graph into an XmlDocument.


the xml mindset is spreading to the abstract world of in-memory representation. if you go to all that trouble to learn xpath, you might as well use it 🙂

PHP static analysis

For PHP to serve on mission critical web sites, quality assurance becomes essential. However, since it is not a strongly typed language with variable and function declarations, the static error checking is very limited. Many errors, such as missing arguments to functions, are only reported when particular lines of code are run.
By translating the PHP to C , the excellent static analysis that produces errors and warnings in modern C and C compilers can be done on PHP.

hmm.. i recently ran static analysis code over the wyona codebase, and it was very helpful. i would love to have the same for php. id rather it would work with java, but there may be hope.