This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Blog around the Campfire and the fly likes why parens aren't like HTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Other » Blog around the Campfire
Bookmark "why parens aren Watch "why parens aren New topic

why parens aren't like HTML

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32481

I wrote about why parens in LISP aren't like HTML. And then concluded with that they are a bit.

In case I didn't manage to cover all the positions, any more?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
chris webster

Joined: Mar 01, 2009
Posts: 2205

Slava Akhmechet had a good ramble around this topic a while ago on his defmacro blog, e.g. converting Ant XML tasks into Lispy looking S-expressions, etc.

I had no real problem with the parens thing - much less typing than HTML/XML - and most editors will keep track of them, indent and even colour-code them for you. Anyway, even HTML etc will try to ditch the closing tag if there are no children e.g. <foo blah="bar"></foo> is the same as <foo blah="bar " />.

How are you enjoying the course, by the way?

No more Blub for me, thank you, Vicar.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32481

Someone in the course posted a link to c2 which has a good discussion on the matter.

I'm liking the course. It is extremely well organized. And they added overlays to the videos to clarify things from the first run.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32481

I got permission to cross post my classmate's entire post:

I think the typical comparison of Lisp symbolic expressions (s-exprs) is with XML and not with HTML.

There was a pretty big hullabaloo some years back, just when XML was becoming a buzzword technology, comparing XML to s-exprs. Famously, Erik Naggum's anti-XML rant is always fun to read. The guys over at C2 also have some fairly extensive discussions on this matter.

Interestingly, your defense of closing tags echoes Paul Prescod's defense of XML, the only Pro-XML response I've ever been able to find. Unfortunately the link appears to be broken, and I can't find any mirrors.

My own opinion on the matter is this (just scattered thoughts):
As a programmer, both as a reader and as a writer of code, I've never found parentheses to be a problem. By contrast, the verbosity caused by Lisp's lack of syntax does impact the clarity of code.
A good editor will automatically tell you which parenthesis you are closing, and even automatically indent your code. Losing context is not something I have ever had trouble with.
When working with data, it is a very powerful idea to be able to directly write an in-memory data structure into a human readable structured text document, and then to read it back in again into a format that can be directly manipulated by your language. In Lisp, the idea can be even more powerful since your input file can even be directly processed using the full might of the lisp reader/interpreter. By contrast, I've never found an XML library that didn't leave me cursing its inventors and all of their ancestors. Retrieving data by manipulating an XML DOM or XPath is incredibly clunky and ugly.

EDIT: You can read Paul's article here, courtesy the Wayback Machine.
J. Kevin Robbins

Joined: Dec 16, 2010
Posts: 1425

A warning to those at work. Don't click that "anti-XML rant" link. Our BlueCoat proxy blocked it as a pornographic site.

I'm probably going to get a nasty-gram from corporate security now.

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Matthew Brown

Joined: Apr 06, 2010
Posts: 4541

When I was doing that course, I found the parentheses relatively easy to get used to (with a decent editor, which DrRacket is). And the ability to use [] as well as () (with the interpreter making sure they match) also helped. A bigger step, I found, was getting used to prefix notation. In particular with non-commutative operators.

So, for instance, (+ (a b)) is OK. But I have a really hard time telling my brain that (- (a b)) doesn't have a -a in it.
I agree. Here's the link:
subject: why parens aren't like HTML
It's not a secret anymore!