Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain why a custom allocator is needed at start of the book #45

Open
ghost opened this issue Jul 20, 2021 · 2 comments
Open

Explain why a custom allocator is needed at start of the book #45

ghost opened this issue Jul 20, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 20, 2021

Hi, thanks for the book It is very helpful.

I don't get the rationale for having a custom allocator though, shouldn't it be explained at the start? Wouldn't default rust allocator be good for this?

@pliniker
Copy link
Member

Yes, thank you, it does seem I need to explain better in the text why I have taken this approach.

An explanation:

  • It is entirely valid to take a native rust std approach such as Rc/Arc. Many interpreter projects in Rust have done so.
  • The next level of complexity is to use something similar in API to Rc but that handles cycles and has a distinct collection phase, such as https://github.com/Manishearth/rust-gc/
  • In both the above situations, the std collections can be used.
  • I wanted to demonstrate building allocation, data structures and collection from the ground up so that the interested reader can understand the specific challenges and solutions that are experienced in Rust.
  • At the time of writing code, the default rust allocator and APIs were unstable and not yet suitable. The situation now might be different.

@ghost
Copy link
Author

ghost commented Jul 20, 2021

thanks for the explanation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant