Unrelated? I thought we were talking about imports?
The fact is NOT all explicit imports use @import
which is what you falsely stated. That’s not true. My use of the term disagree
was putting it kindly, because it’s flat out objectively false.
And just to be clear, for the purposes of this particular conversation, import here means using a module/package/file/whatever-zig-wants-to-call-it in a file, because the usage is what’s most relevant here, not the fact that std imoprts crypto, and so anything that imports std also “imports” crypto. Yes, this might be different from the compiler. Humans aren’t compilers and linguistic concepts transcend the compiler.
In the example you give, you import both std
and fs
. This means both that you import std and, implicitly, everything that std imports, which is not quite what every language does, and you can explicitly “import” (with quotes) anything std imports into your own file.
Regardless of this import vs. use nonsense, the whole point of the conversation is about obfuscation - getting away with using insecure or ill-intentioned things in a patch without anyone seeing it. And it’s very easy to obfuscate specific parts of std
.
It’s weird to not distinguish between importing std
, which is perfectly fine, from explicitly importing everything else that is underneath std
, like sockets, networking, crypto, tls, http, etc.
It is not sensible to restrict all of std
for the sake of protecting against a subset of the standard library.
As for other languages, some languages, when they import a module or package, allow setting that import as public
, or exported. The equivalent of Zig’s system in this type of language would be making every import publicly exported by default. There are clearly downsides to this approach, just like there are always tradeoffs for most everything. And you and many others might be fine with the downsides, but pretending like there’s no downsides does nobody any favors.