Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between a module, library and a framework

In popular programming speak, what is the difference between these terms and what are the overlaps?

Any related terms I'm missing out?

like image 200
jetru Avatar asked Nov 04 '10 18:11

jetru


People also ask

What is a module package library and framework?

Package is a collection of modules. It must contain an __init__.py file as a flag so that the python interpreter processes it as such. The __init__.py could be an empty file without causing issues. Library is a collection of packages. Framework is a collection of libraries.

Are framework and library the same?

Libraries provide developers with predefined functions and classes to make their work easier and boost the development process. Framework, on the other hand, is like the foundation upon which developers build applications for specific platforms.

What is the difference between a module and a library in python?

Library : It is a collection of modules. (Library either contains built in modules(written in C) + modules written in python). Module : Each of a set of standardized parts or independent units that can be used to construct a more complex structure.

What is the difference between a library and a framework?

However, frameworks are usually more complex than libraries. Also, while libraries contain packages that perform specific operations, frameworks contain the basic flow and architecture of the application.

What is the difference between library and module?

In Swift a module is a single unit of code distribution — a framework or application that is built and shipped as a single unit. In my opinion a module could be a subset of a library, which in turn could be a subset of a framework.

What is the difference between a module and a framework?

In the debate about the difference between frameworks, libraries, packages and modules, what does each one of them represent. Is the smallest piece of software. A module is a set of methods or functions ready to be used somewhere else. Is a collection of modules.

What is a framework in Python?

Similar to libraries, Python frameworks are a collection of modules and packages that help programmers to fast track the development process. However, frameworks are usually more complex than libraries. Also, while libraries contain packages that perform specific operations, frameworks contain the basic flow and architecture of the application.


2 Answers

All three of those provide functionality.

However, there are important differences.

A library is just a collection of related functionality. Nothing more, but also nothing less. The defining characteristic of a library is that you are in control, you call the library.

The defining characteristic of a framework is Inversion of Control. The framework calls you, not the other way round. (This is known as the Hollywood Principle: "Don't call us, we'll call you.") The framework is in control. The flow of control and the flow of data is managed by the framework.

You can think of it this way: in both cases, you have an application, and this application has holes in it, where code has been left out, and these holes need to be filled in. The difference between a library and a framework is

  • who writes the application,
  • what are the holes and
  • who fills in the holes.

With a library, you write the application, and you leave out the boring details, which gets filled in by a library.

With a framework, the framework writer writes the application, and leaves out the interesting details, which you fill in.

This can be a little confusing at times, because the framework itself might also contain boring details, that the framework author filled in with libraries, the parts that you write might contain boring details, that you fill in with libraries, and the framework might provide a set of bundled libraries that either work well with the framework or that are often needed in conjunction with the framework. For example, you might use an XML generator library when writing a web application using a web framework, and that XML library might have been provided by the framework or even be an integral part of it.

That doesn't mean, however, that there is no distinction between a library and a framework. The distinction is very clear: Inversion of Control is what it's all about.

The defining characteristic of a module is information hiding. A module has an interface, which explicitly, but abstractly specifies both the functionality it provides as well as the functionality it depends on. (Often called the exported and imported functionality.) This interface has an implementation (or multiple implementations, actually), which, from the user of a module are a black box.

Also, a library is a collection of related functionality, whereas a module only provides a single piece of functionality. Which means that, if you have a system with both modules and libraries, a library will typically contain multiple modules. For example, you might have a collections library which contains a List module, a Set module and a Map module.

While you can certainly write modules without a module system, ideally you want your modules to be separately compilable (for languages and execution environments where that notion even makes sense), separately deployable, and you want module composition to be safe (i.e. composing modules should either work or trigger an error before runtime, but never lead to an runtime error or unexpected behavior). For this, you need a module system, like Racket's units, Standard ML's modules and functors or Newspeak's top-level classes.

So, let's recap:

  • library: collection of related functionality
  • framework: Inversion of Control
  • module: abstract interface with explicit exports and imports, implementation and interface are separate, there may be multiple implementations and the implementation is hidden
like image 138
Jörg W Mittag Avatar answered Oct 11 '22 10:10

Jörg W Mittag


You can see a module, a library and a framework this way:

  • module = your fingers
  • library = your hands
  • framework = your body

Your fingers / Module:
You can move them, touch things, you have 5 in a hand so you can use them to hold things in an easier way, those are not the biggest parts of the body but are one of the most useful parts, without them you couldnt hack!... modules are part of a program, you can use them, expand code to other files (not a large file with a lot of code in it), they make the reading easier.

Your hands / Library:
Hands are a set of 5 fingers each one, you can hold things, move things, interact with them, etc... libraries are part of a program too! and they can be seen like a set of modules, you can use them to interact with other programs or make relevant things with your program.

Your body / Framework:
Your body is a complete system, you can do with your body whatever you want (even fly, just walk into a plane and there you go, a plane is another system), you are unique... a framework is your body, a complete system, it doesnt work for itself (you need to code herpderp) but you can make a complete program with some hacking runs...

just my interpretation... if im wrong please fix ME.

like image 38
jmsalcido Avatar answered Oct 11 '22 11:10

jmsalcido