ralsina/tartrazine

Non-trivial dependencies should be optional

Closed this issue · 4 comments

I was quite confused to see docopt, stumpy_core, stumpy_png and stumpy_utils being installed with Tartrazine, shards that I'm familiar with that wouldn't make sense for a library 🤔. I then discovered the first is for using the shard as an application and the latter for extensions. Realistically such shards shouldn't be required dependencies given they aren't trivial for Tartrazine to operate. Usually if an extension is to be used, it's explicitly required in the user's code at which point it's their responsibility to add the relevant shard(s) as dependencies.

Unless your code uses the image formatter none of those libraries gets linked to your code AFAIK.

If they do, I will fix it.

AFAICS, it works properly.

I tested it with markterm, which links tartrazine but uses only the Ansi formatter

  • stumpy_png/stumpy_core don't link any external libraries
  • if you don't use the Png formatter, stumpy is not even built
  • docopt is only used by the tartrazine CLI binary, if you use tartrazine as a library it's not even built
  • the resulting binary has no stumpy symbols in it

This is the output of nm bin/tartrazine which does use the Png formatter and therefor has stumpy built into it:

image

And here is the output of nm bin/markterm which doesn't use the Png formatter and doesn't have any stumpy in it:

image

So, it's optional and only used when needed.

I'm aware that they are not included in the binary, that would be a separate issue. My point is that optional dependencies shouldn't be installed as if they are required. This principle goes well beyond Crystal/Shards and is widely accepted in the developer space.

Sorry, no. They are not installed anywhere except in the lib/ directory when building from source. AFAIK shards don' t provide support for "optional dependencies".

This costs the user nothing and makes exactly zero difference to anyone not using the Png writer.