Multi Paradigm Programming Language

ProgrammingLanguage with (language) support for multiple ProgrammingParadigms. Examples would be CommonLisp, RacketScheme?, OzLanguage, ObjectiveCaml, Delphi, ScalaLanguage and (debatably) CeePlusPlus.

The comment that CeePlusPlus is "less so" a multi-paradigm was deleted. However, this was not meant as a value judgement, but rather as a technical point.

C++ supports imperative programming, and it has an OO with good language support. It has very primitive support for genericity (via templates).

On the other hand, CL has good support for functional, OO, and even imperative styles. It also has extremely powerful generic constructs, and can be used to build 'mini-languages' with pretty much any semantics you want. Hence strictly speaking it is more "multi-paradigm" than C++.

There are trade-offs, of course, which is why the statement was not meant as a condemnation of C++. The CommonLispObjectSystem is one of the most powerful OO approaches existent, however it can leave much to be desired on the performance front. C++ OO may seem a bit strange to someone coming from the OO community, but it is both useful and fast...

C++ can be effectively used as a FunctionalProgrammingLanguage. The template mechanism is a lazy FPL in its own right (perhaps not a good one), and many libraries (parts of BoostLibraries, etc.) exist which make functional programming easier in C++. The ability to overload operator () makes HigherOrderFunctions easy to implement in C++. The standard library consists of most of the "standard" HOFs.

That said, a few things limit C++'s effectiveness as a FPL.

See also FunctionalProgrammingInCpp, LogicProgrammingInCpp

Possibly the best example of a multi-paradigm language is ObjectiveCaml; an MlLanguage variant that supports object oriented and functional programming. The compiler implementation matches the speed of a typical C++ compiler. ObjectiveCaml is worth looking at if you think the problem with C++ is the lack of a really thorough static type system - I don't, and given the Wiki's XP emphasis I doubt you will either, but ObjectiveCaml is still an impressive achievement.

-- JonCoupe

The OzLanguage is another example of a multi-paradigm language.

I always say about the ToolCommandLanguage that fundamentally it doesn't support any particular paradigm, you just [package require] the one you like. That is quite obvious from the very wide range of different OO packages, as well as some other paradigms like AOP (I also seem to remember seeing some kind of 'frame' based package somewhere). -- Setok

PythonLanguage and RubyLanguage seem particularly good at allowing you to mix and match structures within a single language. The "default" (the way we write HelloWorld) is procedural, but it feels equally natural to write OO or functional or reflective programs.

LuaLanguage is also very accommodating of multiple paradigms. A major design principle of the language is to keep it small and flexible by providing a few meta-features that let you build other features into the language, rather than cluttering the core with them. Adding LazyEvaluation or PrototypeBasedProgramming-style OO to the language can be done in less than a page of code, for example. (It also has TailCallOptimization, unlike Python, which makes it easier to add things via ContinuationPassingStyle.) -- ScottVokes

LuaLanguage is hardly a prototypical example, but I agree that it can support imperative, prototype-based OO, and some functional programming. JavaScript can do the same.

Right. I think ObjectiveCaml or OzLanguage are more overtly multiparadigm, but Lua is both flexible and un-opinionated by design. JavaScript has a lot in common with Lua, but while its design was frozen due to the browser wars, Lua had much longer to mature. I think it's a far better designed language. It seems to me that they were going in the same direction, though. -- ScottVokes

{Being "too meta" may have downsides. See LispIsTooPowerful.}
See MultiParadigmDesign, MultiParadigmProgramming, MultiParadigmDatabase, MultiParadigmWeenie, LetsDesignProgrammingLanguage

Also see ObjectFunctional.

EditText of this page (last edited September 2, 2012) or FindPage with title or text search