Skip to content

Why use strings as labels? #103

@Plecra

Description

@Plecra

Why have you opted to use strings as labels in Bevy's APIs? It seems strictly less expressive than using ZSTs for the same purpose.

struct DoThings;

App::build()
    .add_stage_after(Update, DoThings)
    .add_system_to_stage(DoThings, something.into_system())
  • Type checking
    • It's not huge, but tracking down bugs stemming from little typos is annoying
  • Scoping
    • Types can be completely private to specific modules, allowing an implementation to pop implementation details into the ECS without needing to worry about it being observable. (This is just an extension of the same principle in Rust's sound/correct APIs)
  • Documentation
    • This creates a clear location for the developer to document the purpose of the label, which can be found easily with editor definition jumps

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and events

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions