What is the purpose of library dependencies( which only provide functions) being listed as an application?
For example, the left_pad project recommends that it is included as an application when it only provides a simple function.
def application do
[applications: [:left_pad]]
end
Should Elixir packages always be made available as applications? How can a new library developer make their dependency available as an application? What other features does this provide?
Have a look a this question: Specifying app startup order with erlang.mk
Basically, all applications your application depends on are guaranteed to be started before your application is started.
However, if a function in your application calls another function in a module that hasn't been loaded yet, and the module is in one of the paths returned from get_path/0
, then the VM will automatically load that module anyway.
But, when doing releases with release handler (see this question for more information and also Erlang's official documentation), only specific applications will make its way into the release - those you explicitly specify in the reltool.config
and those that are dependent upon. If your application uses the library application and you don't list it neither in the application file nor in the release configuration file, it won't be deployed to the production system and your application won't be able to call the function from the library application.
And yeah, as pointed out by michalmuskala, the list of dependencies is also a factor for the release handler to consider when it calculates the order in which modules are being reloaded when upgrading releases with release handler.
So, summing up, it's not that important in development environment, but it's a good practice, and it's required if you are doing proper Erlang releases when deploying stuff to production.