Thread overview
Default allocator of container plus element type
Oct 05, 2017
Nordlöw
Oct 05, 2017
Nordlöw
Oct 05, 2017
Moritz Maxeiner
Oct 05, 2017
Jacob Carlborg
Oct 05, 2017
rikki cattermole
October 05, 2017
Would it be possible to set up a mapping (either formal or informal) of each typical container (such as array, linked-list etc) plus element type to a suitable default allocator? And perhaps add this to the documentation of `std.experimental.allocator`?

I currently get the feeling that most programmers have no idea at all what allocator to choose for each given combination of container and element type they want to use.
October 05, 2017
On Thursday, 5 October 2017 at 11:35:30 UTC, Nordlöw wrote:
> Would it be possible to set up a mapping (either formal or informal) of each typical container (such as array, linked-list etc) plus element type to a suitable default allocator? And perhaps add this to the documentation of `std.experimental.allocator`?

To clarify I'm saying that, D's "design by introspection" could help out here.

> I currently get the feeling that most programmers have no idea at all what allocator to choose for each given combination of container and element type they want to use.

Of course, I still think that `std.experimental.allocator` is one of Phobos' most brilliant modules, Andrei.
October 05, 2017
On Thursday, 5 October 2017 at 11:35:30 UTC, Nordlöw wrote:
> Would it be possible to set up a mapping (either formal or informal) of each typical container (such as array, linked-list etc) plus element type to a suitable default allocator? And perhaps add this to the documentation of `std.experimental.allocator`?
>
> I currently get the feeling that most programmers have no idea at all what allocator to choose for each given combination of container and element type they want to use.

I'm skeptical towards such a mapping being universally applicable (or even applicable in the majority of cases), because the best allocation strategy for a specific use case is not determined solely by (container,element), it's (at least) (container,element,usage scenario, operating system, hardware) - and I'm sure I forgot some.
Realistically, if you care about picking the best memory allocator for your use case, imho you should write your application to be agnostic to the allocator used and then benchmark it with a bunch of different allocators.
October 05, 2017
On 2017-10-05 13:35, Nordlöw wrote:
> Would it be possible to set up a mapping (either formal or informal) of each typical container (such as array, linked-list etc) plus element type to a suitable default allocator? And perhaps add this to the documentation of `std.experimental.allocator`?
> 
> I currently get the feeling that most programmers have no idea at all what allocator to choose for each given combination of container and element type they want to use.

If the programmer have no idea what allocator to choose, then I would say they should use the built-in array and associative array.

-- 
/Jacob Carlborg
October 05, 2017
On 05/10/2017 12:35 PM, Nordlöw wrote:
> Would it be possible to set up a mapping (either formal or informal) of each typical container (such as array, linked-list etc) plus element type to a suitable default allocator? And perhaps add this to the documentation of `std.experimental.allocator`?
> 
> I currently get the feeling that most programmers have no idea at all what allocator to choose for each given combination of container and element type they want to use.

Most developers should never need to touch or swap out allocators.
It can be a performance optimization for the more advanced users.

Let container makers decide a good default for /their/ implementation.

Allocators solve a problem that very few developers actually have. Contrary to popular belief. The default GC allocator is probably ok for most people. I'm happy with it for SPEW[0] and it heavily uses allocators.

[0] https://github.com/Devisualization/spew