Subj : Re: wxWidgets To : comp.programming From : Rob Thorpe Date : Tue Jul 05 2005 01:05 pm Phlip wrote: > Rob Thorpe wrote: > > > My point is that it wxWindows would be much more useful if it was a > > library providing a set of library calls. That way it could be used > > with any language. Object-orientated wrappers could be written for > > C++ and other OO languages. > > Technically, that paragraph betrays the belief that flat API functions are > easier to bind to any language than OO objects are. > > Where this is true (and where we don't need Yet Another ORB-Oriented GUI > Toolkit), others have discussed the wrapping issues. > > When I code in wxWidgets, I think "Ah ha, I'm smarter than all these lessor > programmers. They think you 'reuse' an object in OO by inheriting its class! > But I'm smart enough to know that most reuse is by delegation, so I won't > inherit this Window class, I'l just make it a member of my application > object!" > > Then to do anything with the window, I must override a virtual method. So I > must switch to inheritance. > > That's what you meant by "force the user to use C++ and the > object-orientated paradigm". Yes. Once inheritance and virtual functions are involved - which normally has to be fairly early on in C++, you're stuck thinking like they're thinking. > What's really going on here is C++ is not "object oriented" /enough/. The > best OO languages support block closures, which are the best way to sink > events. I should be able to tell that window's event to call this code > block. Without that feature, GUI Toolkits require linguistic hacks to sink > events. Some toolkits call callback functions, and some call virtual > methods. Either way, we got polymorphism. > > Someday, we will have an Ultimate GUI Toolkit when we have a cross-language > system to permit block closures. Then all GUIs would be sets of library > calls, and any language could call them, and sink their events. > > Flat API functions are stack-oriented. When we invent a block closure system > that works at the binary level, the same for every language, then we can > have an Ultimate GUI Toolkit. I would like it very much if the GUI toolkit I was talking about were to use closures. It would make a great deal of code much simpler. When I wrote my post I possibly wasn't dreaming hard enough. The problem though is that it could be difficult generally, if the function being closed within the scope is written in a different language to the scope. When this problem is solved, then yes the Ultimate GUI toolkit is close. .