kburkhart84
Firehammer Games
I'm familiar with all of these methods of saving data. However, I have not been able to find a nice full-fledged discussion on the merits of each of these, and what people have against certain ones. I will start off with what I know of them, and hopefully this sparks some opinions from other people.
JSON.....This has become a nice standard for data, and works great for anything that is getting sent over networks, etc... and Gamemaker has nice support for it as well. Compared to flat binary data, and even using token separated strings, JSON strings are typically quite longer, but in exchange you get something that is much closer to human-readable, and is a "standard" all over. With Gamemaker's built in support, you also get automatic destruction of maps and lists that are nested if you mark them properly simply by destroying the root ds_map.
DS strings...I'm referring to the strings you get with the read/write string functions for data structures. These strings are very much NOT human readable, and look almost like some sort of encryption, even though they aren't as far as I know. I have used these quite a bit anywhere that I don't care if you can understand the strings, and the support with Gamemaker is also great. This is a good way to go in my opinion if your data can easily be put into data structures or already is. You can also save multiple strings in the same file simply by adding a line ending to it. It seems I've seen somewhere that it is not recommended to use these strings, but I really don't know who said it and why that recommendation was made. Hopefully someone here can clarify if there is a good reason to NOT use them.
Token Separated Strings....these are strings with the data converted to string(from numerical values) and each one separated by a token character you choose(like ~ or | or & but can be whatever you want that won't be part of any of the actual stored strings, and can actually be multiple characters together too). From there, this data can be saved to text files. It is partially human readable, but less so than DS strings. However, they would have to know what order the data is being written to the string in to be able to take advantage of that. This method can work, and as far as strings go is going to be the smallest of the string methods, only being larger than binary files for the same data overall. And the functions you would need to make/find are actually pretty short(like 10 to 15 lines I think), so there isn't any massive coding needed to be done either. Although, you will need to make sure you put the data in the same order as you load it in. That last point applies for the other methods somewhat too, depending on how the data is originally stored.
Binary...this is going to be the most performant way generally, and also the harder way to work. With most of the data we are saving, this method isn't really very good in my opinion, simply because there are no performance issues with the other methods, and the data is usually so small to not matter even it is in text format. If we are going with something much bigger, like a file format for 3d models or similar, then binary could indeed be a much quicker option.
So, I'm hoping people will chime in as far as to what they prefer for different situations and why. I haven't seen any such discussion anywhere. And yes, I'm aware that in many cases, there are going to be multiple ways to get things done and it won't matter in the end what gets used, but like I said, I'm hoping to spark a discussion. Also, feel free to add ideas as well, along with pros/cons of those ideas.
JSON.....This has become a nice standard for data, and works great for anything that is getting sent over networks, etc... and Gamemaker has nice support for it as well. Compared to flat binary data, and even using token separated strings, JSON strings are typically quite longer, but in exchange you get something that is much closer to human-readable, and is a "standard" all over. With Gamemaker's built in support, you also get automatic destruction of maps and lists that are nested if you mark them properly simply by destroying the root ds_map.
DS strings...I'm referring to the strings you get with the read/write string functions for data structures. These strings are very much NOT human readable, and look almost like some sort of encryption, even though they aren't as far as I know. I have used these quite a bit anywhere that I don't care if you can understand the strings, and the support with Gamemaker is also great. This is a good way to go in my opinion if your data can easily be put into data structures or already is. You can also save multiple strings in the same file simply by adding a line ending to it. It seems I've seen somewhere that it is not recommended to use these strings, but I really don't know who said it and why that recommendation was made. Hopefully someone here can clarify if there is a good reason to NOT use them.
Token Separated Strings....these are strings with the data converted to string(from numerical values) and each one separated by a token character you choose(like ~ or | or & but can be whatever you want that won't be part of any of the actual stored strings, and can actually be multiple characters together too). From there, this data can be saved to text files. It is partially human readable, but less so than DS strings. However, they would have to know what order the data is being written to the string in to be able to take advantage of that. This method can work, and as far as strings go is going to be the smallest of the string methods, only being larger than binary files for the same data overall. And the functions you would need to make/find are actually pretty short(like 10 to 15 lines I think), so there isn't any massive coding needed to be done either. Although, you will need to make sure you put the data in the same order as you load it in. That last point applies for the other methods somewhat too, depending on how the data is originally stored.
Binary...this is going to be the most performant way generally, and also the harder way to work. With most of the data we are saving, this method isn't really very good in my opinion, simply because there are no performance issues with the other methods, and the data is usually so small to not matter even it is in text format. If we are going with something much bigger, like a file format for 3d models or similar, then binary could indeed be a much quicker option.
So, I'm hoping people will chime in as far as to what they prefer for different situations and why. I haven't seen any such discussion anywhere. And yes, I'm aware that in many cases, there are going to be multiple ways to get things done and it won't matter in the end what gets used, but like I said, I'm hoping to spark a discussion. Also, feel free to add ideas as well, along with pros/cons of those ideas.