i love using buffers for networking and datastores :-) even if it might be a micro optimization they make me feel good so i just use them anyways lmaoaoaoaoaooa
5:08 Unsigned and signed should be swapped. Unsigned takes only positive inputs, and will handle overflows and negative inputs by taking the modulo of the input number with its maximum number + 1. On the other hand, signed numbers allows numbers to have a negative sign. Overflowing a signed integer is trickier, as it involves first taking the modulo with max + 1 then using two's complement with the number in binary. Roblox handles overflows automatically.
@@stewiepfing539 To clarify what I meant: Under the unsigned comments should be buffer.writeu and under the signed comments should be buffer.writei, not the other way around. It's a super small mistake.
I would *really* advise against using these because of how much of a micro-optimization they are unless it involves networking or serialization, and even then, only really consider it if your game or system is having problems in the first place.
Very nice library, I would probably use this in the future when I'm developing more complex games. Also this library is very similar to the one I used in Unity clicker games called PlayerPrefs which function similarly, however there were some limitations for data types and as far as I know, they couldn't store more than 1 piece of data in each variable.
buffers should be used for compacting data that is sent over the network or you have big arrays using buffers for variables are unnecessary unless your going to send them to another script with a remote event (especially unreliableremoteEvents that have a 900 byte payload limit)
while I was watching this video I decided to go outside where the kittens were, I paused the video, but my headphones landed on the space bar, so the video was actually playing at 2x speed, I skipped most of the video because of this
How would I use this in a datastore though? using the read functions just returns the original string. Sorry if this is a dumb question, I just haven't fully understood bitbuffers yet.
@@epixerty Just because you can use it everywhere doesn't mean you should. Variables without buffers allocate memory efficiently automatically. Buffers need the fixed amount of memory, and a little more to manage the buffer itself. Additionally, the steps to read & write buffers adds complexity to your code. local variable = 16 -- 4 bytes are used print(variable) -- Outputs: 16 local mbuffer = buffer.create(4) -- Allocates 4 bytes + overhead memory for buffer management buffer.writei32(mbuffer, 0, 16) -- Writes an integer (4 bytes) local value = buffer.readi32(mbuffer, 0) print(value) -- Outputs: 16 A better use case for buffers would be in data storage (datastores, memorystore) or networking, where they can handle large volumes of data efficiently.
while this is great for Basics, can you make a more in depth video on how to use this for mass data compression and decompression? concept is to automate it completely by detecting the type of data, compress it and map the order somewhere for decompression
You could use for loops that take each ID of a table, adds it to the buffer, and continues. To get it back, take the length of the buffer, get a for loop, and pull each data out and put it in a table. I'm not fully sure but this should work
i have tried to use this, but its hard. you need to think how big is the value, what type, and what index is the buffer, is it signed, unsigned, integer, negative? if it big value, is it 8,16? all these need to think. unless you have good understanding on how your game value is, dont use it. but the good thing is, we can have like the value cap to what the byte is. like if i use 16bit the number will be in 0-65536 and if i use this for my character coins, it wont go beyond that. so maybe its good for security? in case someone hack and want to set it to 9999999 which is not possible in 16bit.
@@Juju-dz5qt heard of Actor's before but haven't really looked into them. I'm not sure what you mean by "parallel roblox", do you mean connecting functions with the :ConnectParallel() function? Also not sire what you mean by OOP.
Do you guys like buffers?
Nah idk, i wil think about it but i wont be needing buffers, my game is currently using under 1 mb of ram (It have at least 50 scripts)
@@Jackinbox19001 it's useful in datastores tho, if i'm not wrong
@@kekulusskek How?
@Jackinbox19001, you can only store so much in a datastore key, so to conserve space you can compress it using buffers.
@@enpiesie give me an example code
This is a microoptimization that you probably won't need in like 99% of use cases. Unless you're working with big data or something
i love using buffers for networking and datastores :-)
even if it might be a micro optimization they make me feel good so i just use them anyways lmaoaoaoaoaooa
still very useful. and micro optimisations add up to something big so mine as well it takes like 10 minutes
The video is very informative and good but the only problem is that sometimes you're saying "bits" instead of "bytes".
@GattoBINwhat's wrong with you, he just corrected him
@GattoBIN respectfully they corrected vital information that if not corrected could cause major confusion in new programmers
@GattoBINwow angry much. The video got very important information wrong. What's wrong with correcting it for the sake of other people
Bits and bytes in 8 times difference,so it is very important,thanks for comment jodio8071,and Gatto dont be govnato@GattoBIN
@@ana_s read the reply above you
5:08 Unsigned and signed should be swapped. Unsigned takes only positive inputs, and will handle overflows and negative inputs by taking the modulo of the input number with its maximum number + 1. On the other hand, signed numbers allows numbers to have a negative sign. Overflowing a signed integer is trickier, as it involves first taking the modulo with max + 1 then using two's complement with the number in binary. Roblox handles overflows automatically.
thats what I said 😭😭
@@stewiepfing539 To clarify what I meant: Under the unsigned comments should be buffer.writeu and under the signed comments should be buffer.writei, not the other way around. It's a super small mistake.
@@stewiepfing539 you wrote the opposite functions for what the code comments were saying
modulo? dude it doesn't use modulo it's just how binary works
I would *really* advise against using these because of how much of a micro-optimization they are unless it involves networking or serialization, and even then, only really consider it if your game or system is having problems in the first place.
To be honest, on the other side using this make scripting/coding looks more complicated than usual
Very nice library, I would probably use this in the future when I'm developing more complex games. Also this library is very similar to the one I used in Unity clicker games called PlayerPrefs which function similarly, however there were some limitations for data types and as far as I know, they couldn't store more than 1 piece of data in each variable.
I like to gamble. how to gamble in studio
math.random 🗣🗣🗣🔥🔥🔥
print(Random.new():NextInteger(1, math.huge()))
Random:NextInteger
math.random Fr 🗣🗣🔥🔥🔥
Random.new():NextInteger() 🤓
W stewiepfing as always!
buffers should be used for compacting data that is sent over the network or you have big arrays
using buffers for variables are unnecessary unless your going to send them to another script with a remote event (especially unreliableremoteEvents that have a 900 byte payload limit)
im gonna assume buffers will be super useful in saving large inventories to the DataStores
Ty :)
while I was watching this video I decided to go outside where the kittens were, I paused the video, but my headphones landed on the space bar, so the video was actually playing at 2x speed, I skipped most of the video because of this
Watch it again💀💀
Cool story bro.
Maybe, you can create a module with a buffer library?
Very cool stuff, though the back and forth and the random pauses make it sound so confusing
just like coding with assembly
Thank you for noticing me about buffers 😄❤️
How would I use this in a datastore though? using the read functions just returns the original string. Sorry if this is a dumb question, I just haven't fully understood bitbuffers yet.
You can use buffer.tostring to save the data to a string, and buffer.fromstring to convert the saved string back to a buffer.
Cool video!
guys i think buffer needs a nerf🥶🥶 shid so cold
this is probably being used in a really specific usecase, nice video btw
Networking for sure
@@epixerty yea, you can use it everywhere but its a bit overkill haha
@@epixerty Just because you can use it everywhere doesn't mean you should. Variables without buffers allocate memory efficiently automatically. Buffers need the fixed amount of memory, and a little more to manage the buffer itself.
Additionally, the steps to read & write buffers adds complexity to your code.
local variable = 16 -- 4 bytes are used
print(variable) -- Outputs: 16
local mbuffer = buffer.create(4) -- Allocates 4 bytes + overhead memory for buffer management
buffer.writei32(mbuffer, 0, 16) -- Writes an integer (4 bytes)
local value = buffer.readi32(mbuffer, 0)
print(value) -- Outputs: 16
A better use case for buffers would be in data storage (datastores, memorystore) or networking, where they can handle large volumes of data efficiently.
it's good for networking
@@epixerty don't use buffers on everything
while this is great for Basics, can you make a more in depth video on how to use this for mass data compression and decompression?
concept is to automate it completely by detecting the type of data, compress it and map the order somewhere for decompression
Basics help you in complex stuff, you can also read roblox documentations about it.
You could use for loops that take each ID of a table, adds it to the buffer, and continues. To get it back, take the length of the buffer, get a for loop, and pull each data out and put it in a table. I'm not fully sure but this should work
hardly the easiest way to save memory. i'd rather down sample one 1024 image to 512 and prob save more than this with a lot less work!
Umm actually the vid was about numbers and strings🤓
@@RyanEXElol True. You should do everything in your power to save memory.
O M G yes thank you!! 🙏🏻
Why don’t people do this more often?
can buffers be used in datastores instead of tables?
Yes
cool
i have tried to use this, but its hard. you need to think how big is the value, what type, and what index is the buffer, is it signed, unsigned, integer, negative?
if it big value, is it 8,16? all these need to think. unless you have good understanding on how your game value is, dont use it. but the good thing is, we can have like the value cap to what the byte is. like if i use 16bit the number will be in 0-65536 and if i use this for my character coins, it wont go beyond that. so maybe its good for security? in case someone hack and want to set it to 9999999 which is not possible in 16bit.
bro just check if the value passes 65k lmao why you would user buffer for that xd
and it just will be possible to exploit your game if you let them to
hi
11-12 Hours, lol!
📝
im sorry to be thet guy but how tf do you find these secret stuff?
Its just that no-one uses it and can be easily replaced by the more simpler option which is a variable.
devforum and roblox's documentation
We studied about these in high school lol
@noobzyx5700 Unless you are making a truly large scale game.
@@noobzyx5700what do you mean replaced by variable
YOU SAID 3.1415927 INSTEAD OF 3.1415926
Thats what I meant in the video, single floating point numbers dont have the precision like double precision floating point ones
3.14159265…
You’d round up to 7 if you’re only going up to that digit.
this is cool but not really worth it or needed in this day and age
lol
dont do this
Why
@@RyanEXElol Its rage bait
so apart from buffer, there is no other way to optimise your code?
Obv, no
@@tantank im convinced there is, we just don't know it yet.
we are in this together amigo!
Actor's, parallela roblox, OOP etc
@@Noon1263prob have other way's what i dont know
@@Juju-dz5qt heard of Actor's before but haven't really looked into them.
I'm not sure what you mean by "parallel roblox", do you mean connecting functions with the :ConnectParallel() function?
Also not sire what you mean by OOP.