Skip to content

Should we rename trio.hazmat? #476

Closed

Description

@njsmith

On the one hand, the name hazmat is definitely effective at getting people to pay attention and be careful. OTOH, I'm not sure it's quite communicating what we want: people seem scared of it, and uncertain whether they can actually use it. A bit of that is fine, but... I'm not sure it's communicating what we want. The block of text at the beginning helps of course, but you can't really fix up a confusing name with good docs.

Maybe trio.lowlevel? Though trio.socket is kind of low-level too. Does lowlevel have the kind of "if you see this during a code review, ask for a comment justifying its usage" implication that we're going for?

trio.foundation? trio.core?

Activity

  1. lisael commented on Mar 19, 2018

    @lisael

    Hi, and thanks for the great work with trio.

    While reading the docs, I had the feeling that trio API is sometimes not non-english-native-speaker friendly. I read a lot of technical documentation and I usually barely struggle to understand technical English but to be honest, I have exactly no idea what hazmat means. Not scary at all for more than the 2/3 of potential users. I've also noticed cushion and tiebreaker, that don't sound very technical, even though I can infer the meaning of those, from my French background or by word composition.

    OTOH, the naming in the API is somehow unusual, refreshing, and sometimes very explicit (do_stuff_before_foo()), but the refreshing part shouldn't hinder the readability. Don't make me wrong, I do think that the documentation is incredibly extensive, readable and sometimes amusing for such a young project.

    May I suggest trio.internals ? core and foundation read good too. Maybe internals reads too much like don't you dare using this, you mortal

  2. njsmith commented on Mar 19, 2018

    @njsmith
    MemberAuthor

    @lisael

    I read a lot of technical documentation and I usually barely struggle to understand technical English but to be honest, I have exactly no idea what hazmat means. Not scary at all for more than the 2/3 of potential users.

    That's a great point – thank you! In colloquial English, hazmat is "hazardous materials"; it suggests that when using this module you might want to wear a suit like this. I definitely want things to be accessible, but as a native English speaker I'm at a disadvantage: it's hard for me to guess which things are common knowledge and which things are weird idioms that most people don't know :-). So, I really appreciate this kind of feedback! If you notice any other places where trio's naming is confusing, please speak up; it's a really valuable contribution. (And just to confirm: you're saying that cushion and tiebreaker surprised you, but were understandable, right?)

    I am kinda liking trio.foundation... it's long, which nudges you not to use it, and it has that hint of "you don't want to use this directly, you want to use the things that are built on top of it" without being outright scary.

  3. njsmith commented on Mar 19, 2018

    @njsmith
    MemberAuthor

    (Possibly interesting trivia: I stole the hazmat name from the cryptography library.)

  4. m-u-xyz commented on Mar 19, 2018

    @m-u-xyz
    Contributor

    or we could take a hint from git and use plumbing, though foundation make sense too.

  5. sorcio commented on Mar 19, 2018

    @sorcio
    Contributor

    I will just contribute some personal thoughts just because I found myself thinking of this naming more than a couple times. I'm going to look very opinionated but I just have some time to write about something that makes me think.

    1. I met cryptography before Trio so the intentions in the naming were easy to translate, and yet required some translation. Because in cryptography the name is meant to actively discourage people who are not experts to implement their own cryptographic solutions, but the hazmat part of the library is mostly extension. It makes the library more extensive, it exposes more ("a larger number of") useful algorithms and protocol implementations. In Trio it feels more like foundation, because it lies on an explicitly different level of abstraction and you could potentially build different abstractions. It's only hazardous because it's lower-level.

    2. In both libraries, I feel that telling the user what is dangerous carries the risk of transmitting a patronizing message. The name choice itself tones this down a bit by resulting "ironically patronizing", although 1) this might even be more triggering for some folks and 2) the humor could easily be lost in translation anyway. There is a difference between documenting the non-obvious hazards of something and labelling something in a way that might imply "grownups only, you must be this tall for this ride". Taking a shortcut to remind of dangers has value, to be sure, but it also has implications.

    3. Reading Trio code for high level components like streams and sync feels like there is some cheating going. You see that what would be hazmat to commoners (and is documented as such) is actually _core to the library author. What is it, then? Is this actually the core of Trio, or something which is better avoided? Is this just a way the maintainers of the library are telling us they don't support users of this layer? And what about the idea of the foundational layer, if the library itself seems to be playing on a different ground? (It's not, it's pretty much just calling hazmat a different name)

    I like names that emphasize "core", "kernel", "low-level" because it's a widely known model to programmers. But: it's common to the point of overuse. It'd be easy to confuse "Trio Core API" or "trio.core API" (the API currently known as trio.hazmat) with "Trio's core API" (some API which is considered to be fundamental to most Trio users, like nurseries). "Low-level" is already taken. "Kernel" is meaningful but way too loaded (is it about interacting with the OS kernel? Is it because it includes a scheduler?). "Foundation" is a good idea because it suggests building upon a layer; it also suggests solidity, which might or might not be the right message. "Internals" is not exactly right (why is it public then? Internal to what? Is this subject to change without warning? Is this less clean?).

    One question would be: what is Trio? Is it the whole thing? Is it the API? Is the split we are talking about between two API sets for the same underlying beast, or is it more like between two libraries working one on top of the other? It's actually a mix of both, but is that an implementation detail? I like the split because it says something like "as long as you only use stuff from the main API, some properties of your program are guaranteed". It's great that this is clearly documented in the name itself. Maybe the two parts should be exposed with different names, one as trio and the other as something else?

  6. Fuyukai commented on Mar 19, 2018

    @Fuyukai
    Member

    I personally don't see the point of even having trio.hazmat. Why not just let people access the core through a normal package, instead of various startup redirects? It feels overly protectionist.

  7. njsmith commented on Mar 19, 2018

    @njsmith
    MemberAuthor

    @Fuyukai can you clarify what you're thinking of when you say we could not have hazmat at all? I assume you don't mean: delete that module and don't let people use those functions at all :-). Do you mean, expose trio._core as trio.core or something like that?

  8. Fuyukai commented on Mar 19, 2018

    @Fuyukai
    Member

    The second one; maybe with a big warning saying "Anything in trio.core can change at any point without complaint".

  9. njsmith commented on Mar 20, 2018

    @njsmith
    MemberAuthor

    So, everything in trio._core is exposed as public API -- we actually have a test checking this. But it gets split up between trio, trio.testing, and trio.hazmat. And the things in trio.hazmat aren't supposed to be any less stable than the rest of trio, they're just lower-level: intended for implementing nice tools rather than being nice tools.

    I want to be able to say things like: "in trio, await always means a checkpoint" (but in trio.hazmat, that's not true: checkpoint_if_cancelled and cancel_shielded_checkpoint aren't checkpoints, but rather tools for building checkpoints). And "in trio, we don't use callbacks" (but in trio.hazmat, that's not true: wait_task_rescheduled does). And "in trio, concurrency always uses a nursery object" (but in trio.hazmat, that's not true: spawn_system_task and TrioToken.run_sync_soon don't). And "in trio, our APIs try hard to be as friendly and easy to use as possible" (but that's not exactly true for trio.hazmat in the same way it is for the rest of the library). Also, trio.hazmat is where introspection and debugging stuff lives, things you can use to pry open the normal abstractions and look inside.

    The rough analogy here is that trio.hazmat is something like the os module: normally in Python if you want to open a file you use __builtins__.open, which gives you a sensible high-level interface. But if you really need to access the raw APIs your operating system exposes, you can use os.open. Along with other wacky stuff like os.setsid, os.posix_fadvise, os.sched_rr_get_interval.

    So... hmm. Some things it would be good to communicate to users about this submodule (whatever we call it):

    • When you're first learning trio, you can ignore it (and lots of people may never need to learn it at all)

    • If you're trying to extend trio or implement your own "primitives", you should look at it

    • It's a real public API, in the sense that it's documented / supported / stable (or at least, no more unstable than the rest of the library)

    • But you may need some expertise and care to use it correctly.

  10. shoyer commented on Mar 20, 2018

    @shoyer

    I like trio.lowlevel.

  11. cjerdonek commented on Mar 20, 2018

    @cjerdonek
    Contributor

    I am kinda liking trio.foundation... it's long, which nudges you not to use it, and it has that hint of "you don't want to use this directly,

    Oddly, trio.foundation to me communicates the opposite feeling of being very safe and stable to use, like the tried-and-true, can't-go-wrong core part of an API. After reading the last comments, it sounds like trio.expert or trio.advanced might be better. trio.plumbing was in fact the first thing that popped into my mind (as @smurfix also suggested).

    By the way, I'm an English speaker and was also confused by what hazmat was going for. I interpreted it to mean something like "use at your own risk because these functions might break at any time." (But that was without reading the docs.)

  12. sorcio commented on Mar 20, 2018

    @sorcio
    Contributor

    Foundation is a good metaphor but maybe the word itself is not the best option. Following synonyms chains and random ideas...
    trio.groundwork, which as a non-native is not entirely clear but suggestive
    trio.base, well, feels like a good lead to me, but maybe too neutral
    trio.ground, ough, don't know
    trio.dirt, sounds... interesting but maybe... avoidable?

    "Plumbing", in Git lingo, is contrasted to "porcelain". Again a good metaphor. In Git, though, "porcelain" comes with less stability guarantees, because it's meant to be used by humans, while "plumbing" is sort of an API (or scripting interface) and tries to be more stable. Also, porcelain is implemented only in terms of plumbing and some glue. This contrasts a bit with the split in Trio's API. Anyway I wouldn't mind adopting trio.plumbing and I don't think it would be too misleading. My only worry is the idea of pipes implied by "plumbing", which is kind of delicate in an I/O library.

    The split in Git also reminded me that it's not only about bases and building upon them, but also about fronts and backs.
    trio.backend might be another good lead
    trio.backstage
    trio.backoffice (ugh)
    trio.behind (?)

    Also...
    trio.extend
    trio.toolkit
    trio.unsafe
    trio.system
    trio.unprotected
    trio.panelboard

    I'm bad at self-explanatory names.

  13. Fuyukai commented on Mar 20, 2018

    @Fuyukai
    Member

    trio.scary perhaps.

  14. 20 remaining items

  15. njsmith commented on Jan 7, 2019

    @njsmith
    MemberAuthor

    @oremanj I'm not 100% attached to powertools, but I'm pretty reluctant to have "plumbing" and "pipes" right next to each other with completely different meanings.

    Is "implementing my own debugger" really not something that you associate with "power tools"?

  16. sorcio commented on Jan 7, 2019

    @sorcio
    Contributor

    Maybe "wiring" as a metaphor works similarly to "plumbing". Or there could be other trades to borrow from.

  17. njsmith commented on Jan 7, 2019

    @njsmith
    MemberAuthor

    trio.drywall
    trio.grout

  18. oremanj commented on Jan 7, 2019

    @oremanj
    Member

    Writing your own debugger is definitely power tools. :-) I don't feel like statistics or instruments or checkpoint_if_cancelled are power tools as much, and Task can be used for fairly simple things like "save the name of the task that's using this resource so you get better error messages on a conflict". It's possible I have a skewed idea of what's in scope for "normal" library users. It's also true that the powertools name sits better with me now than it did when I first saw it, and I'm not going to be notably sad if it gets adopted; it's just not my first choice.

    I'm not very worried about the plumbing/pipes conflict, because:

    • I agree with @pquentin that I don't think I've ever seen "plumbing" used to refer to IPC pipes
    • we don't literally have a trio.pipes submodule
    • we don't have public pipe APIs at all right now
    • if and when we do have public pipe APIs, they'll probably be limited in scope, maybe even just make_pipe() returning a stream pair and serve_named_pipe / open_stream_to_named_pipe for Windows

    But I do understand that it's a possible point of confusion.

    wiring seems good, though if I saw it without explanation I wouldn't know what it was. More brainstorm: backplane, switchboard, reactor, guts, rivets, engine, gears, ...

    I actually think kernel works pretty well for Curio as a term for this sort of thing, and I don't predict much confusion if we were to borrow it, but I recognize that might be a minority opinion.

  19. oremanj commented on Jan 7, 2019

    @oremanj
    Member

    Another idea: trio.loop? (loop like "run loop" or "event loop")

    It's short and I don't see anything in current-hazmat that's not reasonably interpretable as "tell the run loop to do something at a low level". The connotations of "normal users don't need this" are less present, and there's the danger that people coming from asyncio with so many normal operations performed via loop.foo() will look in trio.loop for those normal operations. But I think that might be addressable with documentation. "Low-level control of the run loop: trio.loop" or something.

  20. oremanj commented on Jan 7, 2019

    @oremanj
    Member

    A friend suggests (and I like) trio.control: you don't always want this level of control, but when you do...

  21. ncoghlan commented on Jan 8, 2019

    @ncoghlan

    Nudging folks in the direction of talking about async kernels rather than async event loops would actually make a lot of sense to me, as does the idea of having separate low level kernel APIs (akin to making your own syscalls directly against an OS kernel rather than using libc convenience wrappers).

  22. energizah commented on Feb 17, 2019

    @energizah

    From the above, the criteria describing this submodule seem to be:

    So... hmm. Some things it would be good to communicate to users about this submodule (whatever we call it):

    • When you're first learning trio, you can ignore it (and lots of people may never need to learn it at all)
    • If you're trying to extend trio or implement your own "primitives", you should look at it
    • It's a real public API, in the sense that it's documented / supported / stable (or at least, no more unstable than the rest of the library)
    • But you may need some expertise and care to use it correctly.

    To my ear, this suggests trio.primitives. It tells me everything I need to know.

    powertools, by contrast, is confusing -- I don't know if it's more or less high level; if power tools are automated machines that take care of the manual work, that's sort of the opposite of what this module is.

  23. njsmith commented on Jun 4, 2019

    @njsmith
    MemberAuthor

    I just read over this again, and now I'm leaning towards lowlevel. It seems broadly unobjectionable, and the only concrete argument against it was the one I raised about having a "high level" and "low level" I/O layer in the docs... but now I think we need to reorganize that part of the docs anyway, so it's not a big deal :-). And it's the same length as plumbing, shorter than powertools or primitives.

    Maybe we'll still put the power tools picture in the docs though :-)

  24. ncoghlan commented on Jun 9, 2019

    @ncoghlan

    @njsmith I'm guessing https://trio.readthedocs.io/en/latest/reference-io.html#low-level-networking-with-trio-socket is the specific section you're concerned about?

    If you were to change that to refer to the "Socket API layer" and the "Stream API layer", you'd end up with the stack:

    * `trio.streams` - connection oriented, mostly TCP
    * `trio.socket` - everything else you might normally want to do with a network socket
    * `trio.lowlevel` - low level plumbing and power tools
    

    (Some currently top level APIs would need to be grouped under streams for that to work fully, but even without that code level structure, you could use the framing in the docs)

  25. added 2 commits that reference this issue on May 1, 2020
    81af324
    22038ac
  26. added a commit that references this issue on Jun 6, 2020
  27. added a commit that references this issue on Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions