Re: ADA Popularity Discussion Request

From: jayessay (nospam_at_foo.com)
Date: 08/29/04


Date: 29 Aug 2004 11:08:18 -0400

kevin.cline@gmail.com (Kevin Cline) writes:

> You can not judge the readability of a program by testing whether a
> naive programmer can understand the program line by line. Would you
> consider a book on multivariate calculus to be poorly written because
> it was not immediately understandable by the average high-school
> graduate? Concise mathematical notation makes it possible to reason
> about mathematical objects at a high level.
> So, instead of "limit(e->0) [f(x + e) - f(e)] / e", we write "f'(x)"

I tend to agree with you here. Paul Graham has some interesting
things to say about this stuff:

http://www.paulgraham.com/power.html

[Actually, he has insightful things to say about a lot of stuff...]

With Common Lisp you could (actually this has been done...) define
some macros creating a small domain specific language for
differentiation and integration. Then you could do things like:

(d/d? (3*x + (cos x)/x) x)

==> #<Function (:ANONYMOUS-LAMBDA 1971) @ #x774811ba>
    (((cos x) - (x * (- (sin x)))) / (x ^ 2)) + 3

where the function returned is the compiled (yes, to machine code)
form of the derivative.[1]

So, you could then write something like this:

(defun apply-derivative (fn &key (of 'x) to)
  (funcall (d/d? fn of) to))

(apply-derivative ((x ^ 2) + 2) :to 3)

==> 6

For functions the system doesn't know how to differentiate (or more
likely integrate), you could punt off to a typical iterative
approximater.

> Similarly, writing applications concisely at a high level of
> abstraction makes it easier for programmers experienced in the domain
> to modify the application to meet new requirements.

This is definitely true. This is why domain specific languages are so
potent, but unless you are using something like Common Lisp they tend
not to be built because the effort is much too high to make them cost
effective [2].

> The Boost::spirit parser library for C++ is an excellent example of
> the power of C++ templates...

But this is what I don't understand. Why would anyone with this point
of view hamstring themselves by using something so inexpressive as
C++???

/Jon

1. The actual input form resulting in the compiled function here would
   be

(lambda (x)
  (+ 3 (/ (- (cos x) (* x (- (sin x))))
          (expt x 2))))

2. See: Greenspun's tenth law

-- 
'jay' - a n t h o n y at romeo/november/charley com


Relevant Pages

  • Re: Python or PHP?
    ... > every language here and there more ways to do something. ... The best the programmer can do, as you imply, is to ... parse out into proper perl expressions. ... > lists, dictionaries, etc. etc. ...
    (comp.lang.python)
  • Re: Choice of language and databases
    ... Why would you want only one language? ... dynamic type system, real macros (in the Common Lisp sense, not this C ... are in the compiler, syntax and are just computations / algebraic. ... A good procedural programmer does not really need them, ...
    (comp.databases)
  • Re: Python or PHP?
    ... >> every language here and there more ways to do something. ... The best the programmer can do, as you imply, is to ... I am curious of a list of extraneous methods in Perl (more about the ... I just had a glance on Python, ...
    (comp.lang.python)
  • Re: The War On HLA
    ... Take a look at the HLA compile-time language. ... Macros can be abused just like any other language feature. ... I find it amusing, however, that HLL programmers (e.g., Delphi, ... > feature is left to the programmer to invent his own uses for. ...
    (alt.lang.asm)
  • Re: Is Lisp a Blub?
    ... known in the abstract space of programming language design that "ought" to be ... When the source code changes the programmer ... business needs of the customers who pay the bills. ... What about the Transformation Programmer? ...
    (comp.lang.lisp)