Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What can webdev learn from game developers?

What can webdev learn from game developers?

Łukasz Niemier

December 18, 2018
Tweet

More Decks by Łukasz Niemier

Other Decks in Programming

Transcript

  1. What we can learn from
    game developers?

    View full-size slide

  2. There will be no code

    View full-size slide

  3. Main problems in games
    • Performance

    • Performance

    • Performance

    View full-size slide

  4. Solutions
    • Intrusive lists

    • Better CPU cache utilisation

    • Makes structures look „weird”

    • Entity-Component-System

    • Try to manage data independently form logic

    • Separate of concerns

    • Datagram protocols

    • Connection-less communication

    • Loosing package isn’t a problem

    View full-size slide

  5. Intrusive lists are
    completely pointless for
    our case
    So I will not get into details

    View full-size slide

  6. Entity-Component-System
    • Component - collection of data

    • Should be small

    • Contain no logic

    • Entity - collection of Components

    • In general sense - common ID for the components

    • System - logic over Components

    • Contain logic

    • Modifies one or more components

    • Do not care about Entities

    • Listen on events in log

    View full-size slide

  7. Live
    Fluffy
    Placeable

    View full-size slide

  8. Live
    Fluffy
    Placeable
    Mobile

    View full-size slide

  9. Live
    Fluffy
    Placeable
    Mobile
    Jumpy

    View full-size slide

  10. Live
    Fluffy
    Placeable
    Mobile
    Feedable
    Jumpy

    View full-size slide

  11. Live
    Fluffy
    Placeable
    Mobile
    Weight
    Feedable
    Jumpy

    View full-size slide

  12. Live
    Fluffy
    Placeable
    Mobile
    Edible
    Weight
    Feedable
    Jumpy

    View full-size slide

  13. Live
    Fluffy
    Placeable
    Mobile
    Edible
    Weight
    Feedable
    Jumpy

    View full-size slide

  14. Placeable
    Mobile
    Jumpy
    Weight
    Jumping

    View full-size slide

  15. Placeable
    Mobile
    Jumpy
    Weight
    Jumping
    Moving

    View full-size slide

  16. Placeable
    Mobile
    Jumpy
    Weight
    Jumping
    Placeable
    Mobile
    Moving
    Weight

    View full-size slide

  17. „Real example”
    Electronic Medical Record system

    View full-size slide

  18. Entity-Component
    • Patient

    • Name (first name, last name)

    • Vitals (pulse, body temp., etc.)

    • Illness

    • Practitioner

    • Name

    • Authentication

    • License

    View full-size slide

  19. Systems
    • Authentication

    • Authorisation

    • Vitals measurement

    • Morgue

    View full-size slide

  20. Pros
    • Adding features to entities is simple

    • Making snake jumpy is as simple as adding component to it

    • Removing features is simple

    • Making rabbit immovable is as simple as removing
    component from it

    • You can dynamically add features to entities

    • Less edge cases, as system is not aware of the entities that
    do not contain given components

    View full-size slide

  21. Cons
    • Eventually consistent

    • Systems tends to grow and touch a lot of components at
    once

    • Unexplored technique in webdev land

    View full-size slide

  22. TCP - pros
    • Nice when you can keep connection open

    • Quality of Service

    • Guarantee of delivery

    • TLS

    View full-size slide

  23. TCP - cons
    • No multihoming (at least in IPv4)

    • One missing package will delay all next messages until
    delivered

    • Three-way handshake

    View full-size slide

  24. Hello, would you like to hear a TCP joke?

    Yes, I'd like to hear a TCP joke.

    OK, I'll tell you a TCP joke.

    OK, I'll hear a TCP joke.

    Are you ready to hear a TCP joke?

    Yes, I am ready to hear a TCP joke.

    OK, I'm about to send the TCP joke. It will last 10 seconds, it has
    two characters, it does not have a setting, it ends with a
    punchline.

    OK, I'm ready to hear the TCP joke that will last 10 seconds, has
    two characters, does not have a setting and will end with a
    punchline.

    I'm sorry, your connection has timed out... ...Hello, would you
    like to hear a TCP joke?

    View full-size slide

  25. UDP
    • Connectionless

    • No delivery guarantees

    • No QoS

    • No congestion negotiation - can cause package drops

    View full-size slide

  26. QUIC
    • Implementing TCP guarantees on top of UDP

    • Still connectionless

    • Encrypted

    • No three way handshake

    • Multihoming

    • Implemented in user space

    • Non-blocking on missing packages

    View full-size slide

  27. HTTP 3 = HTTP 2 over QUIC
    • Multi-network connections handled via multihoming

    • Faster delivery, even better than via HTTP 2 push

    • Encryption „reusage”

    • Less traffic when establishing encryption suite

    View full-size slide

  28. –George Santayana
    Those who cannot remember the past are
    condemned to repeat it.

    View full-size slide