[sage-devel] presentation about Maxima at Sage developer days



> I truly doubt that.   500 lines of python and 2700 lines of lisp?
>
> I think that someone familiar with both languages would take it pretty much
> for granted that 500 lines of python can be transcribed into about 500 lines
> of lisp or so, and would be about as easy to read.
>
> I note that lines 117 to 156 in the python code are for making and printing
> trees.  Compare these to the corresponding programs in Lisp.   (read x)
> (pprint x).  Much easier to read in Lisp, I think.

Well, but someone had to write the pprint function, no?

>
>
> See line 159
> def compare(a,b,x):
>
>   159     """Returns "<" if a<b, "=" for a==b, ">" for a>b"""
>   160     c = limitinf(log(a)/log(b), x)
>   161     if c == 0:
>   162         return "<"
>   163     elif c in [oo,-oo]:
>   164         return ">"
>   165     else:
>   166         return "="
>
> in lisp, it would be something like this.
>
> (defun compare(a b x)
>   (let ((c (limitinf (/ (log a) (log b)) x)))
>     (if (= c 0) '<
>         (if (member c, '(inf minf)) '> '=))))

Well, you can make the Python code above shorter too:

def compare(a, b, x):
    c = limitinf(log(a)/log(b), x)
    if c == 0: return "<"
    elif c in [oo, -oo]: return ">"
    else: return "="

>
>
> in python we have this..
>
>    if e.is_Rational or e.is_Real:
>   272         if e == 0:
>   273             return 0
>   274         elif e.evalf() > 0:
>   275             return 1
>   276         else:
>   277             return -1
>   278     elif not e.has(x):
>   279         f= e.evalf()
>   280         if f > 0:
>   281             return 1
>   282         else:
>   283             return -1
>
> which in lisp would be, I think..
>
> (if (numberp e)(signum e)(signum (evalf e))

Well, but the above Python code is for the function signum, so in
LISP, someone had to write that code too.

>
> So maybe the Gruntz algorithm in Lisp would be 200 lines of code.

I would guess it would take around the same number of lines.

> The 2700 lines of lisp in the Maxima limit program may therefore reflect two
> differences.
> 1. Gruntz' algorithm is not used, and the Maxima limit program uses various
> heuristics. So it might not do as much as the Gruntz algorithm.
> 2. The Maxima program accesses a database of assumptions made by the user
> (or possibly other programs) so it might better than the Gruntz algorithm.

Yes, that's a valid point. Gruntz wrote his thesis in 1995, while
Maxima devs wrote this code in 1979. So it's not a fair comparison in
this sense.
But I was not referring to the lines of code, just to the overall style.

>
> As for lisp being dead, it has seen lots of languages come and go.
> See
> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
>
> where Python is ranked 7, after visual basic, php, ...; the trend over time
> suggests Ruby as an up-and-comer..
> Lisp is ranked 16, next to Pascal.  You may be too young to remember Pascal,
> popular in the 1970's.

Pascal was actually my first language I learned, in 1990, when I was
7. I think Pascal is dead too. :)

>
>
> also see newgroup comp.lang.lisp
>
>
>
>>  Which is more
>> readable? I guess there are people who will find the lisp version more
>> readable, but I and most people I know find the python version more
>> readable/maintainable.
>
> Since these two files are not the same program, I do not see how you can
> compare them on readability.

Right. One can look at the overall style of lisp and python though. As
I said, some people prefer one, some the other, some like both and
some neither.
It all boils down if you can get enough people working with you and do
what you want.

>
>
>>
>>
>> However, on a positive note, I think this game is not a game with a
>> sum of 1, but rather it seems to me that all Sage, Maxima, SymPy and
>> other packages are getting new users and developers. In the end, all I
>> want is to get the job done and I think it's important to make sure
>> all the packages talk to each other well, and also to try to find
>> common grounds of cooperation, if possible.
>
> Let me propose getting together a group of people to write a program, let's
> call it Page,
> for People's AmalGam of Editors, that would be a front end to all the text
> editing programs, allowing them to communicate with each other. To improve
> it, we will also take some programs of the 10,000 or so available on
> Windows, and rewrite them in Python, which should make them only a little
> slower.
>
> There are many many more users of text than of mathematics, so it should be
> far more useful than Sage.  There is an additional advantage that to work on
> Page, you don't need to know higher math.   Oh, I forgot, to work on Sage
> you don't need to know math either.
>
> RJF :)
>
> not cc'd to Sage developers, since sarcasm doesn't work there, and this
> login name is not a member..

Sure, everyone is free to do what he wants and to pursue his own ideals. :)

Ondrej