Trailing Whitespace

Namespaces are kinda dumb.

Namespaces provide two things:

  1. An optional name prefix to avoid naming conflicts.
  2. A way of grouping functions so that you can find them again when you need them.

Here are some suggestions for how namespaces could be improved or removed in programming languages:

  1. Allow regex-like imports, like import *_list to get all the list functions, or import print_* to get all the printing functions. This way I don’t have to decide if print_list goes in my print namespace or my list namespace.
  2. Use tags instead of namespaces. In the previous example, print_list would have the tags print and list. This would be slightly better than using regex-like imports because then we do not require names to follow a convention nor would we need to enforce an ordering to the parts of a functions names. Should I choose print_list or list_print? With tag imports, either would be fine. I leave it to the reader to think of a good system for how to tag functions.

I suggest a radical idea based on option 2 listed above. Functions are automatically named the hash of their implementation (perhaps on a normalized form of the syntax). Functions have tags, as described, as well as some documentation so that we can find functions that we want without relying on their name (which is quite unhelpful in this system). Every function imports every function it needs individually.

The benefit of this idea is that backward-compatibility is impossible to break. Every time a function changes, it’s name changes, which means that any dependent function which wants to upgrade to the new function must also change it’s import, which changes its own implementation, and therefore its name. Every change causes a rippling update through the dependency tree of functions.

This idea seems hard to implement without being unwieldy, but I believe with some good tooling, it would be possible to provide a good programmer experience.