0

I hear very often that the object-oriented programming paradigm is the most widespread. But are there any scientific statistics about how often other programming paradigms like procedural programming are used today?

I searched at gartner, but didn't found anything.

Philipp Eger
  • 119
  • 3
  • http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html Gives you a list of which language is used. It doesn't tell you if the user is using C++ to write C-style code, or C to write object oriented, etc, but it's perhaps a starting point. Of course, there are reasons other than "paradigm" that a particular language or technique is used. Try writing a Linux device driver in C++ - yes, it's technically not impossible, but impossible to get into the Linux kernel at present... – Mats Petersson Jan 31 '15 at 12:03
  • Javascript probably made the functional paradigm more popular/accessible than it used to be, but I have no idea how you'd go about determining what percentage of Javascript developers are writing OOP code rather than functional code. – Ixrec Jan 31 '15 at 12:08
  • 2
    Think about what it would take to gather meaningful data on that. – Blrfl Jan 31 '15 at 12:46
  • Further, a lot of programming is really quite a hybrid of many techniques... – Mats Petersson Jan 31 '15 at 13:00

1 Answers1

0

I don't think such statistics exists, and if they are, they may not be particularly relevant.

Take C# code base:

  • C# is an object-oriented language, but it is not unusual to see code bases full of procedural code written by programmers who has no understanding of object-oriented programming (or understand it as "OOP is when you put the code in methods within classes").

    How would you measure the proceduraliness of the code base? How can you tell that the code base is 64.2% procedural and 35.8% object-oriented?

    Assuming you just want to tell whether the code base is either object-oriented or procedural. Agreed, you will be able to do that for some code bases (the ones which are obviously missing any OOP or the ones which use object-orientation very well), but in many cases, the answer won't be that straightforward.

  • C# also has many functional paradigms, making it sometimes particularly elegant when working with collections.

    This being said, C# is not a functional language, and writing purely functional code for a large application won't be possible, not counting the fact that many functional paradigms don't exist in C#.

    This makes it even harder to measure. You can't just say: "This code base is functional." or "This code base is object-oriented." for code bases which use functional paradigms only when working with collections. So we are back to 64.2/35.8% problem described above.

If you're interested in the popularity of paradigms, what you may search instead is the penetration of some paradigms in languages and communities which weren't using them before. For example, ten years ago, C# didn't have any functional paradigms, and programmers who were using exclusively C# were most unaware of what a functional language is. Today, things are radically different.

This is also statistically measurable. You may measure that in 2004, 21.7% of programmers of a given community knew what functional language is, while in 2014, 41.2% know that, or that in 2004, 6% of programming languages had a specific paradigm, while ten years later, 9% had it.

Arseni Mourzenko
  • 134,780
  • 31
  • 343
  • 513
  • Thank you for your informative answer. I understand now that it is very difficult to measure if a code is functional or object-oriented. – Philipp Eger Jan 31 '15 at 14:15
  • It's also perfectly possible to write code which is object-oriented and referentially transparent (i.e. functional) at the same time. In fact, avoiding side-effects (i.e. functional programming) is considered a good thing in OO. The entire book *Java Concurrency in Practice* can probably be summarized as "use functional programming". – Jörg W Mittag Jan 31 '15 at 14:52
  • @JörgWMittag: Interesting remark. Personally, I wouldn't consider code which simply avoids side effects as necessarily functional if I don't see some of the [functional aspects](http://programmers.stackexchange.com/a/265136/6605) in it. Am I wrong and side-effects avoidance *is* the definition of functional programming, while other aspects are simply *tools* which help avoiding side effects? (Reading the definition, it looks like I'm wrong, but I'm not sure) – Arseni Mourzenko Jan 31 '15 at 15:20
  • Functional programming is definitely to a large extent based on "no side effectst". Of course, you can't have 100% no side effects and still do anything more useful than waste time - you probably do want to, say, print some result or read some data from a file [or console] - both of which counts as side-effects. So you can't have 100% "no side effects", unless all you do is calculate something from constants [or random numbers] in the code, and never output anything - which is rather a phony program. – Mats Petersson Jan 31 '15 at 17:41