BattlefyBlogHistoryOpen menu
Close menuHistory

Streams are weirder than you think

Ronald Chen April 18th 2022

Streams are a simple concept, but they are actually really weird if think about it.

What is a stream?

Img

A stream is a sequence of elements. An example of a stream is file, where each element is a byte.

Element type is weird

Element types could be…

Reading a stream is weird

The reader of a stream only see a sequence of elements. Something else determines the order.

Reading a stream could…

  • …be non-destructive from “start” to “end” is the same as reading a file
  • …read “oldest element” when stream is an queue
  • …read “element last written” when stream is a stack
  • …read “least used element” when stream is a least recently used cache
  • …trigger I/O as the internal batch runs out of data
  • …block the thread as it waits for more data
  • …be inverted with events being pushed to the reader
  • …be a from a finite ring buffer

Writing a stream is weird

The writer of a stream submits one element at a time.

Writing a stream could…

Elements are weird

Elements in stream could be…

Higher order streams are weird

Streams themselves are can be input into other functions.

Streams could be…

Streams are weird because so many things are just streams with another name. With our stream goggles on, we can even reconceptualise “random memory access” as two streams. A stream of load address commands and another stream of memory values.

Do you want to learn all the ways streams are weird? You’re in luck, Battlefy is hiring.

2024

  • MLBB Custom Lobby Feature
    Stefan Wilson - April 16th 2024

2023

2022

Powered by
BATTLEFY