Software Development

About Mixed-Paradigm Languages Such As Java and Python

Intro

There are two really popular programming paradigms (yay, alliteration!) out there: functional programming and object-oriented programming. There is another that seems to be on the rise: resource-oriented computing. I’m sure there are others that have come along as well.

For the longest time, languages tended to stick to one paradigm or another, but recently, there has been a strong trend to include multiple paradigms into a language. Python, which has functional and OO elements to it, has really started to become popular; Java just added in Lambda and passing functions with the 1.8 update; a bit back, Scala was developed as a JVM functional language, keeping some OO in order to make the transition easier I think.

There’s a Problem, Though

One of the best-known people in the Java world, Robert “Uncle Bob” Martin, did a talk on Clojure, a pure functional language on the JVM. In the Q&A portion of that talk, someone asked Bob about languages with more than one paradigm. He answered, basically saying that mixed-paradigm languages are a bad idea because every paradigm is designed to restrict programmers from being able to do a certain thing in order to protect them. So when you mix paradigms, it actually ends up taking away those restrictions, making it so that the language doesn’t really have either paradigm, since those restrictions don’t really overlap.

Or Not

I’m a big fan of Bob; after all, he wrote one of the most influential programming books to writers in all language, Clean Code, but I have to partially disagree with him on this. Yes, the different paradigms do work off of using certain restrictions, but that’s exactly why mixing the paradigms is such a good idea. Each paradigm makes a certain thing impossible to do, but sometimes, that thing is exactly what we need to make the best solution to the problem. Or, at the very least, they serve as a way for a programmer of one style to transition from one paradigm to the other.

I don’t have a ton of experience with functional programming, but many swear it’s the best solution to all problems. If that IS the truth, then being able to transition smoothly seems like a really good idea.  If it’s not, then able to have both OO and functional language constructs sounds like a great idea! I’m not entirely convinced that functional is better than OO for everything, but I may find that to be untrue someday.

There’s Still A Small Problem, Though

There is something about mixed-paradigm languages that bugs me, though: they never seem to have all the features of both paradigms. Java doesn’t have pattern matching; Python doesn’t have the ability to make things private (though, that can be argued to be for the best, sometimes).

I can’t be sure that it’s impossible to have full features of both paradigms, but it certainly seems that way. I can’t complain too much about this, though, as there are pure OO languages that don’t have a full set of OO features and pure functional languages that don’t have a full set of functional features. Java doesn’t have properties (I soooo wish it did), and there are plenty of functional languages without pattern matching.

Outro

Anyway, my point, though admittedly not a very strong one, is that I think Uncle Bob is wrong and that mixed-paradigm languages are the way of the future, at least for a while, anyway.

Jacob Zimmerman

Jacob is a certified Java programmer (level 1) and Python enthusiast. He loves to solve large problems with programming and considers himself pretty good at design.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button