The EASIEST Way To Optimize Your Code! | Roblox Studio

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ย. 2024

ความคิดเห็น • 129

  • @stewiepfing539
    @stewiepfing539  หลายเดือนก่อน +28

    Do you guys like buffers?

    • @Jackinbox19001
      @Jackinbox19001 หลายเดือนก่อน +2

      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)

    • @kekulusskek
      @kekulusskek หลายเดือนก่อน +3

      ​@@Jackinbox19001 it's useful in datastores tho, if i'm not wrong

    • @Jackinbox19001
      @Jackinbox19001 หลายเดือนก่อน +1

      @@kekulusskek How?

    • @enpiesie
      @enpiesie หลายเดือนก่อน +1

      ​@Jackinbox19001, you can only store so much in a datastore key, so to conserve space you can compress it using buffers.

    • @Jackinbox19001
      @Jackinbox19001 หลายเดือนก่อน

      @@enpiesie give me an example code

  • @defenestratorr
    @defenestratorr หลายเดือนก่อน +24

    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

    • @ivymuncher
      @ivymuncher 21 วันที่ผ่านมา +2

      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

    • @swordlegend3256
      @swordlegend3256 5 วันที่ผ่านมา

      still very useful. and micro optimisations add up to something big so mine as well it takes like 10 minutes

  • @jodio8071
    @jodio8071 หลายเดือนก่อน +70

    The video is very informative and good but the only problem is that sometimes you're saying "bits" instead of "bytes".

    • @bruhblox_
      @bruhblox_ หลายเดือนก่อน +35

      ​​@GattoBINwhat's wrong with you, he just corrected him

    • @pyxelbuh
      @pyxelbuh หลายเดือนก่อน +18

      @GattoBIN respectfully they corrected vital information that if not corrected could cause major confusion in new programmers

    • @ana_s
      @ana_s หลายเดือนก่อน +5

      ​@GattoBINwow angry much. The video got very important information wrong. What's wrong with correcting it for the sake of other people

    • @mason228x
      @mason228x หลายเดือนก่อน

      Bits and bytes in 8 times difference,so it is very important,thanks for comment jodio8071,and Gatto dont be govnato​@GattoBIN

    • @--Brick--
      @--Brick-- หลายเดือนก่อน +2

      @@ana_s read the reply above you

  • @theosiris4179
    @theosiris4179 หลายเดือนก่อน +14

    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
      @stewiepfing539  หลายเดือนก่อน +1

      thats what I said 😭😭

    • @theosiris4179
      @theosiris4179 หลายเดือนก่อน +6

      @@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.

    • @exolyne.
      @exolyne. หลายเดือนก่อน

      ​@@stewiepfing539 you wrote the opposite functions for what the code comments were saying

    • @Wyrmver
      @Wyrmver หลายเดือนก่อน

      modulo? dude it doesn't use modulo it's just how binary works

  • @ozzy1987
    @ozzy1987 หลายเดือนก่อน +2

    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.

  • @tiltedblock
    @tiltedblock หลายเดือนก่อน +2

    To be honest, on the other side using this make scripting/coding looks more complicated than usual

  • @Runtem
    @Runtem 10 วันที่ผ่านมา

    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.

  • @theoverlord3371
    @theoverlord3371 หลายเดือนก่อน +16

    I like to gamble. how to gamble in studio

    • @4EVERACE
      @4EVERACE หลายเดือนก่อน +11

      math.random 🗣🗣🗣🔥🔥🔥

    • @CheeseY420
      @CheeseY420 หลายเดือนก่อน

      print(Random.new():NextInteger(1, math.huge()))

    • @Mono_DevRBX
      @Mono_DevRBX หลายเดือนก่อน

      Random:NextInteger

    • @로좋
      @로좋 หลายเดือนก่อน +7

      math.random Fr 🗣🗣🔥🔥🔥

    • @PixelOyuncuZ
      @PixelOyuncuZ หลายเดือนก่อน

      Random.new():NextInteger() 🤓

  • @KashTheKingYT
    @KashTheKingYT หลายเดือนก่อน +4

    W stewiepfing as always!

  • @lalaly2011
    @lalaly2011 หลายเดือนก่อน +1

    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)

    • @rrb101567
      @rrb101567 หลายเดือนก่อน +1

      im gonna assume buffers will be super useful in saving large inventories to the DataStores

  • @Hanselkek
    @Hanselkek หลายเดือนก่อน +3

    Ty :)

  • @rocketpadgamer
    @rocketpadgamer หลายเดือนก่อน +1

    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

    • @RyanEXElol
      @RyanEXElol หลายเดือนก่อน

      Watch it again💀💀

    • @noxinabox3506
      @noxinabox3506 หลายเดือนก่อน

      Cool story bro.

  • @Divine706
    @Divine706 หลายเดือนก่อน +1

    Maybe, you can create a module with a buffer library?

  • @Dr_mafario
    @Dr_mafario หลายเดือนก่อน +1

    Very cool stuff, though the back and forth and the random pauses make it sound so confusing

  • @Lobster305
    @Lobster305 หลายเดือนก่อน +1

    just like coding with assembly

  • @로좋
    @로좋 หลายเดือนก่อน +1

    Thank you for noticing me about buffers 😄❤️

  • @Wayne2.
    @Wayne2. หลายเดือนก่อน +1

    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.

    • @builderdolphin
      @builderdolphin 15 วันที่ผ่านมา

      You can use buffer.tostring to save the data to a string, and buffer.fromstring to convert the saved string back to a buffer.

  • @finjer5018
    @finjer5018 หลายเดือนก่อน +3

    Cool video!

  • @Avysilvasan
    @Avysilvasan หลายเดือนก่อน

    guys i think buffer needs a nerf🥶🥶 shid so cold

  • @fayking
    @fayking หลายเดือนก่อน +4

    this is probably being used in a really specific usecase, nice video btw

    • @abodReal
      @abodReal หลายเดือนก่อน

      Networking for sure

    • @fayking
      @fayking หลายเดือนก่อน

      @@epixerty yea, you can use it everywhere but its a bit overkill haha

    • @theosiris4179
      @theosiris4179 หลายเดือนก่อน +1

      ​@@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.

    • @lumalumii
      @lumalumii หลายเดือนก่อน

      it's good for networking

    • @lumalumii
      @lumalumii หลายเดือนก่อน

      ​@@epixerty don't use buffers on everything

  • @Kitsune_Dev
    @Kitsune_Dev หลายเดือนก่อน +2

    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

    • @RyanEXElol
      @RyanEXElol หลายเดือนก่อน

      Basics help you in complex stuff, you can also read roblox documentations about it.

    • @InfinityChances_
      @InfinityChances_ หลายเดือนก่อน

      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

  • @furroy
    @furroy หลายเดือนก่อน +4

    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!

    • @RyanEXElol
      @RyanEXElol หลายเดือนก่อน +3

      Umm actually the vid was about numbers and strings🤓

    • @robocat168
      @robocat168 หลายเดือนก่อน +1

      @@RyanEXElol True. You should do everything in your power to save memory.

  • @Kitsune_Dev
    @Kitsune_Dev หลายเดือนก่อน

    O M G yes thank you!! 🙏🏻

  • @TheProgammerGamer
    @TheProgammerGamer 4 วันที่ผ่านมา

    Why don’t people do this more often?

  • @viperdune
    @viperdune หลายเดือนก่อน +1

    can buffers be used in datastores instead of tables?

    • @olicon1000
      @olicon1000 หลายเดือนก่อน +1

      Yes

  • @MarzFromMars
    @MarzFromMars หลายเดือนก่อน

    cool

  • @garytodak
    @garytodak หลายเดือนก่อน

    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.

    • @passarodeterno
      @passarodeterno วันที่ผ่านมา

      bro just check if the value passes 65k lmao why you would user buffer for that xd

    • @passarodeterno
      @passarodeterno วันที่ผ่านมา

      and it just will be possible to exploit your game if you let them to

  • @ablueslime
    @ablueslime หลายเดือนก่อน

    hi

  • @gamingwithlilabe3711
    @gamingwithlilabe3711 หลายเดือนก่อน +1

    11-12 Hours, lol!

  • @salmanizzadin
    @salmanizzadin หลายเดือนก่อน

    📝

  • @8tan200
    @8tan200 หลายเดือนก่อน +1

    im sorry to be thet guy but how tf do you find these secret stuff?

    • @noobzyx5700
      @noobzyx5700 หลายเดือนก่อน +3

      Its just that no-one uses it and can be easily replaced by the more simpler option which is a variable.

    • @lumalumii
      @lumalumii หลายเดือนก่อน +2

      devforum and roblox's documentation

    • @kryptonnslaxx6378
      @kryptonnslaxx6378 หลายเดือนก่อน

      We studied about these in high school lol

    • @nanni5230
      @nanni5230 หลายเดือนก่อน

      ​@noobzyx5700 Unless you are making a truly large scale game.

    • @windy6191
      @windy6191 หลายเดือนก่อน

      @@noobzyx5700what do you mean replaced by variable

  • @marcoorozco9420
    @marcoorozco9420 หลายเดือนก่อน

    YOU SAID 3.1415927 INSTEAD OF 3.1415926

    • @stewiepfing539
      @stewiepfing539  หลายเดือนก่อน +2

      Thats what I meant in the video, single floating point numbers dont have the precision like double precision floating point ones

    • @erd404
      @erd404 หลายเดือนก่อน

      3.14159265…
      You’d round up to 7 if you’re only going up to that digit.

  • @lembarkii8669
    @lembarkii8669 หลายเดือนก่อน

    this is cool but not really worth it or needed in this day and age

  • @tipic_faker4166
    @tipic_faker4166 หลายเดือนก่อน

    lol

  • @I_pvn
    @I_pvn หลายเดือนก่อน +2

    dont do this

    • @RyanEXElol
      @RyanEXElol หลายเดือนก่อน +1

      Why

    • @stewiepfing539
      @stewiepfing539  หลายเดือนก่อน

      ​@@RyanEXElol Its rage bait​

  • @Noon1263
    @Noon1263 หลายเดือนก่อน

    so apart from buffer, there is no other way to optimise your code?

    • @tantank
      @tantank หลายเดือนก่อน +2

      Obv, no

    • @Noon1263
      @Noon1263 หลายเดือนก่อน

      @@tantank im convinced there is, we just don't know it yet.
      we are in this together amigo!

    • @Juju-dz5qt
      @Juju-dz5qt หลายเดือนก่อน

      Actor's, parallela roblox, OOP etc

    • @Juju-dz5qt
      @Juju-dz5qt หลายเดือนก่อน

      ​@@Noon1263prob have other way's what i dont know

    • @Noon1263
      @Noon1263 หลายเดือนก่อน

      @@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.