Hey Ryan, thanks for all the work. I am noticing that the AsyncRandom class in Random.mo doesn’t have all of the fun methods such as nat64, nat64Range, natRange, intRange, even though it’s in the documentation https://internetcomputer.org/docs/motoko/core/Random, will this be added soon?
Is there a way to add initial capacity to List like Buffer had. Many times with my code i have an item count estimate/upper bound/exact number, so i would like to be able to use that for efficiency
Thank you for pointing this out! I opened this PR to add the missing methods.
There currently isn’t a way to specify an initial capacity for List (same as with the original Vector). For situations where performance is critical and the maximum size is known beforehand, using a var-array with optional values is going to be the most efficient option. For example:
We considered adding a wrapper data structure around this pattern into the standard library but decided that this would be better suited for an external Mops package.
It’s worth noting that it is possible to continue using Buffer and the other original data structures by importing both base and core into a project. The goal is to give enough time for the package ecosystem to fill in the gaps before fully dropping support for the original base library.
We were thinking of doing that (providing a reserve function) but in the end decided against it. The problem is that List has a shrinking logic to free unused space if the List shrinks. Reserving large unused space would interfere with that logic because the logic would try to shrink it again. We didn’t see the performance gain as significant enough to justify the additional complexity. List should be efficient enough even without reservation.
Are there any types that are getting deprecated and if so is there a legacy library we will be able to import ? Are there clear instructions regarding this somewhere ?
I’ve been working on a larger project for several months using the “old” base library. Would it be advisable to upgrade to the new one at this point, or should we continue using the existing version?
We encourage switching to the new core package if possible. This will reduce the complexity in the long run when we eventually drop support for the original base library.
Including both base and core as parallel dependencies is one way to gradually make this transition. LLMs are also beginning to pick up the core package and could be useful (with caution) in combination with the migration guide.
Let me know if you run into any issues if you end up migrating in case we can assist.
Thanks for your response. I’m in the final weeks of the project, with a due date at the end of August. I will try to migrate the project. It consists of four different Motoko canisters that work together for various tasks, such as backend services for task management, documentation, user management, indexing, time tracking, and file storage.
I’m mostly done, but there are still a few small functions that the frontend needs which have to be added.
Today, I tried refactoring a module and realized that migrating will require a significant amount of work. I use OrderedMap and Buffer extensively, and several inter-canister calls from the module functions will also need to be refactored due to the new OrderedMap behavior.