Angle brackets hurt my eyes

2013-05-01, Comments

“All these angle brackets, they’re hurting my eyes.”

I’m quoting a colleague who sits next to me and I sympathise. Perhaps a section from a build file was causing him pain?

<target name="all" description="Build product.">
  <mkdir dir="build" if="${not directory::exists('build')}" />

Or maybe it was some XSL to generate XML by applying XML to XML?

<xsl:if test="$index-make or @index!='false'">
  <xsl:if test="//index">
    <fo:block text-align-last="justify" space-before="5pt">
      <fo:basic-link internal-destination="index-page">
          <xsl:when test="(/doc/@lang = 'ja') or (/doc/@lang = '')</xsl:when>
      <fo:page-number-citation ref-id="index-page"/>

Or perhaps he was wrestling with a C++ compile error.

print.cpp: In function 'void print(const
std::map<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, int, std::less<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >,
std::allocator<std::pair<const std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, int> > >&)':
print.cpp:7: error: no match for 'operator<<' in 'std::cout <<
details' /usr/include/c++/4.2.1/ostream:112: note: candidates are:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(std::basic_ostream<_CharT, _Traits>&
(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char,
_Traits = std::char_traits<char>]

What makes angle brackets so vexatious. Could it be their sharp corners?

Lisp is as elegant as XML is prickly, yet it too is famous for brackets, albeit round ones — and lots of them.

Imagine a parallel universe with angle-bracket Lisp. I wonder if the language would have proved so enduring?
Not so pretty now?
<define <euler-transform s>
  <let <<s0 <stream-ref s 0>>
        <s1 <stream-ref s 1>>    
        <s2 <stream-ref s 2>>>
    <cons-stream <- s2 </ <square <- s2 s1>>
                          <+ s0 <* -2 s1> s2>>>
                 <euler-transform <stream-cdr s>>>>>

Looking more closely at the first code snippet, the section from a build file, we can see the problem isn’t so much the angle brackets as all the others.
<mkdir dir="build" if="${not directory::exists('build')}" />

The braces and parentheses may be embedded in a double quoted string but that only makes things worse. The nested levels hurt my eyes and, if you can bear to look at the code long enough, you’ll realise there’s a simpler message trying to get out: mkdir -p build.