-1

What is the benefit of having multiple implementations just for doing one thing? Are there any other languages that use this concept?

2

It's the same idea as with the difference between interfaces and classes (abstract classes included). Why don't you write everything with classes?

Because once you write the code, that code is fixed and only does what it was written to do. One thing and one thing only. What if I need another implementation that does something slightly different? Or faster? Or by consuming less memory or resources? How do I replace the code if everything is tied to only one implementation? You can't.

Now extend that idea a bit and you get the answer to your question. Take for example, the JVM. The spec sais how it should behave, but there are tons of implementations. The JVM that runs on your PC isn't the same that runs on your mobile phone. Someone else decided to write a JVM optimized for their platform. They can do that because of the "specification approach" as you call it. How about if I'm a manufacturer of smart refrigerators and want to use Java as a language because I can find more developers than, say, C++? Am I going to install the Oracle JVM on the thing?

Another example. Do you use Tomcat? What if GlassFish was your only option?

And the same goes for XML parsing, messaging, servlets, web services, or whatever. You get a reference implementation which you can use, or you can write another one optimized for your specific situation if the reference implementation doesn't quite float your boat.

And yes, a lot of other languages do it the same, for similar purposes. You have multiple implementations that do the same, but in very different ways, and for different reasons or needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.