Live data from Hacker News

Why do we need modules at all? (2011)

groups.google.com

11–20 of 94 posts

Re: Why do we need modules at all? (2011)

#11
As with other similar proposals, doesn't this simply move the complexity around without changing anything else? Now instead of looking for the right module or whatnot, you'll be sifting through billions of function definitions, trying to find the very specific one that does what you need, buried between countless almost but not quite similar functions.

Re: Why do we need modules at all? (2011)

#12
post #8

If there are no modules but a "flat" global namespace which requires every function name to be unique to avoid collisions... it means people would inevitably re-invent pseudo/fake "modules" and hierarchy in metadata tags in large non-trivial codebases. Consider a function name: log() Is it a function to log an event for audit history? Or is it a function to get the mathematical natural logarithm of a number? The glob…

This is what Emacs Lisp has, and what indeed does happen with libraries

Re: Why do we need modules at all? (2011)

#13
Functions are not isolated values.

They are nodes in a graph, where the other nodes are the input types, output types and other functions.

It makes sense to cluster closely associated notes, hence Modules.

Re: Why do we need modules at all? (2011)

#14
post #3

We need modules so that my search results aren't cluttered with contamination from code that is optimised to be found rather than designed to solve my specific problem. We need then so that we can find all functions that are core to a given purpose, and have been written with consideration of their performance and a unified purpose rather than also finding a grab bag of everybody's crappy utilities that weren't desig…

Don't forget about encapsulation, there's most likely a lot of functions that aren't relevant outside the module.

Re: Why do we need modules at all? (2011)

#15

We need modules because they demarcate social units of collaboration.

This could be achieved with a hierarchical namespacing scheme for functions, no?

    universe.mega_corp.finance_dept.team_alpha.foo
But to use `universe.mega_corp.finance_dept.team_alpha.foo` in your application, you don't import a module, just the function `foo`.

Who controls what goes into the namespace `universe.mega_corp.finance_dept.team_alpha`? That would be Team Alpha in the Finance Department of Mega Corp.

I guess this is like tree-shaking by default.

Re: Why do we need modules at all? (2011)

#16
post #3

We need modules so that my search results aren't cluttered with contamination from code that is optimised to be found rather than designed to solve my specific problem. We need then so that we can find all functions that are core to a given purpose, and have been written with consideration of their performance and a unified purpose rather than also finding a grab bag of everybody's crappy utilities that weren't desig…

just deduce the domain from text similarity :o)

Re: Why do we need modules at all? (2011)

#20
post #12
post #8

If there are no modules but a "flat" global namespace which requires every function name to be unique to avoid collisions... it means people would inevitably re-invent pseudo/fake "modules" and hierarchy in metadata tags in large non-trivial codebases. Consider a function name: log() Is it a function to log an event for audit history? Or is it a function to get the mathematical natural logarithm of a number? The glob…

This is what Emacs Lisp has, and what indeed does happen with libraries

Happens with R as well where everything gets dumped into a global namespace. It's a huge mess.

If you're lucky all functions will have a common prefix str_* or fct_*. If you're unlucky then you have to figure out which package has clobbered a standard library function, or the exact ordering of your package import statements you need for your code to run.

Post reply on HN