mike bayer
Posts: 22
Nickname: zzzeek
Registered: Jan, 2005
|
|
Re: Django vs. Cheetah: 1-0
|
Posted: Jan 31, 2006 11:36 AM
|
|
> And why would being a port of something in Perl be a good > thing? Most Python modules that were ported from another > language's popular API (e.g. threading.py, unittest.py, > and the whole XML DOM thing) suffer from some amount of > braindamage due to not being sufficiently Pythonic.
Well, in coming to Python I definitely had a very good look around at everything available. By far, the one template tool that provided the functionality and extensibility I wanted was Spyce (http://spyce.sf.net). However, Spyce was a little inconsistent in its usage, the source code was definitely not industrial strength, its owner at the time was MIA, and the community didnt seem to be interested in my ideas. Spyce has since gotten a new owner, moved to 2.0, and actually integrated the thing that I wanted, which was template inheritance.
HTML::Mason on the other hand had already proved itself with me as the best dynamic-language based template system out there, and it works quite well for Amazon.com and del.icio.us. As it turns out, its constructs were very compatible with those of Python.
I have observed two things with Myghty: that nearly everyone is immediately turned off by it when they first see it, and that everyone who ultimately uses it (and doesnt have a problem writing their own application around it) can immediately see that its feel, its construction, and its componentized layout is by far the best thing available for Python. Nobody has come to me and said, "this is not pythonic enough, it feels like crappy perl code". Trust me, nobody wants to get away from crappy perl code more than I do. You'd have to dig into it just a little to really see what its about. Whereas Django definitely has shallow newbie appeal, its design concepts will definitely become a letdown on a large project; while you might go and develop your project's first version with it, I am sure that you will eventually be back looking for something else within a few months if not sooner.
> Apart from the admitted prejudice, I looked at the example > in the next post, and both the templating language and the > API look horrible to me. What's the advantage of using > ARGS['name'] instead of $name? Why do they call > files/streams buffers? Why is the output stream declared > when the interpreter is created? Why do I need an > interpreter object (apart from remembering the output > stream, which seems too-early binding anyway)? I could go > on; every aspect of it either looks Perlish or smells like > a dinosaur.
Well a comparison using the "how to construct a template from a string and run it" is a totally irrelevant test. If I want to do that, I usually use '"hello %s" % name'. In reality, a decent web application has at most one line of code within the entire thing that is dealing with the semantics of invoking a template, and it will have hundreds if not thousands of lines of actual template code. *That* is the part you should be judging a template language on. Myghty also usually involves setting up a mod_python config or similar so the actual invocation of the template is not explicitly stated at all.
As for <%args>, Myghty's components act like functions; just as a function must declare the argument list of the variables it wants to have in its local namespace, so should a component. It is a very small-fry design to automatically import every single name in the original request namespace into the template namespace; in a bigger situation with hundreds of interrelated components, having an explicit signature is the way to go. ARGS is then just a dictionary that allows access to the full namespace.
> I'm not sure that more templating power is really needed; > and all the contenders are extensible so by definition you > can have all the power you need.
thats like middle-management mumbo jumbo speak. How do you define "extensible" ? is it extensible in the way you want it to be ? What performance and construction overhead is incurred by extensions ? how well do your extensions integrate with the existing template environment ? I dont see how you can think Django is extensible when its very design philosophy states that it is opposed to any kind of interoperability with the outside world.
The Myghty approach definitely is designed to appeal to those who have worked in the web building trenches for a long time....as it seems most of the Python community is interested in building blogs and other small-scale applications, its not surprising that Myghty remains largely undiscovered. My goal is to bring Python into the forefront of web application construction, as a replacement for Java/JSP, PHP, etc. I think most of the stuff out there, while appealing to start with, when put into rough real-world situations will prove to be a letdown. As one who has been let down by dozens of various tools and approaches for over a decade, I am confident that Myghty has the best "no letdowns" design in the whole Python community.
|
|