From: Kay S. <ka...@fi...> - 2009-07-28 06:49:52
|
May I ask if the Django bit is for marketing the book? It's not the only thing I'm confused about. The book goes in a very slow pace and I have the impression that it is for beginners who were never exposed to a programming language before. Then it highlights on various places the differences between CPython and Jython or Python and Java respectively. At other places I wonder what the 5 authors are try to tell: /"In Python, we have ‘duck typing’. If it sounds like a duck, quacks like a duck and looks like a duck - well - it’s a duck. This is in stark contrast to more rigid languagse like C# or Java which have formal interface definitions. One of the nice benefits of having duck typing is that Python has the notion of object ‘protocols’./ /If you happen to implement the right methods - python will recognize your object as a certain type of ‘thing’./ /Iterators are objects that look like lists that let you read the next object. Implementing an iterator protocol is straight forward - just implement a next() method and a __iter__ method and you’re ready to rock and roll." /Do you really expect anyone understands what you are talking about? Do you know why methods which define behavior on user level but being called on VM level are called "protocols"? Keep it as simple as possible but not simpler. The reader has not the slightest idea why the rock'n rolling Python community uses familiar notions out of their context. What comes close to a "protocol" is the relationship of a command-template method and the methods defined in subclasses it calls. This is one of the classical design pattern every self respected Java programmer knows about. In case of "protocols" we are not necessarily bound to command-template method abstraction but it can be just be some block of code represented internally by a sequence of byte codes depending on the compiler implementation.For example a for-statement expects an iterator and calls __iter__() to initialize the object it iterates over and next() to keep the next value from the iterator. Even simple operations like the addition of two values x + y can be understood in terms or "protocols" where the command pattern can be stated as an expression x.__add__(y) in the simple case or as y.__radd__(x) when x doesn't define __add__ but y defines addition __radd__ which means that y assumes to be on the right hand side of the + operation. One remark about Django. It is surely an important milestone to have a working Django port. It shows Python programmers quite clearly: we have arrived in the modern Python world! But last time I checked Django it was a pure Python implementation that doesn't make particular use of anything defined in the Javaverse. When integration of Python with Java is at the heart of Jython why not showing how Java resources can be used effectively from Python ( benefit for Python programmers ) and how Java programmers can benefit from Python scripting? Ciao, Kay |