> > SOFT_BLUE = NSColor.colorWithCalibratedRed_green_blue_alpha_( > 0.92941, 0.95294, 0.99607, 1.0) > > class MyOutlineView(NibClassBuilder.AutoBaseClass): > def drawRow_clipRect_(self, row, rect): > if row % 2 == 0 and not self.isRowSelected_(row): > SOFT_BLUE.set() > bounds = self.rectOfRow_(row) > path = NSBezierPath.fillRect_(bounds) > NSOutlineView.drawRow_clipRect_(self, row, rect) > <snip> > The inspiration for this came from Evan Jones' implementation in > Objective-C, which is, of course, several times larger than the > code above, especially since it involves more than only this one > method: As an fan of Obj-C, I can't really let this go unanswered. There seems quite a bit of animosity toward Obj-C from python programmers, and I don't really understand why. To test the statement above, I rewrote the python code in Obj-C: id SoftBlue = [NSColor colorWithCalibratedRed:0.92941 green: 0.95294 blue:0.99607 alpha:1.0]; @interface MyOutlineView : NSOutlineView { } @end @implementation MyOutlineView -(void)drawRow:(int)row clipRect:(NSRect)rect { if ( row % 2 == 0 && ! [self isRowSelected:row] ) { [SoftBlue set]; NSRect bounds = [self rectOfRow:row]; path = [NSBezierPath fillRect:bounds]; [self drawRow:row clipRect:rect]; } } @end This is 494 characters long. The python example is 445 characters long. So in this case Obj-C is 10% longer, and this is a worst case example, because the ratio of method code to class declaration code is low: python basically replaces the '@interface/@implementation' type keywords with a single 'class' keyword. This leads me to something that I think is better in Obj-C than python: the smalltalk method naming. I like python a lot, and use it when I can. It is a concise language, and there are countless modules available which you can't find in Obj-C. But I find remembering method signatures, particularly the number or order of arguments, much more difficult in python than Obj-C. I have to continually go back to docs to jolt my memory. You don't have that problem in Obj-C, because you remember the method name, and it tells you what the arguments are. You often also avoid in-code comments, because the method calls are self documenting. In my view, monolithic method naming is a hangup from C/C++ that afflicts otherwise good languages like Java and python. It is the same as the countless linux windows managers that were too short-sighted to avoid using a 'Start' button. The dominant technology of the day dictates the trends, whether for good or bad. Along these lines, has anyone ever 'hacked' the python interpreter to do smalltalk like messaging, with segmented names? I've been tempted to try it myself. You wouldn't think it would be that hard. Maybe just an extra stage to convert segmented names to underscored ones, the same way that PyObjC names methods. But I'm no python expert, so I don't know what would be involved. Drew ---------------------------------- Dr. Drew McCormack Trade Strategist (www.trade-strategist.com) Stock Market strategy design platform for Mac OS X.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4