Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- From: "Richard J. Fateman" <fateman@xxxxxxxxxxxxxxxxx>
- Date: Tue, 23 Aug 2005 13:18:16 -0700
Jon Harrop wrote:
On Tuesday 23 August 2005 18:01, you wrote:
Jon Harrop wrote:
That is a poor representation of sparse arrays.
When did you become an expert on (a) lisp (b) hash tables and (c) sparse arrays?
You don't have to take my word for it, just read Numerical Recipies, or any decent book on matrix computations.
When did Numerical Recipes become an authority on (a), (b), or (c) or for that matter, matrix computations?
Just one?
Perhaps you could explain which of the many other compression techniques in the literature for sparse arrays you think is superior and how they should be represented in lisp?
NR has a good one.
consider SPARSKIT...
"SPARSKIT 4 2.1 Storage Formats:
Currently, the conversion routines of SPARSKIT can handle thirteen different storage formats. These include some of the most commonly used schemes but they are by no means exhaustive."
The conventional symbol for And is an upside-down V.
Which you can use in Mathematica but not in Lisp.
I believe the symbol we are discussing is in unicode, which is supported in at least several lisp systems. Symbol number 22C0. I believe Mathematica supports unicode no.w
You tested a program to determine if a number is zero, and found SML and OCaml to be faster? I doubt it.
"(=) 0" in OCaml, "fn x => x=0" in SML. All shorter than the Lisp, OCaml and SML will also be faster...
Faster? Again with the faster?
Faster.
There are probably 6 or more prominent lisp systems, and you've tried them all?
The shootout already did. Lisp does very poorly in terms of performance.
1. (Liar^2 pants on fire). 2. Have you tried compiling a call to zerop in lisp? I doubt that you know how. In one lisp I tried, it compiles to a closed subroutine of 16 bytes on an intel pentium. Open coded it might be 4 bytes.
You've been arguing on many newsgroups, demonstrating misunderstandings of programming languages, especially lisp.
And besides which, I was explaining Mathematica's clumsy syntax, not saying how to write the
program
in lisp. If I were writing the program in lisp, I would use "zerop" which is the same length as the phrase "(=) 0" in OCaml, and shorter than SML or Mathematica.
Actually that should be "(=)0" in OCaml, which is 20% shorter than your
feeble Lisp "code".
And so readable!
Far more people would have to study the Lisp to parse it.
Face it, Jon, parsing Lisp is trivial.
(defmacro def ((name params &body body) (mname &rest mparams) (wname &rest wparams)) `(progn (declaim (inline ,name ,wname)) (defun ,name ,params ,@body) (defmacro ,mname ,(mapcar #'car mparams) ,(loop with inner = (list name) with body = ``,',inner with all-names = nil for (form count) in (reverse mparams) for names = (loop repeat count collect (gensym)) do (setf all-names (append all-names names)) (setf body ``(multiple-value-bind ,',(reverse names) ,,form ,,body)) finally (setf (cdr inner) (reverse all-names)) (return body))) (defun ,wname ,(mapcar #'car wparams) (,mname ,@(mapcar #'cadr wparams)))))
The use of "'", "`", ",", "#" and "@" is reasonable in Lisp but unreasonable in other languages? For example, what does the ``,', do in that code?
You seem to miss the point. The programs I displayed required no use of the backquote and comma, no use of loop, no use of optional parameters. They are easy to read. And if you want to know what a part of a lisp expression evaluates to, you can try it out. e.g. (setf name 'foo) (setf inner (list name)) then ``,',inner evaluates to '(foo).
Are we running an obscure program contest? Even the program you
display above, which is very non-lispish because of the use of "loop"
can be read mostly by noticing that function calls look like (function_name arg1 arg2 ...)
You seem to think that the only programs that count are programs that define macros. You even think that Mathematica uses macros when it doesn't, perhaps because you don't understand macros (or Mathematica?)
Parsing Mathematica is a chore for most humans. Maybe you don't know what "parsing" means.
You'll have to ask my Mathematica parser.
Parsing Mathematica by computer costs $134. for a student, and much more for non-students.
Mathematica was only $50 last I looked. Or you could write your own... ;-)
Our student store charges $134. I wrote my own and Wolfram threatened to sue.
Parsing Lisp by computer costs more like $0 for any of a number of free and open-source lisp implementations. (There are commercial versions too; they give only trial versions free)
Parsing many other languages is also free.
Fast matrix routines do not use lists (or Lisp).
How would you know?
Well, I've been a computational physicist for some years and I've never met another one who uses Lisp. For anything.
I've met quite a few physicists who think they know a lot about computer programming, but don't. Someone with initials SW for example. I've worked at the DOE Berkeley and Livermore Labs at various times.
There are many operations, e.g. interchanging two rows, that are vastly faster
on a list representation.
No. That is O(n) with lists and O(1) with an array of arrays.
Oh, so now you are now not using an array of numbers but an array of pointers to arrays. How clever. Did you pick that one out of the 13 in SPARSKIT, or make it up yourself? Why not go full-out and point out that you can encode linked lists in arrays, and therefore there can be no advantage to linked lists (or lisp) that cannot be duplicated in Fortran.
If you have an operation that takes time say n^3 , the original format of the data may be rather unimportant, since it can be copied to some other format in time O(n^2 ). But that is just being argumentative. Without anything concrete here, "fast" is pretty meaningless.
Yes. You must really regret using that phrase now.
Actually, I regret spending the time trying to educate you. RJF
.
- Follow-Ups:
- References:
- Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- From: Jon McLoone
- Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- From: Nasser Abbasi
- Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- From: Richard J. Fateman
- Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- From: Jon Harrop
- Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- From: Richard J. Fateman
- Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- From: Jon Harrop
- Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- From: Richard Fateman
- Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- From: Jon Harrop
- Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- Prev by Date: Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- Next by Date: Re: volume under the surface
- Previous by thread: Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- Next by thread: Re: functional style compared to procedural style and comments on a Mathematica function I saw.
- Index(es):
Relevant Pages
|