My adventures with DSSSL (and Scheme)

DSSSL was probably better than Xsl after all

Posted by 05/09/2006

DSSSL is looking better to me these days.

the math man with meaningless symbols

For those that don't know what DSSSL is, it stands for "Document Style Semantics and Specification Language". It is written in a dialect of Scheme and basically transforms and styles an Xml document just like Xsl. It was originally designed to work with SGML, and was pretty much invented by James Clark. One of my heroes.

From 1999-2003 I worked on a rather complex set of DSSSL stylesheets - to create Rtf documents from a set of Xml documents. This made Scheme my 2nd language after Visual Basic. They say the first computer language you use profoundly affects your thinking for the rest of your life. Like whether you prefer CamelCase or under_scores. I'm not sure what the 2nd language does.

I had trouble comprehending Scheme, and the documentation was difficult to read. One of my fellow co-workers actually refused to work on the files at all. He didn't care if he was fired he was NOT going to write any Dsssl code. He blamed the parenthesis but I suspected it was more than that. I suspected he was just a mediocre programmer.

the Return of LISP

Now that everyone is talking about how advanced LISP is (or at least Paul Graham), my perpsective has changed on this episode of my life. I thought it had been a big waste of time. At the time I had only been programming a few years and the truth is, it was over my head. Even though Scheme seems simple, I'm not sure it's a good starting language. Or even 2nd language. Now that I have education and years of experience programming, I can appreciate it better. Of course the co-worker that refused to do anything was just a mediocre programmer. But maybe most programmers are. I was at the time too, but at least I was trying.

If a functional language like Scheme is so advanced, and difficult for a beginner to use, what language should a programmer start with? I've been thinking a lot about how to teach programming lately. My college courses are not teaching me much of anything anymore. Interestingly enough the Scheme package I've gravitated toward is DrScheme which is an IDE for learning Scheme. But I would probably just teach by making someone live my programming history over again - without the Dsssl. So:

Rob's Computer Science cirriculum:

  1. Start with something like Visual Basic. Because the most encouraging thing in the world is actually getting something running. I can't understate the importance of immediate success with a programming language. When I first took computer science courses in 1987 I typed a bunch of Pascal on a big floppy disk, gave the disk to a proctor who ran it through a compiler, and then I waited an excruciating 10 minutes for some kind of error printout. "Uggh. Left out a semicolon..." That was a demoralizing way to learn.
  2. Write an entire system - something big. It doesn't matter what it does, but make it a monstrosity. Architect, and then overarchitect. I think it's a great learning experience to build something really horrible. Java is good for this, but then again so is PHP. This would need to be a year long class.
  3. Somewhere in here move away from an IDE and learn to use a text editor. Emacs or Vim I'm not sure which. I never can decide. I don't think it matters. The problem with Emacs is that is introduces LISP a little early in the curriculum. But the editor will be the one common thread throughout your entire education
  4. Look at assembly code for a while. Just to feel the pain and horror. Try to write something you think should be easy - like - I don't know - adding 2 numbers
  5. Look at C ( the 'friendly assembly' ) - so you can feel the relief it must have been back in the 80s
  6. Look at C++ to learn
    1. Why Java was invented
    2. What Java did wrong
    3. The pain that is known as the Makefile
    4. How difficult it can be to use other people's code
  7. Ruby/Python/Perl - whichever. Personally I can't deal with Perl. That's just me though. I see no substantial difference between these 3 languages despite all the hoopla (assuming Perl6 happens). That being said, they are all pretty cool - and Python is probably better than Visual Basic as a "starter" language.
  8. SQL/Xml/Javascript etc... the myriad of psuedo languages you will encounter. This is actually a good time to return to IDEs and look at something like Eclipse. Just because this is towards the end of curriculum, and your going to have to know about stuff that happens in the real world of mediocre programmers - and people like me (who think they aren't mediocre when they really are)
  9. Scheme/LISP - at this point I think you’re ready for LISP. You've dealt with compilers so you know that going down to the C level is necessary. You've dealt with runtime, dynamically typed languages so you know how cool that can be. You've dealt with Java and know what writing code wearing a straight-jacket feels like. You've learned how to use a good text editor - so you have a trusty companion and sidekick as you venture into the world. And you now see how you’re going to be wallowing in a tower of Babel of languages for the rest of your programming life.
  10. Graduation

Back to what I was talking about before

In 2003 I rewrote all those Dsssl stylesheets in Xsl because that was the direction everyone was going, and because the Dsssl documentation and user base was so small. It makes sense. I can't say I regret it, but I've found the Xsl is more difficult for me personally to maintain - and that it's nearly as difficult for mediocre programmers work on Xsl as it was Dsssl.

Xsl has books though. And lots and lots of information on the internet. It wins, but not by a lot. My experience with Dsssl helped me with a)the concept of recursion and b)procedures without side-effects. These are core concepts of Xsl. And also core concepts of Scheme.

Also, some things are easier to do in Xsl. Like <xsl:if test="preceding-sibling::chapter[1]/title"></xsl:if> But most of the times I prefer the Dsssl version of things. For instance

(define ($italic-seq$)
  (make sequence
    font-posture: 'italic

(element EMPHASIS
     (let ((em-style (attribute-string "style")))
       (case em-style
                (("italic")   ($italic-seq$)))))

would be this in xsl

  <xsl:attribute-set name="italic">
    <xsl:attribute name=font-posture">italic</xsl:attribute>

  <xsl:tempate match="EMPHASIS">
    <xsl:variable name="em-style" select="@style"/>
      <xsl:when test="em-style='italic'">
        <span use-attribute-sets="italic">

Except it's not obvious how to compound attributes together

Another Example:

(define (IN-PARAGRAPH?)
  (have-ancestor? "PARAGRAPH"))

(element IMAGE
 (make display-group
       space-before: (cond
                      ((IN-PARAGRAPH?) 4pt)
                     (else 0pt))))

In xsl it would be this:

  <xsl:template match="IMAGE">
    <xsl:attribute name="space-before">
        <xsl:when test="ancestor::PARAGRAPH">4pt</xsl:when>

The thing that gets me is how many times I have to type the letters x-s-l

Looking at Scheme again

So I'm looking at Scheme again. Because in retrospect I kind of liked Dsssl. There is fragmentation in the community though. I can see some advantages to the BFDL approach. I've looked at PLT, Chicken, Bigloo, MIT, Scheme48, Kawa, SISC. It is a little disheartening. I'm going with PLT because it seems to have the biggest library and because it has a focus on helping people learn the language. But it isn't easy. I'm looking at a library to connect to postgresql. Part of the documentation is this:

method map: string (field ... -> 'a) -> (list-of 'a)
(send connection map proc)

Now, what does that mean? There is a good Tutorial though.


Stuarzurith commented, on August 30, 2017 at 3:08 a.m.:

viagra for daily use prices website - viagra without a doctor prescription usa
viagra forum rules
<a href="">viagra without a doctor prescription
</a> - drugs refund scheme viagra
viagra online buy adobe clinic generic illustrator time trademarks forum

Total: 0.31 Python: 0.06 DB: 0.25 Queries: 19