bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Multiple types have conflicting/confusing type names.

Open Atlas16A opened this issue 8 months ago • 11 comments

Bevy has reused the same conceptual names for multiple types across things within bevy. Ie Query is used by bevy_ecs and cosmic_text, Handle in Bevy_asset and bevy_log, etc This creates confusion especially for autocomplete tooling like in vscode where the conflict leads to confusing errors that a normal person will not understand as syntactically they have done everything correctly.

Bevy should reserve the key conceptual ideas such as Query, Param, System, Handle, etc and any reuse should be name scoped, ex cosmic_text Query renamed to CosmicQuery etc

Checklist of conflicts (Ongoing) Please comment any additional items for renaming

  • [ ] Query: Bevy_ecs > cosmic_text
  • [ ] Handle: Bevy_asset > Bevy_log

Atlas16A avatar May 19 '25 01:05 Atlas16A

https://github.com/bevyengine/bevy/issues/3823#issuecomment-2769369036

hukasu avatar May 19 '25 02:05 hukasu

I believe best route would be to go through and search common concepts. If a conflict is found favor the bevy local name, so ecs Query stays and rename cosmic_text Query to CosmicTextQuery or CosmicQuery. If a conflict is between bevy crates, such as Handle in asset vs log, we should favor the one thats more important to development, so Handle should stay in asset and in log renamed to LogHandle.

I think renaming with their scope like this is the simplest solution to it.

Atlas16A avatar May 19 '25 02:05 Atlas16A

Yep, I'd love a checklist in this issue of all of the items that need renaming. We should then tackle them one item at a time in separate PRs so they don't get stalled out.

alice-i-cecile avatar May 19 '25 19:05 alice-i-cecile

I think re-exporting cosmic text in its entirety should be reconsidered. Imo it should largely be an implementation detail, except for advanced use cases. People in that position can just add a top level dependency to their project.

cart avatar May 20 '25 16:05 cart

Agreed! That will also ease migration if we want to swap again.

alice-i-cecile avatar May 20 '25 21:05 alice-i-cecile

would that go the same for the encase re-exports?

hukasu avatar May 20 '25 21:05 hukasu

would that go the same for the encase re-exports?

Yes please. Rendering is also interested in removing encase as a dependency completely IIRC, so that's a fine step forward.

alice-i-cecile avatar May 21 '25 15:05 alice-i-cecile

Bevy API docs / all items -> cut & paste into VSCode, Remove all lines which mention prelude::, Regex delete all module names, Sort lines, Run uniq -d, This yields a list of about 300 names, most of which are false positives. However, a few interesting ones are: Access, Anchor, Builder, Buffer, Cursor, Color, Command, Direction, Rect, Transform

(Most of these are dups from cosmic, although Access and Builder are not.)

I've been annoyed at Direction in the past, it's defined in cosmic_text::rustybuzz and bevy_ecs::schedule::graph

From Discord conversation.

alice-i-cecile avatar May 29 '25 17:05 alice-i-cecile

Another one I hit today: bevy::scene::ron::de::Position :(

alice-i-cecile avatar May 29 '25 23:05 alice-i-cecile

This weekend I had bevy::ecs::world::Entry and both bevy::platform::collections::{hash_map::Entry, hash_set::Entry} in the scope. The latter two are from hasbrown but the first could have a different name, like ComponentEntry.

urben1680 avatar Jun 01 '25 19:06 urben1680

bevy_render::camera::ScalingMode and bevy_sprite::ScalingMode (the latter also happens to be in the prelude).

benfrankel avatar Jun 01 '25 19:06 benfrankel

Hi, I investigated the remaining items in the checklist. Here's what I found:

  1. bevy_log Handle - I checked the entire bevy_log crate, there's no Handle re-export. Not sure where this came from.

  2. bevy_assets::Entry - This is a private enum (no pub), so it's not exposed in the API at all. Can't cause autocomplete issues.

  3. ScalingMode - Already solved by #21100 .

WaterWhisperer avatar Oct 21 '25 06:10 WaterWhisperer

Perfect. I'm going to mark this as complete then.

alice-i-cecile avatar Oct 21 '25 16:10 alice-i-cecile