Dependency manager, awesome feature of every programming languages

 

dependency preview

Each programming language has its features. One of them is the dependency manager feature, which is very useful during the development process. Before we go into the discussion about dependency managers, let's learn to know what dependency is.

Dependency is the dependence of a method or function on a method or function outside the program we are making. This dependency includes community or company-made libraries that are already available for us to use. So far do you understand bro?

package flow

Surely not, right? Let's learn slowly. First, we have to know what a library/package is in a programming language.

A library or package is a collection of code scripts that contain methods/functions which are ready for us to use to create applications. By using the library, we don't need to create methods manually (create our methods). And this will speed up the process of making programs or applications.

Maybe friends who read this article have created an application (web/mobile) that has an export to excel feature? Then allow me to ask, did you make your method that works to convert Array/Object into an excel file? Well, this method is called a library. Oh yes, if you have never made an application that has an export to excel feature. Then you should try to make the application. This is to make it easier for you to understand what a library/package is.

If the library logic is like you copying a code script from the internet, for example, you copy a code script from the internet which contains a method/function that functions to convert numbers of data into currency strings, from 50000 to Rp.50,000. Well, it can also be called a library, but the difference is it's not included in the dependency, but you copy it manually.

After knowing what a library is, now we go into the core discussion, namely the Dependency manager. As we know, every programming language has a dependency manager feature. So that we have a view of the Dependency manager, then I will provide programming language data along with the dependency manager. Here is the data below:

  • PHP - Composer
  • NodeJs/Javascript - Node Package Manager (NPM)
  • Java - Maven, Gradle
  • Python - pip
  • and others.

In this article, I will practice how to use the dependency manager. I will use Nodejs to put it into practice.

Node Package Manager (NPM) is a package manager for JavaScript that can make it easier for us to manage packages available at https://www.npmjs.com. NPM is automatically installed when installing Node.js on our computers and is also the standard package manager for Nodejs.

npm ilustration

Talking about packages, of course, you already understand module functions in JavaScript. With modules, we can share JavaScript code for use in different files. In fact, through NPM, we can use it on different projects. In other words, the package available in NPM is a module.

When using NPM, we can write commands in the terminal (Linux/macOS) or command prompt/PowerShell (Windows). Here's a terminal example using the npm command.

npm terminal

Before using NPM, we will build an application to convert a number to a currency string with native code. Here are the steps.

  • Create a new app.js file.
  • Enter the following code.
  • Then open a terminal in the directory that has the app.js file and type the following.
  • $ node app.js
  • Then it will have the following result.
    result currency

In contrast to making currency conversions with native code, the package manager can summarize the currency conversion code scripts. Here are examples.

  • Create a new project
  • npm init -y
  • Installing package currency-formatter
  • npm install currency-formatter
  • Using package currency-formattercode
  • Running code
  • $ node app.js

The result is the same, right? Instead of using native code, by using packages, you will be faster in building currency conversion applications. Even in the currency formatter package, there are already many types of currencies, as follows.

Imagine if you had to create the methods/functions one by one manually, then you would need a very long time.

So far, have you understood? I assume so.

After practicing making the currency conversion application above, we can conclude that the dependency manager functions to manage the packages needed by the application. In the example above, it explains that the application requires a currency-formatter package for the application. With the dependency manager, we can also define the packages that are needed during production, and during the development process. The following example.

With the dependency manager, we can also define the packages that are needed during production, and during the development process. The following example

With the dependency manager, we can create applications very quickly, because we do not create methods/functions from 0. Instead, we use packages that are already available in the registry of every programming language. What I'm showing is nodejs, which is NPM. But other programming languages have the same way of working. If we know the fundamentals of this dependency manager, it will make it easier for us to use the dependency manager in other programming languages.

qube

How the dependency manager is amazing, right? Even today, many packages can make applications multiplatform (android, ios, web), machine learning, to Artificial Intelligence.

Still, want to create apps manually?

Also read: Programming language translation method so that it can be executed

Post a Comment

Silahkan corat-coret ....!!!

Previous Post Next Post