Programmers, ants and grains of sand

Collaborative work and the emergence of complexity


and while you're waiting

I am @jjmerelo/JMERELO@CPAN

And you can find this talk

Writing at the edge of chaos

Writing involves sand

Darwin took a sandwalk

Writing = breaking metaphors

language: perl
  - "5.16"
  - sudo apt-get update -qq
  - sudo apt-get -y install libhunspell-1.3-0 libhunspell-dev 
  - echo "use Test::Text;just_check( 'text','/usr/share/hunspell' );" > just_check.t
install: cpanm  ExtUtils::PkgConfig Test::Text TAP::Harness
script: >
    perl -MTAP::Harness -e 'use utf8;
		            my $harness = TAP::Harness->new( { verbosity => 0} );
			    die "FAIL" if  $harness->runtests( "just_check.t" )->failed;'

How am I writing?

my $dir = shift || ".";
my @logs = glob("$dir/log*.log");
my @data;
for my $l ( @logs ) {
  my ($number) = ( $l =~ /log-(\d+)/);
  my $file_content = read_file ($l );
  if ( $file_content =~ /Tests=(\d+)/ ) {
    $data[$number] = $1;
say "Commit,Words,Delta";
my $old_number_of_words = 0;
for (my $i = 0; $i <=$#data; $i ++ ) {
  if ( $data[$i] ) {
    say "$i, $data[$i], ", $data[$i]- $old_number_of_words;
    $old_number_of_words = $data[$i];

How does the pile grow?

In fits and starts

Like a real sandpile

Piles and Zipf piles

Can books self-organize?

WHERE self-organizing IS they tune themselves

Do they reach a critical state?

WHERE critical IS changes can cause any effect

They can if

they are scale-invariant

WHERE scale-invariant IS no average scale

There are long-distance correlations

WHERE long-distance IS exactly that.

... and there is pink noise

WHERE pink noise IS ...

too complicated for a single slide

✔ Scale independence

Hashlash-log-log distribution of deltas

✔ Long-distance autocorrelation

Hashlash-partial autocorrelation

☹ Pink noise

Not really

Other ways of measuring the piling of sand

Measuring grains of sand

my $repo = Git->repository (Directory => $dir);
my @filespec = split(/ /,$filespec);
my @revs = $repo->command('rev-list', '--all', '--', @filespec);
my @data = ("Lines changed");
my $prev_commit = pop @revs; #Throwaway first commit
$prev_commit = pop @revs;
for my $commit ( reverse @revs ) {
  my $file_contents = $repo->command('diff','--shortstat',  "$commit..$prev_commit", "--", @filespec );
  my ($insertions) = ($file_contents =~ /(\d+)\s+insertion\S+/s);
  my ($deletions) = ($file_contents =~ /(\d+)\s+deletion\S+/s);
  $insertions = $insertions || 0; $deletions = $deletions || 0;
  my $lines_changed = ($insertions > $deletions)?$insertions:$deletions;
  push @data, $lines_changed;
  $prev_commit = $commit;

✔ Scale independence

✔ Long distance autocorrelation

... and ...

Pink noise!

Self-organized criticality emerges in

slowly driven systems,

with many degrees of freedom and

non-linear dynamics.

How come?

We are ants

Camel ants, maybe

So what?

Writers gonna write

Insight helps us improve the process

Automatizing production/repair can't be long behind

And Perl helps us do all that!

Picture credits

And thank you, and questions?