Tao of the Machine

Programming, Python, my projects, card games, books, music, Zoids, bettas, manga, cool stuff, and whatever comes to mind.

Lisp

Another long language-related thread, otherwise known as flamewar, on comp.lang.python. Although it's currently still too polite to be a real flamewar, it could very well become one soon. The original question was this: why is Python popular, and Lisp and Scheme aren't?

Who knows, but the reason I don't use Scheme and Lisp is syntax-related. I already pointed this out at some time in my old blog. It's not the abundance of parentheses that makes Lisp difficult for me. First of all, Lisp functions are basically one large nested expression. Here's an example from the CS330 course on byu.edu:

(define list-index (lambda (sym lst)
    (letrec ((list-index-aux 
               (lambda (sym lst index)
		  (if (null? lst) 
		      -1
		      (if (eq? sym (car lst))
		  	  index
			  (list-index-aux sym (cdr lst) 
			  		      (+ 1 index)))))))
	(list-index-aux sym lst 0))))

My gripes with this are: expressions are nested too deeply, and there are no syntactic clues. Where do some of these expressions end? (And this is code that is relatively easy to read, by Scheme standards, it has indentation and meaningful naming...) I realize that Lisp syntax is very powerful, but as long as I can't grok it, I cannot use Lisp well. Maybe someday...

Another issue that was brought up in the thread is that Lisp allows for powerful macros, which let you make your own control structures, etc. Very nice, but what happens if someone else reads your code? I can read anybody's Python code without problems, unless it's deliberately obfuscated (which is often done using deep nesting and functional constructs <hint>). Languages that allow more freedom in this area (Lisp, but also e.g. Perl) allow for programs that are hard to read for others.

All this doesn't mean that Lisp & co aren't worth studying or that they suck. On the contrary, they are very powerful and elegant languages. But using them requires a mastery that I haven't acquired yet. :-/

Posted by Hans Nowak on 2002-11-10 20:02:42   {link}
Categories: programming

Some random thoughts

1. Tomorrow is veteran's day. Basically that means that everybody is off, except me. :-) Worse, there will be no mail, and I am expecting two large paychecks. How many excuses does USPS need to not deliver the mail? Not long ago it was Columbus day, Halloween, now this... soon it'll be Thanksgiving, etc. And I thought the Dutch PTT was bad...

2. We went to Petsmart to look at the cats, which supposedly can be adopted in the weekend. (You cannot access the area on regular weekdays.) Finally, we saw cats we liked and wanted them. How to get them, though? Petsmart person: "Oh, the people of the Puppy Hill Farm are only here on Saturdays, so you can't get them now, but you can call this number." How stupid is that? What's the point of letting people visit (and choose) on Sunday then? To top it off, they didn't show the cats on their website, just dogs.

Imagine walking into Borders to buy some books, and the clerk says, no, we only sell those on Saturday, but you can call this number to reserve the book, but bear in mind that many other people might want the same book... ::grumble::

Posted by Hans Nowak on 2002-11-10 19:55:35   {link}
Categories: general

Editor, take 2

I abandoned the Tkinter version of my editor project in favor of a wxPython version.

Why? IMHO, Tkinter is cool for a simple GUI like Kaa's, or for any GUI where the available widgets are sufficient. Unfortunately, they were not sufficient for my plans. I didn't want all that much, really... picture a window with a tabbed notebook; each of the notebook pages contains an editor. I'm sure the Tkinter/Pmw combo can do that, but I ran into problems. Renaming tabs, lack of custom file dialogs, etc. So now I'm using wxPython instead.

Of course, that isn't flawless either. I consider Tkinter to be cleaner and in some ways easier to use. wxPython requires you to juggle lots of IDs, for example. Also, layout is non-obvious... it took me a while to figure out that sizers can pretty much do what I want, but they require some method calls (taken verbatim from the demo) to make it work.

IDs are an implementation detail and should be hidden from the programmer whenever possible. I (try to) get rid of them like so:

class MySubClass(wxSomeClass):
    def __init__(self, parent):
        self.id = wxNewId()
        wxSomeClass.__init__(self, parent, self.id)
Now I can create MySubClass without having to worry about yet another ID. If I really need it, I can get it from the instance though the id attribute.

Any working code I might produce will be published here. Bear in mind that this is my personal editor project, though... (Hmm, don't I say that about all my projects? :-)

Posted by Hans Nowak on 2002-11-09 19:03:44   {link}
Categories: Python

--
Generated by Firedrop2.