5 ms·
The bit about these kinds of articles that always nags at me is the assumption that different programming paradigms are somehow mutually exclusive. Essays talk
by bunderbunder 14y ago
The bit about these kinds of articles that always nags at me is the assumption that different programming paradigms are somehow mutually exclusive. Essays talk as if object-oriented code cannot also be functional, or code isn't procedural if it involves classes, or whatever.
In some cases that might be true - declarative programming and procedural programming, for example, are diametric opposites in many respects. But others can be quite comfortable bedfellows. In particular, object-oriented programming and its older cousin modular programming tend to play quite nicely with other paradigms. Consider CLOS or Objective-C.
And even when they're opposed to each other that really just means you're limited in how you can mix them on a per-line basis. You can still write a multi-paradigm language that lets you support features from different styles.
Consider C#, which supports object-oriented, procedural, functional, and declarative programming (with the last admittedly being somewhat constrained), and where it's standard practice to use elements of each style all within a single short procedure. Sometimes elements of different styles end up depending intimately on each other. For example, to provide optimal support for (declarative) query expressions, one will probably need to implement the (object-oriented) IQueryable interface, and many of the methods in that interface are expected to take (functional) anonymous procedures as arguments and/or are used to build up (functional) monads representing the query that's being declared, which are in turn represented as (object-oriented) instances of classes that implement specific interfaces.
- einhverfr 14y agoThis. Even declarative and procedural program can have some interactions. It is very hard to do anything with just declarations ;-), and there is some logic to making the procedures of the code clear and explicit. A lot of stuff comes back to 'be simple, be clear.' And if mixing paradigms lets you do it, go for it!
- ExpiredLink 14y ago> The bit about these kinds of articles that always nags at me is the assumption that different programming paradigms are somehow mutually exclusive. Paradigms are by definition mutually exclusive[1]. I'd argue that neither OOP nor FP nor procedural programming ... are paradigms but merely styles or idioms. Combining idioms is quite usual in our culture. [1] http://plato.stanford.edu/entries/thomas-kuhn/#3 http://plato.stanford.edu/entries/thomas-kuhn/#3
- bunderbunder 14y agoI appreciate that you're trying to be pedantic, but taking a word that was used correctly according to the jargon of the subject being discussed, and claiming that it was actually used incorrectly because of this other definition in an completely unrelated field isn't really pedantry. It's more a failure to understand polysemy[1]. 1: http://en.wiktionary.org/wiki/polysemy http://en.wiktionary.org/wiki/polysemy
- ExpiredLink 14y ago"When I use a word," Humpty Dumpty said in a rather a scornful tone, "it means just what I choose it to mean --- neither more nor less."
- bunderbunder 14y agoAnd in this case, I meant it to mean the concept you'll read about if you google "programming paradigm." As clearly indicated by my use of the phrase "programming paradigm." You can find out about a different concept if you google "philosophical paradigm". That'll give lots of links that talk about Thomas Kuhn. TL;DR: It may be called a drum, but that doesn't mean you can use a bongo to repair your car's brakes.
- dllthomas 14y agoBut if you expect other people to understand you, you need to be aware of how they expect the word to be used and either use it that way or clarify at the outset that you're using it differently.
- ExpiredLink 14y ago'Paradigm' isn't used ambiguously. See also Wikipedia: http://en.wikipedia.org/wiki/Paradigm http://en.wikipedia.org/wiki/Paradigm
- dllthomas 14y ago