9

This is a more specific question (or actually two, but they are related) coming from the comments of OOP technology death where someone stated that OOP is not the right paradigm for GUI programming.

Reading the comments there and here I still have the feeling there are things to learn: which programming paradigms are considered good fits and why are they better than others (perhaps with examples to illustrate?)

I removed the tk-example from the title and question

18
  • @Inca - keep in mind, that SK-logic (who originated this comment) fights OOP on every possible occasion - like if he had a fanatic mission. I strongly doubt that he can really prove that tk is not related to OOP at all. Commented Jun 30, 2011 at 9:38
  • -1: for quoting a personal opinion as if it were fact. "OOP is not the right paradigm for GUI programming" would fly in the face of C# and Objective C which seem to depend very heavily on OOP for GUI programming. If it's not the right paradigm then all of Apple's huge market share doesn't really exist or something.
    – S.Lott
    Commented Jun 30, 2011 at 9:49
  • 1
    @S.Lott it's not the right paradigm though, GUI should be declarative. You seem to be confusing popularity with what is right.
    – Raynos
    Commented Jun 30, 2011 at 10:06
  • @Raynos: "declarative". As in, some related objects? I don't get how declarative is not a bunch of relationships among a bunch of objects. And. That's seems off-topic for this question. The question seems to be about OO, not better ways to write GUI's. The title seems to be misleading compared with the actual question. Neither are very good.
    – S.Lott
    Commented Jun 30, 2011 at 10:07
  • 1
    @Inca: Consider disregarding it entirely as mere hyperbole.
    – S.Lott
    Commented Jun 30, 2011 at 10:16

2 Answers 2

9

I'm not normally a proponent of OOP, but I would say that GUI programming presents some of the best opportunities to use the strong points of OOP. Implementing various widgets is made a lot easier by using OOP's polymorphism and inheritance. PLT Racket's GUI library is a good example.

2
  • 2
    Functional reactive programming yet seems to be a better fit.
    – SK-logic
    Commented Jun 30, 2011 at 13:09
  • @SK-logic: You could make a very good case for that, and some interesting work in Common Lisp (have you heard of Cells?) has been done in that direction. I'll edit my answer to make it more precise. Commented Jun 30, 2011 at 13:13
6

A typical GUI, made of widgets and their layout, is entirely declarative. Widgets per se would not interact with each other, so a notion of objects and messages is somewhat alien here. Hierarchial declarative DSLs are a sort of a mainstream currently, with Tk being one of the early examples, and WPF as a more modern approach to the same thing. Functional reactive programming is another interesting (but not very widespread) approach.

Some people tend to see OOP anywhere where a hierarchy is defined, which is wrong - there is absolutely no connection between strict hierarchies (read - algebraic data types) and Kay's definition of OOP.

1
  • 4
    In my experience, widgets do need to interact with each other to make a better GUI, and the more declarative systems I have encountered (certain xml-based ones, including HTML+css) certainly lack possibilities in the interaction-part. Also, my experiences with incorporating UI using declarative (prolog) and functional (Haskell) did not really give the impression it was easy. Do you have sources I could look at that specifically discuss more of this? I have only come up with very abstract (or very basic) examples that don't explain much as to why certain approaches work better
    – Inca
    Commented Jun 30, 2011 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.