Just posted this on comp.lang.python. Maybe Zope developpers could have comments. ************** First, a warning: - I'm very poor in english. - I woke up way too early this morning. - It's a long post... (Sorry!) - I *love* python. This is not a troll, or anything like that. Ok. Here we go. I would like to share my impressions and my comments on Python. At the end, I will propose what would be for me the *perfect* Python interpreter. Background: I'm working on a fairly big Python (Zope) project since a year and a half. It's a content management system for a big (19 000 employees) entreprise. At first, I was the sole developper for the project. My orders were: "Ok, choose what you want, do what you want. We just want one thing: results..." Lucky, hey? ;) I had experience in Object Pascal (Delphi), Vb (...), C++ and Java. I was new in the company, and wanted to impress my bosses. After some research, I narrowed my choices to two options: EJB (Java) and Zope (Python). I gave a serious look at EJB, but in the end, I chose Python. I took a risk. I don't regret it. After only 2 months, I had already produced a working system. Alone... :) Opinions, impressions: At first, I was amazed by the simplicity and the clarity of the syntax. I *love* the indentation style. It gives clean and standardized source code. We are now three developpers on the project, and it's easy for anyone of us to understand the code of the others. But... As project grew up, I started to see some of the limitations of the language. I understand that Python was not designed for such big projects. But it's so powerfull, so clean, that I just wonder what Python could become with just some (ok, not so minors...) improvements. I understand that backward compatibility is important too, but the latests extensions to Python begin to seem locked by past decisions. I don't like this tendency to __this__ and __that__ everything. We loose in readability, accessibility and clarity, in my opinion... The Perfect Python (c): What is missing ? Well, I'm not a language designer, but I can say what *I* miss. - Interfaces. Behavior checking is not enough. - Private and Public scopes. Explicitly. No more __name_mangling - Design by contract. Pre and Post conditions. Could save hours of debugging. - Block comments. """ """ should be for documentation. - Class variables. - A cleaner Property declaration. No separate _variable. Saw too many newbie posts about that. - No more self in functions declarations. In OOP, this *can* be implicit. (I know, this is controversial stuff) - Standard GUI library. AnyGui seems to be the solution, but development seems to have stalled recently... I tried to write an example of what Perfect Python(c) could look like. It's not valid code (duh!), and it does'nt try to do anything unless give a sample syntax: ******************** from package1.package2 import module1, module2 public interface MyInterface implements (OtherInterface1, OtherInterface2): """ Comments """ private PrivateClassVariable public property MyProperty public MyFunction(param1, param2) public class MyClass(Class1, Class2) implements MyInterface, Interface2: """ Comments """ # Instance Variable private InstanceVariable = "Default" # Class Variable - Public by default static PublicClassVariable = "Default" # Class Variable - Private static private PrivateClassVariable = "Default" public initialize(param1, param2="", param3=None): """ Comments """ # OtherInstanceVariable is Public by default self.OtherInstanceVariable = "rien" # OtherInstanceVariable2 - Private private self.OtherInstanceVariable = "rien" private MyFunction(MyParameter1, MyParameter1): """ Comments """ return "Result" /* Block comment function Foo(): pass */ public property MyProperty: """ Comments """ get(): """ Comments """ return self.MyProperty set(newValue): """ Comments """ self.MyProperty = newValue private testInterface(otherObject): """ Interface checking """ # Check for interface implementation if otherObject implements MyInterface: return true # Check for multiple interface implementation if otherObject implements (OtherInterface1 or OtherInterface2): return true # Check for class inheritance if otherObject implements MyInterface: return true return false private testInheritence(otherObject): """ Inheritence checking """ # Check for class inheritance if otherObject implements Class1: return true private propertyCall(): """ Uniform call """ return self.MyProperty private propertySet(newValue): """ Uniform call """ self.MyProperty = "new value" public functionWithAssertion(Param1): """ Design by Contract """ require: """ Precondition """ Param1 < 1000000 do: """ Function body """ pass ensure: """ Poscondition """ Param1 < 1000000 ******************** I have no idea how this could be implemented. Maybe a PerfectPython interpretor could be developped on top of the standard interpretor? Any comments? Anybody interested to start the project? ;)
Jean-François Ménard wrote:
- Interfaces. Behavior checking is not enough.
Interface packages exist. Have a look at Zope 3.
- Private and Public scopes. Explicitly. No more __name_mangling
I've never found these useful.
- Design by contract. Pre and Post conditions. Could save hours of debugging.
Would itnerfaces solve this for you?
- Block comments. """ """ should be for documentation.
*shrug* I use emacs, it block comments for me in python mode.
- Class variables.
These already exist. class MyClass: my_class_var = 0
- A cleaner Property declaration. No separate _variable. Saw too many newbie posts about that.
never used these, dunno what you're on about.
- No more self in functions declarations. In OOP, this *can* be implicit. (I know, this is controversial stuff)
Sorry, I'd abhor that with a passion. Explicit is better than implicit ;-)
- Standard GUI library. AnyGui seems to be the solution, but development seems to have stalled recently...
TK? WXPython? Take your pick, or your shovel if you're Irish. cheers, Chris
On Wed, 2002-08-28 at 10:31, Jean-François Ménard wrote:
Just posted this on comp.lang.python. Maybe Zope developpers could have comments.
I understand that backward compatibility is important too, but the latests extensions to Python begin to seem locked by past decisions. I don't like this tendency to __this__ and __that__ everything. We loose in readability, accessibility and clarity, in my opinion...
The Perfect Python (c):
Perhaps I'll be dumped from the list, but I really think you should check ruby :) Regards, Juan Pablo
Call this JavaEiffelPython (c) :)) Try to write PEPs about it but don't expect the support of most Python community members! See my (personal) answers within the lines of your original mail (I apologize too for my poor english) --Gilles ----- Original Message ----- From: "Jean-François Ménard" <jeanfrancoismenard@msn.com> To: <zope@zope.org> Sent: Wednesday, August 28, 2002 5:31 PM Subject: [Zope] The Prefect Python
Just posted this on comp.lang.python. Maybe Zope developpers could have comments.
[SNIP]
The Perfect Python (c):
What is missing ? Well, I'm not a language designer, but I can say what
*I*
miss.
- Interfaces. Behavior checking is not enough.
raise NotImplementedError exceptions in the base classes in methods that *must* be implemented by child classes.
- Private and Public scopes. Explicitly. No more __name_mangling
__xxx notation is familiar and short to most python developers including newbies. Using __xxx shows that we're using private scope in an expression. When you declare... private stuff ... # 100 lines of code ... stuff = someExpression You don't see immediately that "stuff" is in the "private" scope... Talking about readable code ? Huh !
- Design by contract. Pre and Post conditions. Could save hours of debugging.
Check the values and raise appropriate exceptions if needed
- Block comments. """ """ should be for documentation.
These ARE for documentation !!!???
- Class variables.
class Stuff: # class var below... objectsCount = 0 def __init__(self): Stuff.objectsCount += 1
- A cleaner Property declaration. No separate _variable. Saw too many newbie posts about that. - No more self in functions declarations. In OOP, this *can* be implicit. (I know, this is controversial stuff) - Standard GUI library. AnyGui seems to be the solution, but development seems to have stalled recently...
Tkinter *is* the standard GUI library that comes with any Python distro. Okay that is not as rich as Java Swing, but it's enough for most small apps, and easy to use. Don't blame those who want to provide environment specific GUI library (Win32, QT...) that are essential in lots of circumstances. [SNIP]
On Wed, Aug 28, 2002 at 11:31:29AM -0400, Jean-François Ménard wrote:
What is missing ? Well, I'm not a language designer, but I can say what *I* miss.
- Interfaces. Behavior checking is not enough. - Private and Public scopes. Explicitly. No more __name_mangling - Design by contract. Pre and Post conditions. Could save hours of debugging. - Block comments. """ """ should be for documentation. - Class variables. - A cleaner Property declaration. No separate _variable. Saw too many newbie posts about that. - No more self in functions declarations. In OOP, this *can* be implicit. (I know, this is controversial stuff) - Standard GUI library. AnyGui seems to be the solution, but development seems to have stalled recently...
There's a lovely language you should check out with all the features you want (except for multiple inheritance and properties); it's called Java. -- Michael S. Fischer / michael at dynamine.net / +1 650-533-4684 Lead Hacketeer, Dynamine Consulting, Silicon Valley, CA
participants (5)
-
Chris Withers -
Gilles Lenfant -
Jean-François Ménard -
Juan Pablo Romero -
Michael S. Fischer