Hacker News new | ask | show | jobs
by augusto-moura 693 days ago
> I understand and kinda appreciate the nice (apparent) simplicity of a dedicated "import", especially as you will use it a ton, but I also like the bluntness of Zig where it's not special (well, it has a macro), and you're explicitly doing the assignment:

That is exactly how CommonJS worked for the longest time:

  const module = require('url')
The short end of the stick was the export syntax for CJS, which is basically just assigning a property to an object:

  module.exports.value = 'foo'
The problem solve with the import syntax is that is statically parseable, you just need to parse the top-level of a package to find its dependencies. The explicit export is also a god-send for tooling, which can have a lot of introspection from it, without executing any code.