archives

The Architecture of Open Source Applications

This looks like a very interesting book, and it's free to view online: The Architecture of Open Source Applications.

Architects look at thousands of buildings during their training, and study critiques of those buildings written by masters. In contrast, most software developers only ever get to know a handful of large programs well—usually programs they wrote themselves—and never study the great programs of history. As a result, they repeat one another's mistakes rather than building on one another's successes.

This book's goal is to change that. In it, the authors of twenty-five open source applications explain how their software is structured, and why. What are each program's major components? How do they interact? And what did their builders learn during their development? In answering these questions, the contributors to this book provide unique insights into how they think.

Yet another programming language with customizable syntax

I'm designing a new general-purpose programming language with entirely customizable syntax. Its "killer-feature" is naturalness in functions/macros syntax definition: other languages with customizable syntax (Nemerle, LISP, XL) requires either knowledge of compilers construction theory or reading a large amount of manuals or both (and resultant syntax definition constructs look rather cryptic), while in my language all this is done rather intuitive. Just look at examples.

Example 1:

`{min} < {var} < {max}`
  returns Boolean
  :
  min < var and var < max

`{HH}:{MM}:{SS}`
  where HH is Natural and 0 < HH < 23;  -- Here parser fails when using `{x} < {y}`
        MM is Natural and 0 < MM < 59;  -- so it uses `{min} < {var} < {max}`.
        SS is Natural and 0 < SS < 59;
  returns Natural
  :
  HH * 3600 + MM * 60 + SS

`time between {time1} and {time2}`:  -- No "returns" clause, automatic type inference is used.
  time2 - time1

`how much {x}`:
  x

`main`:
  print how much time between 23:48:12 and 08:17:00  -- Absolutely natural-language-like expression.

Example 2:

class Point.  -- Predefined function with syntax `class {regexp(\w+)}` is used.

`{p}_x`
  where p is Point;
  returns Number
  :
  field  -- That's how fields and variables are declared.

`{p}_y`
  where p is Point;
  returns Number
  :
  field

`({x}, {y})`:
  p := new Point;  -- Function `new Point` is declared automatically for every class.
      -- Function `{regexp(\w+)} := {value}` is predefined.
      -- Type inference is used heavily everywhere.
      -- Oh, and function `{f1}; {f2}` (sequential execution) is predefined too.
  p_x := x;  -- Function `{p}_{x} := {value}` is declared automatically for every "field" function.
  p_y := y;
  return p

`||{p}||`: sqrt(p_x^2 + p_y^2)

`{p1} - {p2}`
  left-associative;
  priority is the same as for `{x} + {y}`  -- Yes, priorities are relative.
  :
  (p1_x - p2_x, p1_y - p2_y)

`D({p1}, {p2})`: ||p1 - p2||

`main`
  p1 := (0, 0); p2 := (3, 0); p3 := (0, 4);
  print D(p1, p2) + D(p2, p3) + D(p3, p1);  -- We'll get 12!

It is possible to create similar language with XML tags instead of "`"-s and ":"-s. For example:

<func>
  <syntax>time between <arg>time1</arg> and <arg>time2</arg>
  <body>time2 - time1</body>  -- Look at the body, its sytnax is still entirely customizable!
</func>

so in fact I'm designing a meta-language.

Should I proceed or is this entirely stupid idea?