News for hackers. Stuff that matters.
Re:Why do we need modules at all? (2011) by dmitriid on Tuesday August 27, 2019 @08:19AM (#20808764)
There are namespaces, you just don't see them. That's why there's python and python3, cmake and cmake2 (IIRC) etc.

With functions it's worse. In a flat namespace you will inevitably run into a problem of two people coming up with the same name.

Re:Why do we need modules at all? (2011) by nickjj on Tuesday August 27, 2019 @08:31AM (#20808846)
> There are namespaces, you just don't see them. That's why there's python and python3, cmake and cmake2 (IIRC) etc.

IMO python and python3 is a very welcome feature not a negative side effect of no namespaces. At call time it's super explicit so you know exactly what version you're using.

But in most module driven programming languages you might import the foo function at the top of your file and then use foo in 5 different places within that file. However, you spend 99% of your time working with the code in the file not glancing at imports, so now you're left wondering not only where foo is coming from, but who provided foo. Is it from the standard library, your own code base or a third party author? Suddenly you need to keep all of this in your head and it sucks.

Phoenix (a web framework for Elixir) has been taking steps to remove a lot of loose function imports so you know what module they are coming from at call time, but that's because Elixir as a language has modules. But even still, explicitness where you're using it is so much better in the long run for maintenance, even if it involves typing a few more characters.

Re:Why do we need modules at all? (2011) by Anonymous4C54D6 on Tuesday August 27, 2019 @10:59AM (#20810259)
As way-too-often, I think the solution should be a good IDE. There is nothing stopping your IDE from completing "foo" as "module1.foo" and offering "module2.foo" as well if it exists. Alternatively the IDE could just display "module1.foo" instead of foo because that is what the import dictates.

As always with dynamic things and editing code for them, this will be more difficult to get right when imports are dynamic.

Re:Why do we need modules at all? (2011) by dkersten on Tuesday August 27, 2019 @08:32AM (#20808864)
> There are namespaces, you just don't see them. That's why there's python and python3, cmake and cmake2 (IIRC) etc.

That's a versioning issue, that would happen with namespaces too. You'll have to disambiguate somehow and if a version number is the natural way, then that's the natural way regardless of if a single name or namespaced.

Keeping the next incompatible version as a separate thing (eg python vs python3, instead of continuing python but with semvers saying that 3.0 breaks 2.x compatibility) is actually a good idea. It leads to fragmentation, sure, but it makes dealing with the different versions easier IMHO and incompatible versions may as well be totally different things anyway.

> With functions it's worse. In a flat namespace you will inevitably run into a problem of two people coming up with the same name.

Yes, completely agree!

Re:Why do we need modules at all? (2011) by lootsauce on Tuesday August 27, 2019 @02:09PM (#20812713)
Just spit-balling here... I think a proposal like this can benefit from making some assumptions about tooling, the database of functions and their metadata would logically be tightly integrated into your editor. The official name of the function could simply be a hash of its contents, the serialized ast then hashed could be another option for matching exactly-syntactically equivalent code. Then human friendly names could be automatically searchable and tacked on in the code via tooling which presents the metadata in-line but does not become part of the source.
Re:Why do we need modules at all? (2011) by tosh on Tuesday August 27, 2019 @08:23AM (#20808790)
You could use something like uuids for naming functions and attach meta data (including e.g. human readable names and/or namespaces).
Re:Why do we need modules at all? (2011) by pjc50 on Tuesday August 27, 2019 @08:32AM (#20808856)
> uuids for naming functions

Microsoft COM would like a word. {20D04FE0-3AEA-1069-A2D8-08002B30309D}

Re:Why do we need modules at all? (2011) by ChrisSD on Tuesday August 27, 2019 @08:35AM (#20808883)
People on HN keep reinventing COM. I swear every other week we have discussions like the above in at least one thread.
Re:Why do we need modules at all? (2011) by pjc50 on Tuesday August 27, 2019 @08:47AM (#20808959)
Yup. There's a lot of factors at play. We're a very ahistorical field; lots of folks are self-taught and therefore reinventing everything is normal to them; the dev universe is heavily siloed into "Web+UNIX" versus "Microsoft" versus some now moribund siloes (Websphere! Solaris! Alpha!); Microsoft have almost no community compared to the FLOSS world (although .net is changing this a bit); and finally the simple fact that COM and you and I are very, very old.

I'm not even sure that reinventing COM would be a bad idea - you can definitely do some great things with it, and the specific implementation details of COM are crufty. But doing so deliberately rather than accidentally would be better, with a review of benefits and problems of COM approaches.

Re:Why do we need modules at all? (2011) by pjmlp on Tuesday August 27, 2019 @09:43AM (#20809475)
COM has been reinvented, as UWP. :)

As for the community, maybe not on SV, but there are plenty of Microsoft communities and meeting groups.

Re:Why do we need modules at all? (2011) by NikkiA on Tuesday August 27, 2019 @11:04AM (#20810327)
Tell them it's called 'Core Foundation Plugin' and point at the apple docs, they'll start loving it.

https://developer.apple.com/documentation/corefoundation/cfp...

Re:Why do we need modules at all? (2011) by abstract7 on Tuesday August 27, 2019 @01:50PM (#20812532)
It's "Component Object Model" for anyone out there that almost gave up after googling "COM".