1

Clearly the prototypical "Hello World" program does not suffice to demonstrate the difference between the major paradigms of programming. What would be the minimal program to show the differences between procedural, object-oriented, functional and reactive programming?

  • 2
    It would be nice if there was such a thing, but there isn't. There's no objective way to tell the difference between "demonstrating where one language is better/worse" and being "biased towards/against one language". – Ixrec Apr 08 '16 at 08:37
  • A popular vehicle is to print out the "99 bottles of beer" song. – Kilian Foth Apr 08 '16 at 08:47
  • 1
    @Ixre, I think you miss the point of the question. It's not about better/worse; it's how each paradigm is used to solve the same problem. – David Arno Apr 08 '16 at 08:52
  • Exactly @DavidArno – nilo de roock Apr 08 '16 at 08:54
  • 1
    You seem to be assuming that there are clear lines of delineation between different paradigms; but there aren't. All of the popular mainstream languages support multiple paradigms; and often principles which are commonly attributed to a particular paradigm are equally valid in other paradigms too. – Ben Cottrell Apr 08 '16 at 08:58
  • Assume that I assume nothing, @Ben Cottrell The question is not about a specific language, the questing is about the minimal program to demonstrate a paradigm, maybe you can demonstrate different paradigms in one language. – nilo de roock Apr 08 '16 at 09:01
  • 1
    @ndroock1 you have made at least one assumption in your question, which is that a single program is usefully capable of showing the differences between different paradigms. If your question were "What would be a minimal (different) program for each paradigm?" then that question would be a lot more answerable. – Ben Cottrell Apr 08 '16 at 09:12
  • This poster contains the 34 principal (as deemed by the author) programming paradigms: http://WWW.Info.UCL.Ac.Be/~pvr/paradigms It also organizes them in a way that it shows you which concepts (there's about a dozen) you have to add to a paradigm to get to another one. You could look at those concepts and try to find a problem where all of them are in some way important. I think an IDE would work well: the type checking and inferencing part would let languages like Prolog shine, it is highly concurrent, highly reactive, a compiler is essentially a big pure function, objects are nice for GUIs … – Jörg W Mittag Apr 08 '16 at 09:16

1 Answers1

5

One could take, for example as Kilian Foth mentions, a bunch of bottles on a wall and show how the different paradigms solve displying the song, via loops, recursion, events etc.

However, it's questionable whether you would achieve anything useful by doing so. Many modern languages can support all four paradigms, for very good reasons: each paradigm has its time and place. Having some timer-based countdown and an event listening to that countdown to emit new messages of decreasing bottles would be a poor way of implementing the green bottles song. There are situations where reactive programming is a really good solution though.

I'd suggest you'd be better off identifying good examples of when to use each paradigm, rather than how each paradigm can be used to solve just the one example.

David Arno
  • 39,270