Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the Loki library not more widely used?

Tags:

c++

boost

loki

The Loki library implements some very widely used concepts (smart pointer, visitor, factory, etc.). The associated book "Modern C++ Design" is often mentioned, but the library itself is not widely used. Why is that?

Most developers seem to prefer Boost. In particular, why do people often decide to use Boost's smart pointers rather than Loki's?

like image 450
Frank Avatar asked Feb 27 '10 16:02

Frank


4 Answers

Loki is a research/proof-of-concept sort of thing. Alexandrescu pushes new ideas, other people adopt those for real world. Also boost::shared_ptr is almost literally in TR1.

like image 90
Nikolai Fetissov Avatar answered Nov 06 '22 08:11

Nikolai Fetissov


Loki's suffers from being a good library touching on several functional areas (template metaprogamming support with a few specific applications: smart pointers, singletons, function objects, scope guards etc.), whereas boost is a collection of many libraries typically exhaustively covering each functional area and much more highly tuned for portability (first).

When 9 birds out of 10 can be killed with the same stone, many people just start with boost and fill in the gaps with third party libraries. It's very hard to compete with boost if you overlap. Because you won't overlap with much of boost, people will download/install boost anyway to get the other functionality, so unless you nail an area that boost is weak at - and the difference is significant to the project, they'll "settle" for boost there too.

Further, Alexandrescu made repeated attempts to get Loki included in boost, and some of the key boost authors just weren't cooperative. My personal view is that they want the more complete but much less user-friendly MPL to have more "market share": as authors of the library and the hard-copy books that are the only decent documentation (in stark contrast with most other boost libraries which have excellent online documentation), they do quite well out of this.

If anyone is offended by and disagrees with this analysis, I'm all ears.

Another practical issue with extremely parameterised code is that in large projects where different developers/teams work independently, they'll often end up using subtly different instantiations of the same template pretty arbitrarily. This makes it harder to pass values between those subsystems: the receiver may need to:

  • be parameterised (i.e. templated, and hence inline, which introduces compilation dependencies and slower builds in enterprise-scale systems)
  • provide some minimal coverage for all possible instantiations (e.g. checking error codes and expecting/handling exceptions)
  • working through some compile-time to run-time hand-over based on an abstract base accessor with implementations for each instantiation) which compromises some of the performance benefits of parameterisation

This is all possible, but it takes a great programmer to navigate the terrain.

like image 38
Tony Delroy Avatar answered Nov 06 '22 09:11

Tony Delroy


You want to use a library that the next programmer is going to know and that is going to be well supported in the future - so you pick a major lib. Because it's a major lib lots of people use it, so it becomes the default choice.

like image 12
Martin Beckett Avatar answered Nov 06 '22 10:11

Martin Beckett


I actually prefer Loki's way of doing things and I have contributed to Loki myself a Decorator pattern which now sits in the tracker because the project as far as I know is no longer maintained.
I use boost shared_pointer just because it will be the standard very soon, I may dislike the fact that I can't customize it to act exactly the way I want it to act but I have to live with it.
Usage of the standard library is important as it keeps the code maintainable by other programmers. If it's open source and you want to experiment go ahead and use Loki. No one is stopping you.
Actually Windows Vista uses some of Loki's features.
I am guessing they are not using the redundant implementations of smart pointers and visitors.

like image 7
the_drow Avatar answered Nov 06 '22 09:11

the_drow