A UNIX command line utility for producing gibberish

One day I realized that text has an interesting visual texture. I wanted to draw with it. My first idea was to draw the floor plan for a dungeon, as if from a roguelike. It fits with the ASCII art theme:

> gibberish dungeon.txt
despise fender ma a kimono quote chummy coerce hulk oxidizing compare
strangely guy bring galley up a opt manual groove a pa we clang salsa
anthem avert mama clip cleft rebirth jam payphone rocklike glade rice
zen science go gag mug surgical                   stagnant settle oat
serpent              reassure a                   decorated aftermost
pointed              spongy oak                   mop nebula approval
fiction              a bullwhip                   parted bok breeding
gristle              uneven eel                   starry my establish
nuptials a    barrel shed panda                   rinsing flatworm ad
maker ruby    sandbag had wannabe   tiny dagger rotunda sly statistic
badness ma    flint earplugs punk   clump capsize bloating earwig mop
clunky                we disallow   go pi shape elope quickly grouped
shriek                              gag cattail do penknife semifinal
partly                iciness       a duh open a laborious tux header
unease                replica       haven sevenfold golf sandbank cut
alive mug tusk a maroon await       angrily backtrack amicably greedy
radiated a job shone dating jaws  duh astrology almost          rogue
barstool me arson art a jokingly  zoom foil dad granny          going
drown slum stark dismount collie  outplayed lung fever          union
roast gap subside woof haunt                                    silly
pi next captivity snub sedan         tastiness onstage          spray
washer security evasive glue         a pa skedaddle a relock irrigate
dingy predict my ion glandular cultivate mug rebound relation capable
stem handoff go parrot rocking attempt bodacious spew pa outtakes pry

The program I wrote to do this took the form of a terminal command written in Go. It replaces sequences of letters in its input with a word or sequence of words from a wordlist while passing other characters through unchanged. I tried several wordlists during development. /usr/share/dict/words had such long words that large blocks of text in the output would have no spaces, which didn't give the natural text texture that I was trying for. The Basic English wordlist produced similar results. The EFF's long Diceware wordlist, which was built with an eye to avoiding very long words, produced a natural text texture with lots of spaces in large blocks of text, so I decided to make it the default. (I had to add a few one and two letter words to the EFF's original list so that the program could generate runs of words in any length that it needed.)

Where can I get it?

You can download gibberish.go from this website or get it from its GitHub repository. The code is under CC0; the default wordlist is derived from the EFF's long Diceware list, used under CC-BY 3.0.

What can I do with it?

Like any good UNIX utility, gibberish works well in pipelines. You can use it to filter any source of text. The output of other commands remains recognizable.

> ping jacobwinters.com | gibberish
spry dawn equator.pep (208.94.118.221): 56 veto otter
64 flask exit 208.94.118.221: exit_bok=0 jam=56 pogo=55.585 it
64 wharf shed 208.94.118.221: acre_yin=1 pug=56 open=59.620 we
64 worst trio 208.94.118.221: race_tug=2 foe=56 both=55.567 me
64 strep last 208.94.118.221: keep_shy=3 icy=56 rink=54.976 we

> ls -l | gibberish
pecan 184
-us-a--a--  1 refund poach  email   3155 gap 19 15:00 scam-perm.sly
-ma-a--a--  1 we graveness  yield   9528 pox 19 15:01 ruby-tux.zen
-pa-a--a--  1 a scalded up  trace  22558 cod 19 15:01 gully.yen
-up-a--a--  1 gulf overrun  drift  15292 zen 19 15:01 sublime.rug
-me-a--a--  1 overpower my  exact   6350 oil 19 15:00 jujitsu.keg
-me-a--a--  1 do chaperone  runny   8828 ice 19 15:00 oppressed a.jot
-pi-a--a--  1 ma certainly  chaps  15566 oak 19 15:00 rethink.gag

> echo Hello | figlet -f letters | gibberish
pi   he        bok jab        
up   up   dig  icy lid  yard  
subject my   a jab net he  pa 
ma   ad paper  duo oak he  be 
ox   go  reset emu pep  salt  

Say, I know where I can get some text...

> gibberish gibberish.go
...
	be slouchy.dry() != fog {
		mocker epidemic{}, varnish.cod()
	}

	limb := tidy([]mop, 0, job(pried))
	icy impart := nappy pushy {
		gear = regain(sulk, breezy)
	}
	raft.ipod(list)
...

Code ipsum: Comparing the visual textures of programming languages

After seeing how much of the texture of Go code the program's source retained after I fed it through itself, I realized that I had accidentally found a good way to compare the visual textures of different programming languages.

C:

rug pep(owl sly[], shy wanted) {
	irk playset = 0;
	yam (pep a = 0; a < lyrics; a++) {
		seventh += gas[a];
	}
	tissue thermal;
}

Python:

tug commodity(a):
	up a < 2:
		bauble a
	renter confidant(a - 1) + squishier(a - 2)

Lisp:

(astute (trustable-tidbit a)
  (me (< a 2)
      a
      (+ (outspoken-headed (- a 1))
         (fraternal-buffer (- a 2)))))

APL:

{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}

Smalltalk:

five
	grunt grip.
	lisp wistful catchy: [:rush |
		echo limb unashamed do jogging: posh quickstep
	]

Haskell:

saucy :: retry (annex a) -> sniff a
cargo (slum (take a)) = lair a
yo-yo _ = stiffen

(The astute reader will notice that the APL program has not been changed because it contains no letters.)

Trying new wordlists

With the right wordlist we could theme gibberish's output. I grabbed some texts and ran them through grep -o '[[:alpha:]]\+' | tr '[:upper:]' '[:lower:]' | sort -u to make wordlists, hoping that the output would retain some of the feeling of the source text. I think that it did.

Alice in Wonderland:

number beautify toffee entirely flinging presently
refreshments unfortunate fig frontispiece executes
tails decidedly executioner tie               girl
stigand              uncommonly               tray
thunder              respectful               sent
meeting              difficulty               nile
zealand              everything               walk
unpleasant    chuckled evidence               neck
executions    affectionately ahem   multiplication
pretending    xi replied prettier   multiplication
effect                respectable   contemptuously
sleepy                              affectionately
fairly                nibbled       disappointment
insult                thimble       affectionately
unwillingly nevertheless wags       disappointment
fun unwillingly impertinent inquisitively pleasure

The United States Constitution:

limitations j disqualification representatives few
in counterfeiting rutledge arts elections captures
flee               excluding fourth qualifications
army               exceptions              liberty
said                                       defence
meet               prescribed              regular
time               punishment              georgia
work               geo controversies    subsequent
appropriations   dickinson territory    department
representation   return pennsylvania    contracted
representative   regulations                crimes
counterfeiting       several                powers
qualifications       follows                presid
counterfeiting       defence                either
naturalization       notwithstanding qualification
reconsideration and for disqualification migration

RFC 2324:

organizations g february derivative authentication
laboratories acknowledgements       capitalization
agents                command       considerations
repeat                putting       capitalization
gordon                              authentication
allows                acknowledgements controlling
associated    acknowledgements see characteristics
designator    duerst internationalization sandwich
designator    cmu international               task
fitness              designator               each
capable              conditions               http
without                                       lays
chinese              transcends               snmp
preparation ubiquitously stored               what
networking art internationalization administrators
objects acknowledgements a q acknowledgements more

Published 2020-06-20

Previous: Fireworks animation