News for hackers. Stuff that matters.
Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge... by greggman3 on Thursday August 06, 2020 @02:55AM (#24068720)
Java's packaging system sucks as does all the similar ones like C#, C++ etc compared to JavaScript's IMO.

All of those the space of namespaces is global. You can't have 2 modules named math.quaterinions in any of those languages. You can in JavaScript. To put it another way, in order to prevent name clashes in C++/C#/Java you have to know the name of every other project on the planet. If someone uses the same namespace then if you ever need to use those 2 projects together one of them will have to be re-factored.

That problem doesn't exist in modern JavaScript. There are no namespaces. There is just floating references to code.

Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge... by smt88 on Thursday August 06, 2020 @03:55AM (#24068964)
I honestly have no idea where you got the idea that namespace conflicts are a problem in C# or Java. Both have solved this problem (C# with aliasing and Java with packages).
Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge... by greggman3 on Friday August 07, 2020 @11:39PM (#24088747)
aliases help you use bar from foo.bar and moo.bar. They don't help you with 2 files both of which declare foo.bar
Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge... by manigandham on Sunday August 09, 2020 @12:46AM (#24097329)
Why would you declare the same type in 2 different files in the same project?
Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge... by greggman3 on Tuesday August 11, 2020 @04:58PM (#24125897)
you don't have control of all 3rd party libraries.
Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge... by manigandham on Tuesday August 11, 2020 @05:20PM (#24126120)
Then it's not the same project and the fully qualified type name will be different.
Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge... by manigandham on Thursday August 06, 2020 @03:07AM (#24068767)
That’s not true. You can use aliases just fine. .NET is great with this.
Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge... by greggman3 on Saturday August 08, 2020 @03:08AM (#24089696)
in one file declare

    namespace foo {
      class Bar ...
    }
In another file declare

    namespace foo {
      class Bar ...
    }

Now use both foo.Bar from file 1 and foo.Bar from file 2 in the same project. Aliases don't help with this
Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge... by manigandham on Saturday August 08, 2020 @03:54AM (#24089874)
Different assemblies with the same assembly name, namespace and class? Use an extern alias (which is how different versions of the same assembly can be used if necessary): https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...

Different assemblies with different assembly names but same namespace and class? Just use the fully qualified type name (and alias it for a shorter name).

Single assembly/project and namespace with the same class in multiple files? If you're just spreading out the code then use partial classes, otherwise why would you define the same type twice?

C# (and other languages) that use virtual namespaces can do everything that file-based namespaces can do, but also support many more scenarios.

Re:Node Modules at War: Why CommonJS and ES Modules Can’t Ge... by adev_ on Thursday August 06, 2020 @06:04AM (#24069583)
> Java's packaging system sucks as does all the similar ones like C#, C++ etc compared to JavaScript's IMO.

There is one gazillion things that are much more a problem than "namespace conflicts" in packaging and package management.

Including security & code authenticity, parallel multi-version handling, sensibility to side effects, speed, auditing and reproducibility.

And in these domain the JavaScript packaging system generally range from being 'catastrophic' to 'absolutely terrible'.

If I have to take an example package management system for the world I would certainly quote cargo, Nix, Guix or Spack but certainly not npm which is quite close to what you should really not do for a package manager.