Reflective Wiki

Spawned from WikiPlacenameProblem by this comment:

Actually, a "reflective" Wiki which could be used to alter its own source code would be a very worthwhile thing. On the other hand, it is also most definitely and absolutely certainly a stupid idea and one that couldn't possibly work, ever ever. On the gripping hand an ObjectOrientedWiki could certainly work. Combine that with ManaMana and one might have a TarBaby. Hmm. -- PeterMerel

Hence the ReflectiveWiki is an idea or suggestion for yet another WikiEngine.

Which technology? How would it work?

Well, it seems obvious that you would need a strong sandbox.

You would probably need some automatic version control, such that the system could automatically roll back changes which cause it to malfunction.

Supposing each "page" had a UnitTest, you then have a hook for your version control - if the change you are making will break the ReflectiveWiki, then you must commit to a branch.

Of course, that would be VersionControlAppliedToWiki gone mad.

I don't think such a thing is necessary. Just provide some rudimentary scripts (eg show and edit) that cannot be altered, but usually use other (reflective) interfaces to the wiki. Make an exception handler that points the user directly to the non-alterable edit script on the right file.

Likely side effects

I can see that this system is not going to be popular with the casual WikiZen.

SelfModifyingCode is often ConsideredHarmful, so I can see that the average contributor is likely to be a hacker with a twisted mind. Hence the ReflectiveWiki would have some amazing features, but few will be able to understand or use them.

In case there was still some doubt, it would nicely underline the fact that CodeIsSpeech? (in the ProtectedByAmericanConstitution? sense. See also DigitalMillenniumCopyrightAct).

There could be problems with ensuring that the code compiles. OK, you could check that at submission time, unless "do" or "use" are allowed to include other pages - you don't want to have to "perl -wc" the whole site each time.

Then there is the HaltingProblem. Solve that and you're on to a winner! 8->


I started the page thinking the idea must be bonkers, but I'm not so sure now. -- MatthewAstley

See also WikiEngines and WikiEnginesWanted

Well, you don't actually need to build all that much. Start with a plain vanilla Wiki. You could just add some special TextFormattingRules to mark those areas that are ReflectiveWiki code. Then a small script can be run whenever "save" is pressed to strip out all lines of ReflectiveWiki text into a file.

A UserModeLinux sandbox can run the actual ReflectiveWiki.

Of course that leaves one wondering about a MetaReflectiveWiki?...

A ReflectiveWiki could also just have one layer that users could edit for instance using PrologLanguage to assert facts and rules, and query them, and another underlying layer (in perl, java or whatever) that would not be user modifyable. Perhaps with import/export from/to RDF. Most SemanticWeb/SemanticWiki/RdfWiki sites seem just about storing facts a ReflectiveWiki could allow inference on the facts. So even if the knowledge/rulebase got deleted or mangled it could be repaired by users from recent edits the basic functionality to allow viewing, adding, editing would not be affected.

For instance describes an ontology for Beer and even has breakdowns by country but nowhere does it let a user type for instance beer(seasonals,'by event',X) to query what another user(s) has entered.

An online example showing what is possible can be tried by going to copy and paste the following (derived from the .txt above)-

Paste in "Query Interpreter":

  beer(seasonals,'by event',X)
Paste in "Quick Online Editor":

  beer(seasonals,'by season',
     ['christmas beers',
     'easter beers',
     'winter beers (belgian)',
     'summer beers',
     'saison (belgian, french)']).
  beer(seasonals,'by month',
  beer(seasonals,'by event',
Then click the submit button the result is a bit hard to see but in the bottom frame scroll down a bit it should say

You could vary parameters and it would return results accordingly. In a ReflectiveWiki with a prolog or other interpretive top layer one set of users could enter knowledge and rules and others query it to arbitrary levels of detail. See also an online prolog RDF parser demo at With that kind of interface users could combine queries to outside the wiki from RDF/RSS feeds See By using UseModWiki and swi prolog (free with both unix and windows source) it should not be hard to do.

See also AntiComment, LukesProgrammableWiki

EditText of this page (last edited January 5, 2008) or FindPage with title or text search