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.
They are useful for heavy algorithm, networking and serialization but it's kinda useless for anything else cause 99.9% of the devices can handle a few extra bytes fine
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.
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
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 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
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.
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.
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.
Its mostly used for micro optimization, things like huge datas and etc etc, thats the reason, theres not alot of roblox games that have huge amounts of memory/data that needs to be compressed
@@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.
@@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.
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
I'm late but as per the recent editable images update, you can read and write pixels into the images by using a unsigned byte buffer (8 but u)
Even still it's good practice do be doing it this way
@@zilezia not at all.
The video is very informative and good but the only problem is that sometimes you're saying "bits" instead of "bytes".
cry about that is a nice video 10/10
@@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
@@pyxelbuh You got a point, true
@@GattoBINwow angry much. The video got very important information wrong. What's wrong with correcting it for the sake of other people
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
They are useful for heavy algorithm, networking and serialization but it's kinda useless for anything else cause 99.9% of the devices can handle a few extra bytes fine
im using this for a loading screen, and its almost twice as fast now.
They are usefull for chunking games and creating render distance algorithms, they are very performant heavy sometimes
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.
Thank you for notifyng me about buffers 😄❤️
To be honest, on the other side using this make scripting/coding looks more complicated than usual
Very cool stuff, though the back and forth and the random pauses make it sound so confusing
Maybe, you can create a module with a buffer library?
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.
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 :)
W stewiepfing as always!
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
@@InfinityChances_ I wouldn't use for loops unless it's truly unavoidable. Better approach would be to use a meta table and module script setup
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() 🤓
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.
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.
can buffers be used in datastores instead of tables?
Yes
Cool video!
just like coding with assembly
guys i think buffer needs a nerf🥶🥶 shid so cold
O M G yes thank you!! 🙏🏻
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.
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
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
Why don’t people do this more often?
Its mostly used for micro optimization, things like huge datas and etc etc, thats the reason, theres not alot of roblox games that have huge amounts of memory/data that needs to be compressed
11-12 Hours, lol!
📝
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.
cool
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.
hi
this is cool but not really worth it or needed in this day and age
lol
dont do this
Why
@@RyanEXElol Its rage bait
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