Binary 가 왜 필요한가
JSON 은 사람이 읽기 쉽고, 디버깅 쉽고, 느려. 고빈도 또는 compact message — multiplayer 게임 position, market tick, sensor stream — 엔 JSON tax 가 bandwidth 비용과 dropped frame 으로 나타나. binary 로 payload size 60-80% 자르고 parse time 은 더 짤려. 브라우저가 binary 네이티브 지원, 비용은 encoder/decoder 직접 짜는 거.
DataView 가 친구
DataView 는 ArrayBuffer 의 byte offset 에서 typed value 읽고 써. endianness 명시적으로 픽 (거의 항상 little-endian 으로 true 넘겨), 같은 wire format 이 JS 클라와 Python 서버 사이 작동하게. 알려진 offset 으로 여러 field 를 한 buffer 에 합치면 hand-rolled binary protocol 완성.
MessagePack 또는 Protobuf 골라야 할 때
Hand-rolled binary 는 field 적은 tightly-defined message 엔 ok. protocol 자라면 — schema evolution, optional field, nested structure — MessagePack (drop-in JSON 대체, 30% 작아, schema 없음) 또는 Protobuf (best compression, .proto 정의 필요) 손 가. Track 5 에서 다뤄.