There are a few I’m aware of:

  1. Rust-style use (multiple imports per statement, renaming items using as)
  2. Java-style import (single import per statement, no renaming (afaik))
  3. Zig-style let xlib = @import("xlib") (imports as assignments)
  4. C-style #include (no importing, just pastes the code of the named file)
  • nebeker@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    1 month ago

    I think C# handles this pretty well. You include namespaces with whatever granularity you need, down to a single class (or interface or whatever) and can alias them.

    using MyProject.Domian.Entities; //the whole module
    using Routes = MyProject.Api.Contract.Routes.Http;  //an aliased single class
    

    I bet Java had this too, C# us still mostly Java: Microsoft Edition.

    • Traister101@lemmy.today
      link
      fedilink
      arrow-up
      1
      ·
      1 month ago

      Java doesnt have aliases. You can do glob imports of a particular package (IE all the classes) and you can statically glob import all the static functions in a class but uh yeah that’s it

    • terabyterex@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      1 month ago

      c# is delphi with some realized mfc lofty goals.

      first, microsoft liked delphi and hired the guy who created delphi to create c#

      second if you read an mfc book from the 90s that talks about history and goals, 6ou can see they wanted the .net framework