3 ms·
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 c
by greggman3 6y ago
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.
- manigandham 6y agoThat’s not true. You can use aliases just fine. .NET is great with this.
- greggman3 6y agoin 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
- manigandham 6y agoDifferent 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-reference/keywords/extern-alias 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.
- smt88 6y agoI 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).
- greggman3 6y agoaliases help you use bar from foo.bar and moo.bar. They don't help you with 2 files both of which declare foo.bar
- manigandham 6y agoWhy would you declare the same type in 2 different files in the same project?
- greggman3 6y agoyou don't have control of all 3rd party libraries.
- manigandham 6y agoThen it's not the same project and the fully qualified type name will be different.
- adev_ 6y ago> 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.