Re: [q-lang-users] Strong examples of Q equational programming wanted
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2006-09-28 18:49:56
|
Hi John, John Cowan wrote: > In attempting to explain Q to Scheme programmers, I'm constantly running > up against this lack of compelling examples of what makes Q essentially > unique. Toy examples about a(b(x)) = c(x) and so on do not cut it. I'm afraid that you'll probably consider those toy examples, too, but there are two examples for symbolic algebraic manipulations in the distribution, i.e., stuff that you can't do like this in Haskell et al: examples/dnf.q examples/symbolic.q I know that these are basic examples, but try doing these in Scheme and you'll surely appreciate Q's equational style. ;-) If you need something more substantial, you could try to extend the symbolic differentiation example. However, substantial examples for algebraic manipulations are not easy to come up with, since that essentially amounts to writing a fairly complete computer algebra system. Nobody has done that in Q yet. (Another nice example would be tree manipulations in the code generators of compilers, which should be really easy to do in Q now that we have Lex+Yacc. But, again, nobody has done something like this yet.) And, while you dismiss the tree manipulation examples a la huffman.q and searchtree.q, those *are* compelling examples for the convenience of pattern matching. While those are easily translated to Haskell and ML, I doubt that these will interface nicely with Scheme, which is much easier to accomplish because Q, with its dynamic typing, is much more "Lispish" in style than most other modern-style FPs. Other stuff that makes Q unique: - It's a dynamically typed modern-style FPL. Schemers should be able to appreciate that. The only other FPL which comes close to that is Erlang, but Erlang doesn't have real algebraic data types and hence doing stuff a la huffman.q or searchtree.q in Erlang feels klunky. - Q's special forms, which provide a unifying framework for both "runtime macros" and lazy data structures. Try defining the (normal order) Y combinator in Scheme, without essentially implementing a lazy Scheme evaluator in Scheme. In Q it's easy, see examples/fixpt.q. - Expressions as first-class citizens. Together with those runtime special forms, this gives you almost the same amount of reflectiveness as in Lisp. (Not quite, as the equations making up a Q program are not first-class.) This makes it possible to do stuff like list comprehensions in Q rather than providing it as a builtin as all other modern FPLs (have to) do. - Q's library, especially the multimedia stuff. That may not be that convincing to Chicken programmers as they have easy access to C/C++. But it's certainly a big improvement over the stuff available for Haskell and ML. Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |