How do I use libraries manually?

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Feb 5 22:43:24 UTC 2019


On Tue, Feb 05, 2019 at 08:39:50PM +0000, Murilo via Digitalmars-d-learn wrote:
[...]
> Thank you very much, I will try what you just explained. And yes I
> would really appreciate it if people would make single file libraries
> that I can just import as if it were any other .d file.

That only works up to a certain point, though.  Past a certain level of
complexity, you have no choice but to split your code up into multiple
files. Otherwise it becomes a maintenance nightmare, not to mention
having the high probability of unwanted coupling between pieces of code
that really should be separated from each other, which usually leads to
code smells and hard-to-find bugs.

Nevertheless, IMO the best libraries are those where you can just unzip
the source files into a subdirectory in your workspace, add a few -I's,
and they will Just Work(tm).  Overly-heavyweight libraries or libraries
with too many recursive dependencies are not only a pain to work with
outside an automatic dependency system like dub, they also have a high
tendency to instability over time (i.e. after 5 years nothing compiles
anymore because one or more dependencies have broken behind your back
and/or the earlier version(s) of the code that used to work no longer
exist / cannot be easily found again).  More and more, I'm finding that
copying the darned code into your source tree directly, rather than have
network dependencies that are here today and may suddenly cease existing
tomorrow with no warning, is the key to code longevity.


T

-- 
Obviously, some things aren't very obvious.


More information about the Digitalmars-d-learn mailing list