Using all #1708
Replies: 14 comments
-
The list of ALL possible namespaces is extremely large and would guarantee ambiguity - because some exist in the core framework libraries. It would likely also slow down compilation substantially. I'm already dealing with 13 minute compile times (yes, minutes) for full builds, so any slowdown is a non-starter for me. There's a reason why the original language designers didn't do this. |
Beta Was this translation helpful? Give feedback.
-
You read code significantly more often than write code. It should be optimized for that purpose. Having to parse through a blacklist of namespaces would be significantly more complicated and confusing. And since namespaces bring in extensions as well as types the impact on code and resolving ambiguities would be a nightmare. |
Beta Was this translation helpful? Give feedback.
-
The list of namespace you'd have to blacklist to resolve the ambiguities would no doubt be larger than the unrealistically large list you've used, thus defeating the point and making everything more confusing. Besides that, |
Beta Was this translation helpful? Give feedback.
-
I'd expect two things in practice: editor lag and conflicts which are irritating to resolve. |
Beta Was this translation helpful? Give feedback.
-
I've been tempted to propose the opposite, allowing you to import only specific types in a namespace instead of all. Several other languages take this approach. The motivation would be to speed up compilation, though I don't have data to show how much of an improvement it would be. It would need to be significant for most developers to bother with the extra work of being explicit. |
Beta Was this translation helpful? Give feedback.
-
That might be where the Scala-like syntax would come in handy: using System.Threading.Tasks.{Task, Task<T>}; // only import Task and nothing else |
Beta Was this translation helpful? Give feedback.
-
@HaloFour True. |
Beta Was this translation helpful? Give feedback.
-
Instead of
why not refactor your class to only have one responsibility, thus removing the need for gigantic using lists? |
Beta Was this translation helpful? Give feedback.
-
@lazyloader. you must think real hard to come up with these nice features! |
Beta Was this translation helpful? Give feedback.
-
One thing people have to learn about Visual Studio is that the number of projects in your solution has a greater impact on build time than the size of the projects in your solution. Most teams have zero discipline isolating assemblies by functionality but isolate them anyway, meaning they're slowing the build down for absolutely nothing.
Ctrl+. Nobody has been actually typing out namespaces for years. |
Beta Was this translation helpful? Give feedback.
-
✋ Depends how well I know the API and which of the two things is easier to type. |
Beta Was this translation helpful? Give feedback.
-
As far as it goes, you're absolutely right about this - but your comment isn't relevant to my situation. Excessive proliferation of projects isn't the reason the codebase I mentioned takes 13 minutes to build, even though there are around 400. My build times used to be 85 minutes, with the hard drive being the bottleneck. Since installing a (very fast) SSD as my development drive, build times dropped to around 13m, with the bottleneck now being the processor. Compiler performance is important - and suggestions like this one, which would have a major impact on performance, worry me. I'm really appreciative of all the work the Roslyn compiler team has put into throughput and performance so far. |
Beta Was this translation helpful? Give feedback.
-
When I'm doing a code review, one of the things I do is to skim the list of The presence of cryptography related namespaces is informative; as are the namespaces for Windows.Forms, for WPF, for ASP.NET, for LINQ, for Immutable types, for testing frameworks (xUnit, Fluent Assertions), for utility libraries (moreLinq), and so on. Sometimes the absence of a namespace is useful - if Collapsing all that into an amorphous blob, by writing |
Beta Was this translation helpful? Give feedback.
-
I was just curious and wrote some code to count namespaces.
Simple Console App: 75 |
Beta Was this translation helpful? Give feedback.
-
Instead of
We can just do:
And it all automatically include all possible namespaces. If there is a naming ambiguities, it will ask you to resolve them. For example, if both
Foo.A
andThirdPartyA.A
had a typeButton
, I could resolve the amiguity by doing something like this:The result is that code will be much easier to type and shorter. You could also go into settings to have namespaces implicitly removed from
using all
without having to type it, so if you rarely ever useSystem.Threading
it won't be added, unless you did this:Beta Was this translation helpful? Give feedback.
All reactions