A few years ago we realized that having a package manager for the Ada
/SPARK
community would be a game changer. Since then, AdaCore has been sponsoring and contributing to the Alire
project created by Alejandro Mosteo from the Centro Universitario de la Defensa de Zaragoza. With this blog post I want to introduce Alire
and explain why this project is important for the Ada
/SPARK
community.
What is a package manager? #
There are many different kinds of package managers, Alire
is a source-based package manager focused on the Ada
/SPARK
programming language.
This means that the goal of Alire
is to provide an easy way to get, build and use Ada
/SPARK
projects in source form. It is a tool for developers, as opposed to binary package managers which are providing ready to use applications for end-users. It is comparable to opam
for the OCaml
ecosystem, or Cargo
for Rust
.
What are the benefits of Alire for the Ada/SPARK ecosystem? #
In my opinion, the main benefit of a package manager is to improve the collaboration within a community of developers.
This is achieved in multiple ways:
-
Alire
is a central place to look for existing projects. If you are looking for a library to provide a given feature in your project, a quick search on the alire.ada.dev website will tell you if someone from the community already implemented it. -
The corollary is that
Alire
is a central place to contribute projects and make them available to other developers in the community. -
Alire
provides a common and easy way to integrate projects from the community in your own projects.
What does it mean in practice? #
Let’s take a simple scenario from personal experience: I am writing an application in Ada
, and I want my application to produce PDF reports.
We will look at different steps of this scenario and compare how to achieve them without and with Alire
. I will use the alr
command line tool from the Alire
project.
1st step: finding an Ada PDF library #
-
Before
Alire
: I will search the web for a project that matches my needs. Search engines are pretty powerful so if there is something out there (on GitHub, SourceForge, GitLab, or elsewhere) I will likely find it. “Ada PDF” doesn’t yield good results, but “Ada PDF library” does the job. -
With
Alire
: A simple search on the alire.ada.dev website gives me a list of Ada/SPARK projects available right now matching the PDF keyword: https://alire.ada.dev/search/?q=pdf Or on the command line:$ alr list | grep pdf
2nd step: use APDF in my project #
-
Before
Alire
: Once I have found theAPDF
project (https://apdf.sourceforge.io/) I can either get the source from tarball or checkout the repository. From that I have to understand how to use the source code in my project. Maybe I have to set theGPR_PROJECT_PATH
, maybe I have to build and install the library. -
With
Alire
:$ alr with apdf
The
alr with
command automatically fetches the latest version ofAPDF
and makes it available in my project.
3rd step: updating APDF when new releases are available #
-
Before
Alire
: I have no automated way to know if a new version ofAPDF
is available. I can follow forums and mailing lists in hope of catching the information, but this is not very reliable. If I do get the information that a new version ofAPDF
is available, I have to redo the 2nd step (download tarball, extract, set project path, etc.). -
With
Alire
:$ alr update
With the
alr update
command,Alire
will let me know if new versions of my dependencies are available and automatically update them for me, if I wish to do so.
4th step: Other developers want to build my project #
-
Before
Alire
: I have to document in the README file all the steps to get and set up my dependencies (download tarball, extract, set project path, etc). Anyone interested in compiling my project has to follow all the steps, and do so transitively for all dependencies. -
With
Alire
:$ alr get my_project
If I contributed my project to the
Alire
index, anyone can get the project and its dependencies with a simple command. Otherwise, one can checkout the repository and usealr update
to fetch the dependencies.
5th step: publishing my project for others to use in their projects #
-
Before
Alire
: I have to document how to integrate my project in another project. I can then announce the project on an Ada/SPARK community forum like Reddit r/ada and hope that this or the repository will show up in a Web search when people need my project. -
With
Alire
:$ alr publish
Alire
provides a command to help publishing projects in theAlire
index. Once my project is in the index, a dedicated page will be created on the alire.ada.dev website and my project will be available forAlire
users. Of course it is still a good idea to announce it in the forums.
How many projects are available in Alire
? #
As of October 2020, there are 130 projects (“crates” in the Alire
vocabulary) available. You can browse through the list on the website: alire.ada.dev/crates.
There is also a network graph view of the Alire ecosystem: here.
How do I start? #
The first beta release of Alire
was published a few days ago. Go to alire.ada.dev for instructions on how to install and use the tool.
from Hacker News https://ift.tt/3eh5hyM
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.