Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between Wrapper and Library [closed]

I am curious to know the differences between a Wrapper and a Library.

From what I have been able to find online I can't really see any major difference between the two. I often came across "Wrapper Library" or "Library Wrapper" and it makes it seem as if they are basically one in the same.

However, my assumption is that a Library is a collection of finely tuned functions that provide a means to accomplish a task that isn't part of the core functionality in the language.

And a Wrapper is a facade that makes it easier and quicker to set up certain functionality within your program so that you have less typing to do.

These two descriptions just make it seem like it's the same thing with different wording to me though.. so I come to you Stackoverflow,

What are your opinions and professional points of view on Wrappers/Libraries?

Sidenote/Background:

This question stems from my C++ Design Patterns Class I finished a month ago:

In my C++ Software Design Patterns class we had to create a Socket Library that took the WinSock Library and created a Thin(Or Thick, our choice) Wrapper over it. We then had to create two applications that used our library so that we didn't have to repeat the basic set up and tedious coding of the WinSock Library. I ended up with 100% on the project but wish to know more about the actual differences or similarities because I want to expand on this project in my personal time.

like image 553
Dylan N Avatar asked Jun 14 '13 17:06

Dylan N


1 Answers

In general, I personally think of it like this:

  • A library is typically an actual concrete implementation of some functionality.
  • A wrapper is mostly just a layer of abstraction around existing functionality. It is only intended to offer a better, cleaner interface (or at least one feels more native to the language or technology it targets) to something that already exists.

Now obviously there are times when the distinction between the two is crystal clear and times when the line is blurred, so some subjectivity may be inevitable in the latter scenarios. In other words, what you consider an implementation and what you consider simply an abstraction can be ambiguous occasionally.

For instance, a wrapper can have argument checking functionality or better state bookkeeping that the underlying system did not have. If this is mostly to serve the correctness of the abstraction, then it this still leans on the side of the wrapper. If some genuinely new functionality is added, it starts becoming a library and could be called a wrapper-library.

On the other hand, a full-fledged library may not be a wrapper at all, in the sense that it may leverage an underlying system to offer some functionality, but without exposing any considerable part of that underlying system in any clean interface (other than the specific functionality it adds). This would be called a library, but most probably it wouldn't be called a wrapper.

(I should clarify that what I said is how I think of the matter in general, not specifically in regard to C++. If the C++ world has less ambiguous definitions of these terms, please do correct me.)

like image 143
Theodoros Chatzigiannakis Avatar answered Nov 15 '22 01:11

Theodoros Chatzigiannakis