Actually, the main connection between lisp and latex
is literate programming. You write a primary source
document that contains your explanation and your code.
You run "tangle" on the primary document to get source.
You run "weave" on the primary document to get latex.
In Axiom (the open source effort I lead), we have
defined new latex macros so the "weave" step is not
needed since the whole document is latex. We have
integrated the "tangle" step into lisp so lisp knows
how to read literate documents and extract the lisp code.
Thus, you just write a document, latex it to a PDF that
people can read, and read it directly into lisp to execute.
Note that there is an escape in TeX that will allow you
to execute lisp code. Indeed, you can create a PDF from
your document and still execute your lisp code. I have
not tried this with Clojure (yet) but there is nothing
lisp-specific in the interface so it should work.
It would be very nice if the clojure code, such as the code that implements
immutable data structures, were actually written in a literate form. Then
we could just download the "chapter" that explains how it works and what
were the design choices ("the why"). The "chapter" would contain the
actual source code (not copies, but the actual code used during standard
builds) so we could be sure that we had working code.
The key advantage of the literate approach to Clojure would be that we
could all just read the chapters. There would likely be a chapter on agents,
one on each immutable data structure, one on the reader, etc. Life would
be so much easier if Clojure were literate. Rich Hickey would only have
to explain "the why" once and we wouldn't have to grep the source code
to find out where things are (just check the index and cross references in
the book). Naked source code in tiny little files is a throwback to an era
when machines only had 4K of main memory. Stop, please just stop, doing
that.
Clojure is modern in so many ways but it still is written like we were on
a PDP 11/40.
Why can't we just download "Clojure, the Book" and execute it?
Is anyone interested in a literate version of Clojure? Could we work
with Rich, troll the newsgroups, reformat the code, so that it was just
a large book that anyone could read or execute?
If you don't think this is possible, check out "Lisp In Small Pieces"
which is a full book containing a full lisp (interpreter, compiler, etc).
I haven't tried this with Clojure yet as I'm still trying to find my way
around the language. When I build an application with Clojure it will
be literate so I'll end up writing the tangle function in Clojure and I'll
post it.
Tim Daly
Mike Meyer wrote:
On Sun, 23 May 2010 06:55:50 -0700 (PDT)
faenvie <faen...@googlemail.com> wrote:
today i read this statement in a blog-post:
"... remarkably (La)TeX is much better suited for composing and
distributing most types of documents than any other modern
word processor on the market that I am aware of. Just like
programming languages tend to converge towards Lisp because
it got things right the first time around, so do the Word
Processors tend to converge towards (La)TeX."
Another analog to LISP: most people don't know what they're really
dealing with. Even the blog you quoted from got that wrong. (La)TeX is
a document processor, not a mere word processor. Which is why it's so
good at composing and distributing documents. Of course - again like
LISP - this has led to it generally being ignored outside the circles
that adopted it early on, and made life hard for it's commercial
competitors (Scribe and FrameMaker being the two that come to mind
readily). One difference is that TeX didn't get it right first; that
would be Scribe. But Scribe was sold and support for the free version
vanished, leading to it pretty much withering away.
To redraw the parallels: Clojure is cool for a number of reasons, but
those that it inherited from LISP aren't unique to it - any LISP
should have them. (La)TeX is also cool for a number of reasons, but
those that it shares with other document processing languages aren't
unique to it, either - any good document processing language should
have them.
In particular, SGML has many of those features. It also has a lot of
cruft for dealing with legacy document types, which make doing a
full-featured SGML implementation difficult. Once you've got it, you
can do outright magic, but there just aren't that many people who can
write the thing in the first place. XML is an "SGML application" with
many of the options set so that pretty much any competent programmer
can build an XML implementation (it's sometimes called "SGML for
dummies"). HTML was sorta-kinda SGML; the SGML standard was amended
(via the "web annex") so that HTML would qualify, those increasing the
number of SGML documents in the world by many orders of magnitude.
what about combining (la=)tex and clojure for implememting
extraordinary document-processing ?
These days, most people generate some form of SGML (usually XML or
(X)HTML) instead of (La)TeX, for a number of reasons. One is that the
language is easier to deal with in code than TeX, both as input and as
output. This means that while there are lots of tools to manipulate
and format SGML, there aren't so many to deal with TeX. Second,
(La)TeX is really biased toward printed output. So what normally
happens is that your tools generate the SGML, then transform that to
the format appropriate for the target audience: (x)HTML or pdf for the
web or Unix, microsoft .hlp files for Windows, and (La)TeX for
printing or to generate a pdf of a printed document, because (La)TeX
produces gorgeous printed output.
XML, of course, is just S-expression with a *really* ugly syntax. So
using LISP languages for generating it is easy and natural.
either by run (A) Clojure scripts from (La)TeX documents
and use Clojures output to generate document's content. This
can be used to read/convert data, generate tables and figures,
do on-the-fly calculations.
I don't think anyone has done anything like this. Then again, most
people don't use (La)TeX as an authoring language.
or by (B) implementing a clojure-based DSL that can produce
(La)Tex documents.
Given a clojure-based DSL that produces SGML, there are a number of
SGML applications that can be used to generate (La)TeX
documents. Further, they can also produce things that more people are
interested in, interactive web documents.
The (La)TeX bias towards print bites you if you want interactive
documents, as print is a miserable medium for them. People wanting to
do them tend to use (x)HTML, because - well, it's design has been
driven by two groups of people: One set wanted a good language for
doing document processing, and they wrote the standards. Another set
wanted a good language for doing network presentation, and they wrote
the most popular code. The net result is a language in which it's
possible to do good document processing if you want to (though 95% of
the people producing web pages don't know that such a thing exists,
much less have any ability to produce it), but it *also* has hooks to
let you build complete applications in the document, should you want
to.
There are a number of efforts under way to provide clojure-based tools
of either type A or B as you described - at least for some SGML
applications. Most of them are aimed at the application-building side
of things (mine included). Actually, I haven't looked for any aimed at
more general document preparation, but going from an (X)HTML DSL to an
SGML one that used docbook shouldn't be that hard. You can read about
my DSL for XHTML - though it's set up to make it easy to create a DSL
for an arbitrary XML schema - at
http://mired.wordpress.com/tag/web/. Unfortunately, it's a blog, so
the justification for what's near the top is found at the bottom....
<mike
--
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