[seqfan] Re: Rant on Maple code
Joerg Arndt
arndt at jjj.de
Fri Aug 14 05:12:45 CEST 2009
* Robert G. Wilson, v <rgwv at rgwv.com> [Aug 14. 2009 08:47]:
> SeqFans,
>
> The hierarchy of programming.
>
> 1. It must be accurate.
> 2. It should be efficient (both in computer resources and time)
> 3. Readable. Please no spaghetti coding.
>
> For me when all of the above occurs the coding is 'elegant'.
>
> I also try hard to label functions which are useful in several other sequences
> with unique descriptive titles. As an example, before Mathematica had as a built
> in function, nextPrim[n_]. In this way someone who was following me could cut and
> paste this function into their coding and thereby the OEIS would be internally
> consistent.
>
> With consistency for the OEIS in mind, the generating function if not named
> should be the f(n) with helping functions of g(), h(), etc. If the sequence is
> recursive, then a(n) and not f(n) is useful.
>
> Bob.
>
>
> [...snip to save precious electrons...]
I agree with your statements.
Enforcing routine names would be nice
but appears impossible to me.
There should also be a reason for the code.
-- computation (efficient, code as clear as possible)
-- verification of a statement
(e.g. cranking out the Catalan seq via combinatorial counting)
-- showing how to do it in a certain language
(e.g. ellj() and znstar() in pari/gp)
-- code as a formula?
Good, because errors in code can often be found trivially by running it.
Bad, because what should be a formula is often stated
(enCODEd) in the cryptic syntax of a particular language.
-- Using unexplained functionality of a package?
Good if that package is one you should know about
if you are interested in this seq (e.g. some combinatorial stuff).
Good if otherwise practically impossible (e.g. znstar()).
[Bleep]ing bad if a stupid obfuscation, e.g. all with(finance) code.
A few more remarks:
There is no point for giving code for 10*n et.al.
Omitting the * with multiplication is bad.
Code for a free/open source system is much more valuable
than code for commercial systems as e.g. M & M, check the prices!
Prefer a simple approach, not everyone understands
Nest[Fold[Hold[Flatten[N__ \;] @@ Doppel!Moppel[@% \; _Eval[#@]]]]]
This style is called "write only" for a reason.
More information about the SeqFan
mailing list