Why should I write English in the first place?  Because it helps me to
think; and it helps me to "program" other people to think like me.
But I would never have learned English unless along the way it gave me
near-term results.  It should follow, then, that telling people to
write literate programs for the sake of posterity is never going to be
enough to change mindsets.  Taking an illiterate [sic] program and
making it literate as you are doing with Clojure will be a tour-de-
force, and an intimidating one at that.  I think that making literate
programming incrementally useful, however, is \inevitably going to
involve tooling.

Of two kinds, if you follow the logic above: social, and personal.
Firstly, there really needs to be something like a Github for literate
programming.  Why?  Because a literate program will be easier to
\understand, but also easier to \find (see example below).  Imagine a
sort of "function search engine"----code liberated from namespaces and
leiningen projects, annotated and independently useable.  If there
were a community that actually \took \advantage of findability and
understandability, it would greatly speed coding (think of how much
time you have to spend hunting for documentation), and in the process
not only \promote literate programming but make it \advantageous.

On the personal side, writing English as part of coding has to be
maximally efficient for us humans: no retyping.  The identifiers we
use in English should flow into the code, and vice-versa.  Take the
following example:

To CAPITALIZE EVERY WORD in a STRING:
        Split the STRING on SPACE into WORDS;
        CAPITALIZE the first letter of every WORD, producing CAPITALIZED
WORDS.
        Re-assemble[JOIN] the string on SPACE, to make the CAPITALIZED
STRING.

Using functions from clojure.string: split, join, capitalize; see
documentation:
http://docs.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html
http://clojure.org/other_functions
http://www.fatvat.co.uk/2009/01/regular-expressions-in-clojure.html
http://clojure.github.com/clojure/clojure.string-api.html

(defn capitalize-every-word [m-string]
  (let [m-space " "
        regex-space #"\s"
        words (split m-string regex-space)
        capitalized-words (map capitalize words)
        capitalized-string (join m-space capitalized-words)]
    capitalized-string))

(defn c-e-w [m-string]
  (join " " (map capitalize (split m-string #"\s"))))

Now there is actually not that much novel text here, and typing it out
was an enlightening exercise (to really see how enlightening, you'd
have to see the full example; but I've omitted it because the
Internets are already complaining about a long post not written in
their native Twitterese).  But it was  very cumbersome and time-
consuming to do it.  This cumbersomeness was incidental: because my
activities were split among editing, browsing, and coding, for one
thing; and also (not a complaint, Rich!) because our programming
languages do not incorporate basic English concepts like abbreviation
and definition-in-place.

(One of the big advantages of writing English along with code is that
you come up with sensible identifiers.  Without English, it's a
puzzling exercise done completely out of context.)

You can't tell me this isn't a problem for IDE's to handle.  At a
minimum, I want my IDE to link up the identifiers between code and
English.  If they do, look at what happens: the identifiers get
enriched by natural language context (notice, for instance, how JOIN
gets associated with 'assemble'), and if we push everything to our
social tool, the code ends up with more paths to be located by.

We don't yet have Google-level findability for code, of course; but I
would argue that this is not a technological defect, it is simply a
failure of description!  Once we have literate code, Google will build
a function search engine for us.


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to