Shlomi Fish  committed 6f41cac

Add more.

  • Participants
  • Parent commits 5eb0f0f

Comments (0)

Files changed (1)

File essays/Sherlock-Holmes-about-Awk/Stoic-road-to-peace-of-mind.xhtml

 <html xmlns="" xml:lang="en-US">
-<title>The Stoic Road to Peace of Mind</title>
+<title>Sherlock Holmes about the Awk Programming Language</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <meta name="author" content="Shlomi Fish" />
 <meta name="description" content="Shlomi Fish's Homepage" />
-    <!-- Tags: stoicism, psychology -->
-<h1>The Stoic Road to Peace of Mind</h1>
+<!-- Tags: sherlock, holmes, psychology, software, memory
+<h1>Sherlock Holmes about the Awk Programming Language</h1>
-If you are like most people, you probably feel angry, frustrated, or
-disappointed, often. That’s also has naturally been the case for me, but I
-was told a trick that made it much easier for me to handle these situations,
-and it dates back to antiquity. 
+I enjoyed reading some of Sir Arthur Conan Doyle’s writings about
+the fictional detective <a
+href="">Sherlock Holmes</a> when
+I was younger, which were entertaining (although possibly distanced from
+the way actual crime investigation actually works), and interesting. I
+vividly recall One excerpt from Holmes’ first story
+<a href="">A
+Study in Scarlet</a> which I recall is this:
+His ignorance was as remarkable as his knowledge. Of contemporary literature,
+philosophy and politics he appeared to know next to nothing. Upon my quoting
+Thomas Carlyle, he enquired in the naivest way who he might be and what he had
+done. My surprise reached a climax, however, when I found incidentally that he
+was ignorant of the Copernican Theory and of the composition of the Solar
+System. That any civilized human being in this nineteenth century should not be
+aware that the earth travelled round the sun appeared to be to me such an
+extraordinary fact that I could hardly realize it.
-<a href="">Stoicism</a> was an ancient 
-Greek school of thought (that still exercises some influence today), which
-among other teachings, advocated self-control and avoiding making your 
-emotions and irrational desires influence your behaviour for the worst. What
-they claimed
-was that painful feelings were not a direct result of an experience that
-induced pain, but rather the human mind's irrational interpretation of it.
+"You appear to be astonished," he said, smiling at my expression of surprise. "Now that I do know it I shall do my best to forget it."
-If we move from this theory to its implications, then once something
-frustrating happens to you, you can say to yourself “I don’t like this.
-This situation is not ideal. However, feeling angry and resentful will
-not be beneficial, and so I should just accept this as is, try to reasonably
-cope with it, and make the best of it. I might even grow to like it.” 
+"To forget it!"
-My psychotherapist told me that “Things must always go my way.” has been
-identified as an irrational cognitive belief by many people. 
-(It is mentioned in 
-<a href=";pg=PA39&amp;lpg=PA39&amp;dq=%22things+must+always+go+my+way%22&amp;source=bl&amp;ots=PWZxNEP65c&amp;sig=13za5dB5KXvOKIUTp_iNSPZSksM&amp;hl=en&amp;sa=X&amp;ei=T_R1T_-4HsSRswbi183EAw&amp;redir_esc=y#v=onepage&amp;q=%22things%20must%20always%20go%20my%20way%22&amp;f=false">this page in the Google Books’ hosted book</a>).
-The solution to this is simply to say to myself that “I cannot always get
-what I want.” and that “Things might not go exactly like I want them to and
-that’s OK because I’ll survive.”.
+"You see," he explained, "I consider that a man's brain originally is like a
+little empty attic, and you have to stock it with such furniture as you choose.
+A fool takes in all the lumber of every sort that he comes across, so that the
+knowledge which might be useful to him gets crowded out, or at best is jumbled
+up with a lot of other things, so that he has a difficulty in laying his hands
+upon it. Now the skilful workman is very careful indeed as to what he takes
+into his brain attic. He will have nothing but the tools which may help him in
+doing his work, but of these he has a large assortment, and all in the most
+perfect order. It is a mistake to think that that little room has elastic walls
+and can distend to any extent. Depend upon it there comes a time when for every
+addition of knowledge you forget something that you knew before. It is of the
+highest importance, therefore, not to have useless facts elbowing out the
+useful ones."
-Back to Stoicism, we can draw inspiration from the Roman Emperor and 
-Stoic philosopher
-<a href="">Marcus Aurelius</a>’s
-quote from his book <i>Meditations</i>:
+"But the Solar System!" I protested.
+"What the deuce is it to me?" he interrupted impatiently; "you say that we go
+round the sun. If we went round the moon it would not make a pennyworth of
+difference to me or to my work."
+(<a href="">Chapter 2 of A Study in Scarlet</a> by Sir Arthur Doyle, under the public domain
+in most countries.)
+Sir Doyle was naturally exaggerating here in portraying the ideal
+of Sherlock Holmes (as few, if any, human beings can forget that the Earth
+revolves around the Sun), but the principle still stands: we need to make
+a conscious decision of how to manage our memory, because there is a limit
+to how many different aspects can put inside our resident memory because
+otherwise we'll forget more important stuff.
+So what does it has to do with the Awk programming language? Many decades
+after A Study in Scarlet, <a href="">Eric
+S. Raymond</a> had this to say in his book
+<a href=""><i>The Art of Unix
-    <p>
-    Say to yourself in the early morning: I shall meet today ungrateful,
-    violent, treacherous, envious, uncharitable men. All of these things have
-    come upon them through ignorance of real good and ill… I can neither be
-    harmed by any of them, for no man will involve me in wrong, nor can I be
-    angry with my kinsman or hate him; for we have come into the world to work
-    together…
-    </p>
-I am not an authority to speak a lot further about Stoicism, because I’ve only
-heard about it from hearsay and read the wikipedia entry and some other online
-sources, but I think we can all become a little, or even a lot happier, by 
-adopting the mindset that the key to peace of mind is accepting sub-optimal
-situations, instead of insisting that we will always have our way. 
-Thanks to <tt>steerpike</tt>, <tt>mofino</tt> and <tt>perlmonkey</tt> from
-<a href="">Freenode</a> for going over early drafts of
-this essay and providing some comments.
-This work is licensed under the
-<a rel="license" href="">Creative
-    Commons Attribution 3.0 License (Unported)</a> (CC-by) or at your option
-any later version. Copyright © 2012, Shlomi Fish. CC-by is a common,
-permissive, free/libre/open licence for cultural works, which allows for
-almost unlimited use. See
-<a href="">my interpretation and
-    expectations</a> from people who wish to build upon it (which I believe
-are pretty fair).
-I realise I’ve neglected this blog for a long time, and I’ve been meaning
-to write and publish this entry for a long time, but didn’t, but I guess
-“better late than never”, right? Personally, I’ve been mostly fine recently
-having found a part-time job, which involves a short bus ride to the office
-in the downtown city, so it’s at a great location for me. I also enjoyed
-attending the latest Israeli Perl Workshop for 2012
-<a href="">written a report about it</a>.
+A case study of awk is included to point out that it is not a model for
+emulation; in fact, since 1990 it has largely fallen out of use. It has been
+superseded by new-school scripting languages—notably Perl, which was explicitly
+designed to be an awk killer. The reasons are worthy of examination, because
+they constitute a bit of a cautionary tale for minilanguage designers.
-In the meanwhile,’s handling of this blog’s 
-<a href="">DNS</a> 
-domains has deteriorated, and now just redirects it to This probably made me even less motivated to post
-on this blog, and my reports about it appears to have been marked as 
-duplicate without a proper resolution, but I'll try to get it handled and
-fixed. If not, I might have to investigate other hosted blog solutions.
+The awk language was originally designed to be a small, expressive
+special-purpose language for report generation. Unfortunately, it turns out to
+have been designed at a bad spot on the complexity-vs.-power curve. The action
+language is noncompact, but the pattern-driven framework it sits inside keeps
+it from being generally applicable — that's the worst of both worlds. And the
+new-school scripting languages can do anything awk can; their equivalent
+programs are usually just as readable, if not more so.
-There’s a lot more going on with my life, but I’m not sure how much it will
-interest other people and how much I should share it, but I’m fine and happy
-and have plenty of free time for work and leisure and whatever is in between. 
-So good bye until next time.
+For a few years after the release of Perl in 1987, awk remained competitive
+simply because it had a smaller, faster implementation. But as the cost of
+compute cycles and memory dropped, the economic reasons for favoring a
+special-purpose language that was relatively thrifty with both lost their
+force. Programmers increasingly chose to do awklike things with Perl or (later)
+Python, rather than <strong>keep two different scripting languages in their
+By the year 2000 awk had become little more than a memory for most old-school
+Unix hackers, and not a particularly nostalgic one.
+Falling costs have changed the tradeoffs in minilanguage design. Restricting
+your design's capabilities to buy compactness may still be a good idea, but
+doing so to economize on machine resources is a bad one. Machine resources get
+cheaper over time, but <strong>space in programmers' heads only gets more
+Modern minilanguages can either be general but noncompact, or specialized but
+very compact; specialized but noncompact simply won't compete.
+(Emphasis mine.)
+(<a href="">Case Study: awk in minilanguages</a> in <i>The Art of Unix Programming</i> by Eric
+Steven Raymond, text available under the
+Creative Commons Attribution-NonDerivatives licence, and hopefully quoted
+here (with attribution) under
+<a href="">fair use</a> auspices.)
+Back in 1996, after I first learnt Perl and started working on Unix, I asked
+one of my co-workers if I should learn Awk and he said “Forget it! Perl can
+do everything Awk does and more, and is a much better language.” (that was some
+time before other of the so-called “scripting languages” that gained popularity
+after Perl, were notable enough to be considered by most sane people). While
+I was not entirely convinced, and also ended up using GNU awk (gawk) to write
+a small text processing script for Windows at one point (because I preferred
+not to investigate how to make the perl executable more self-contained - it
+is doable however), for a while I felt guilty about not being fluent in Awk,
+until I read what Raymond said, when I realised why he (and his co-worker and
+Holmes were right all along).