BlobString vs FixedString vs NativeString?

Scenario: I have an immutable blob of data that consists of a few integers, enums, and a few string values. To store these string values, however, are a few options: BlobString, NativeString, and FixedString

My question is how to determine which to use?

BlobStrings are variable sized and theoretically immutable.
So far when comparing FixedStrings and NativeStrings, at first glance, FixedStrings seem more readable and elaborated upon. Some clarifications here would be nice. If there are no differences then perhaps NativeStrings should be deprecated if no longer needed.

In regards to BlobData, is there a reason not to use FixedStrings besides the size limitations?

So far from my findings, if I want to actually use the string and have burstable code, then FixedStrings are the way to go. This however is not true when wanting to debug said FixedString in a job. The console complains about the Log method not running on main thread.

2 Likes

Hi there,

Can you please share your experience dealing with strings with burst code in jobs? Does they work without issues? etc

No. There are a lot of caveats you need to deal with.
For now, the things you CAN do, is check with FixedStrings whether or not a FixedString matches another. However, as expected you are missing most of the string aspects that make them more viable for a web communication aspect, Regex matching, toUpper, Appending (sorta), etc.

So some options of what I have done, is burst do logic on everything that is needed, then with that logic done, in a non busted job or on main thread, handle string communications. It is not the end desired effect, but I still keep the performance components of iterating through all my relevant entities. I’m hoping that strings (while reference types) are semi converted to a value type with burst later on or FixedStrings gain more features.

THE ABSOLUTE needed aspect is for the internal packages to PICK a standard and lean into it, rather than introducing BlobStrings, NativeStrings, FixedStrings, StringStrings, DimensionalVoidStrings, StringsFromTheUnderworld, etc.

FixedStrings are plenty and more clear. They should be added upon.

2 Likes

Thank you for your detailed reply,
So its right that we can use FixedString in a bursted jobs.

And i also looked at few extension methods like IndexOf, Contains etc which means it can be used for a words/scrabble game?

What should i use for saving english words of varying length, NativeList or NativeList

NativeString are not even documented anymore, FixedString should be used in almost all cases, BlobString is the alternative for when dealing with Blobs

3 Likes

Thank you for all of your help, ill now work on FixedString based example and see how it goes.

Even with Blobs I use fix strings as there is nothing you can really do with blob strings in burst

3 Likes