News for hackers. Stuff that matters.
Re:Astonishing Performance of .NET 5 by christophilus on Thursday November 12, 2020 @07:59AM (#25069351)
It’s been a hot minute since I wrote any C# (pre .NET Core). I kicked the tires yesterday. I have to say, documentation is all over the map, and the old DI / enterprisey boilerplate is still alive and well. Coming from a Node + TypeScript, Ruby, and Go world, C# still feels like a lot of ceremony. So, I gave F# a spin again. It’s always had a special place in my heart. But while the language is fantastic, the tooling (on OS X) and documentation made it difficult to get off the ground.

So, what’s the best-organized resource for getting up to speed on .NET these days?

Re:Astonishing Performance of .NET 5 by shireboy on Thursday November 12, 2020 @09:02AM (#25069894)
I’m a Dev doing mostly C# and JS. I’ve heard some of the complaints on HN mentioning DI and really don’t get it. I honestly feel like it makes my code cleaner and more testable. For example, I don’t have to care where my IFooService comes from or how best to instantiate and dispose, I just request one in the constructor. For a framework to be flexible, you need _some_ plugin capability. Asp.net seems to do pretty good at giving you nice defaults but letting you swap out with DI. All my dependencies are laid out nicely in one place (Startup.cs) and then used throughout. DI gives you that and I’m glad that it’s baked in now as opposed to having to pick a 3rd party. Maybe I’m biased, though. Help me understand why NOT to use DI? Is it just moving people’s cheese or are there other reasons?
Re:Astonishing Performance of .NET 5 by mattmanser on Thursday November 12, 2020 @09:46AM (#25070410)
If you don't want to write any unit tests, for which there are a myriad of reasons not to, whether you're prototyping, throwing together a small once and done for a client, etc.

Then it's just a massive waste of time and gets in the way.

I really feel that you (and Microsoft) have completely lost sight of the reason why DI was ever even necessary and have become blind to just how much extra code it generates. The only reason was to inject mocks, and people hand-wrung for ages over it because the code to do so infects all the other code. Then people started to try and back justify it with IoC, but it's never really been a convincing argument.

It's also something that if you're not working regularly with it can be very mysterious and when it fails, fails at run-time, quite inscrutably sometimes.

From my perspective it's just boilerplate magic that if you actually need it, fair enough, but if you don't is a persistent, nagging, pain in the ass.

Re:Astonishing Performance of .NET 5 by chunkyfunky on Thursday November 12, 2020 @10:03AM (#25070591)
"The only reason was to inject mocks". Must disagree...the reason for DI is to support the Dependency Inversion Principle : "High-level modules should not depend on low-level modules. Both should depend on abstractions (e.g. interfaces)." Won't even go into the host of side-benefits that are gained from adhering to the DIP.

In C# the idiomatic way to achieve this is via constructor injection, which is made much easier to manage in ASP.Net with a DI library that works with the framework for you (either the built in one or AutoFac / SimpleInjector, etc.). But you don't have to use a library; many times I'm writing a simple-ish console app and just use good old "Poor Man's DI" where I manually construct my object graphs at startup.

Re:Astonishing Performance of .NET 5 by zzbzq on Thursday November 12, 2020 @11:16AM (#25071365)
This is the common misconception/defense of DI that drives me so cRaZy I've jumped to different languages. DI containers do NOTHING, NOTHING to make Dependency Inversion easier, nor does use of a DI container guarantee (as dozens of projects I've worked on prove) that DIP is correctly adhered to.

DIP is achieved precisely when the components (be they packages, projects, classes, types) are organized with the low-level modules depending on the high-level modules rather than vice versa. In English, this usually means the I/O and any heavy framework code is kept out of the program logic.

What DI does do is confuse this matter. Class relationships which are mere IMPLEMENTATION DETAILS of a module are elevated alongside the actual component architecture of the program. The object graph becomes obscured. Program execution order becomes nondeterministic. The callstack is completely ruined, undoing decades of enlightenment since Dijkstra's "GOTO statement considered harmful." And all my experience with the pattern proves, the DI container causes programmers to not even evaluate or understand whether their dependencies are even inverted, because all classes and their relationships just become one amorphous blob floating aimlessly inside the container.

Re:Astonishing Performance of .NET 5 by chunkyfunky on Thursday November 12, 2020 @11:45AM (#25071657)
Some fair points but I would disagree on the fundamental definition of the DIP. In my book it absolutely does not mean that low-level modules depend on high-level modules. That's just high coupling turned upside down. You have to have shared abstractions as the "loose coupling" between modules and nothing more, to say you are adhering to the DIP.

Simply, this means that no implementation module, high or low, depends on any other implementation module, ever. It only ever depends on abstractions which are shared between modules.

I don't see how using a DI container can change the program execution order, unless one is misusing it terribly - after all, its sole purpose is to provide the correct concrete implementation of a dependency to an object at the time of its construction, the execution order from the perspective of the program is 100% preserved. Sure, maybe the container itself creates my graph in a non-deterministic way, but why would I care? If my program depends on this that's just bad design imo, no amount of libraries is going to save it :)

And the object graph is not obscured, in fact it is clarified, because you look at a class constructor and immediately can see what it's invariants are! And I have yet to come across a DI library that wouldn't immediately halt and catch fire if you introduced a circular dependency chain, so it's literally not possible to have these amorphous blobs (great expression though!) in any proper DI container.

Re:Astonishing Performance of .NET 5 by ratww on Thursday November 12, 2020 @12:10PM (#25071926)
> DIP is achieved precisely when the components (be they packages, projects, classes, types) are organized with the low-level modules depending on the high-level modules rather than vice versa.

+1. This simple idea is the basis of Clean Code, Hexagonal Architecture, Onion Architecture, Haskell, Functional-Core-Imperative-Shell, among other good architecture ideas.

Re:Astonishing Performance of .NET 5 by chunkyfunky on Thursday November 12, 2020 @12:24PM (#25072111)
Page 150 of "Clean Code" says this about the DIP: "In essence, the DIP says that our classes should depend upon abstractions, not concrete details". This is very similar to pretty much any canonical definition you can find anywhere else. I'm quoting it here because the person who coined the principle is the same person whose name is on the book, so I am guessing his definition is correct.

If you're not using abstractions, you are not using the DIP. What is being described here with low-level modules depending on high-level modules is categorically not the DIP, and I am starting to wonder if this is perhaps part of the frustration that the poster we're replying to has experienced with DI, since turning your coupling upside down will have the same problems as just high coupling in general, except everything is upside down now and harder to read :)

Re:Astonishing Performance of .NET 5 by jdmichal on Thursday November 12, 2020 @03:02PM (#25074189)
Is it just the text that's supposed to be upside down:

    ᴉɟ (ɐ == q) {
        ɔ;
    }
Or the whole thing?

    {
        ;ɔ
    } (q == ɐ) ɟᴉ
I want to make sure I do this the right way.
Re:Astonishing Performance of .NET 5 by peheje on Thursday November 12, 2020 @03:51PM (#25074820)
Hi chunkyfunky. I recently read Clean Code, great book.

I agree with your take on DIP.

We're using Microsoft Service Collection and with the Scrutor nuget component we were able to easily decorate an implementation from another package to extend the functionality adhering to the open closed principle OCP.

DI also enables your code to be open for extension but closed for modification.

Great stuff!

Re:Astonishing Performance of .NET 5 by chunkyfunky on Friday November 13, 2020 @03:20AM (#25080221)
Scrutor looks great, I must take it for a spin! And that is a great point about DI - being able to extend code/behaviour by injecting a different implementation of a dependency
Re:Astonishing Performance of .NET 5 by AndrewSChapman on Thursday November 12, 2020 @10:24AM (#25070822)
I'm not even a C# coder and I can't understand the complaints about this. If you want to code fast and fancy free, use Python or PHP. If you want to use enterprise patterns that will make your code clean, testable and nicely modular, then go for something like C# or Java. Why even use C# if you can't be bothered with DI because... too many lines? mindblown
Re:Astonishing Performance of .NET 5 by mattmanser on Thursday November 12, 2020 @10:46AM (#25071053)
Simply because not only does it not have to be like that, for years we weren't forced to use this stuff if we didn't want to.

I like C#, no, I adore C#. I have a bad memory for even the simplest method calls and the sheer power the intellisense in a statically typed language gives me to just not care means I can just code with joy.

My personal view on it has always been that someone in MS wrote MVC 1 in response to Rails on the sly. It was fantastic, a breath of fresh air into the MS constant misunderstanding of the web. Especially compared to webforms. For a while, everything was good. Then somehow 7 or 8 years ago the ASP.Net team got obsessed with ramming "best practices" down our throat and everything's gone a bit downhill from there.

Re:Astonishing Performance of .NET 5 by taco_emoji on Thursday November 12, 2020 @02:45PM (#25074021)
You still are not forced to use it. The documentation will heavily emphasize it, but you can still manually new things up to your heart's content if you want.
Re:Astonishing Performance of .NET 5 by moron4hire on Thursday November 12, 2020 @11:07AM (#25071293)
This isn't even about C# at all, actually. This is about the web application framework ASP.NET Core.

And they don't even have a point in this regard, because nothing is forcing you to use the DI. You wanna make a database connection with ADO.NET and a static connection string in your Controller? Go ahead. You can do that. It's no more effort than it ever was.

You want to grow your app to run it in multiple environments and be confident you don't clobber your configuration during migrations? Use ASP.NET Core's DI.

Every app framework has some "magic convention over configuration". I personally think ASP.NET Core's "magic" is a lot less pervasive than in, say Django, or RoR. When I was first learning ASP.NET Core--coming from WebForms--there was a learning curve. You don't just throw everything into a Web.config XML bag of doom anymore, with a single, static configuration reading tool that reads just that one file. That particular magic has changed. I mean, if you want to do that, you can, just read the file yourself. But it's not wired up by default anymore. And the new way of doing things was easily learned with a couple of afternoons of reading the documentation.

Which you can do, because there is actually documentation, and a lot of it. I think part of the problem might be that people are used to other web app frameworks where the documentation is pretty lacking, so they don't even think to go looking for documentation on ASP.NET Core and think they can just jump in and figure it out. I don't think you could do that going from Django to RoR or vice versa, but people complain when they can't go from ASP.NET WebForms to ASP.NET Core without learning new ways of doing things.

Don't like ASP.NET Core? You don't even have to use it. You can (rather easily) write your own web app framework. I've done it in the past, and there are FOSS projects for doing it (https://suave.io/, https://www.abp.io/, https://giraffe.wiki/, https://dotnetify.net/, https://www.dotvvm.com/, https://coalesce.intellitect.com/).

Re:Astonishing Performance of .NET 5 by philliphaydon on Thursday November 12, 2020 @11:55AM (#25071755)
You don’t even need to use DI with .NET... everyone complaining of DI. Just don’t use it...
Re:Astonishing Performance of .NET 5 by ivanche on Thursday November 12, 2020 @11:01AM (#25071215)
You're 100% right. People that complain about DI don't understand 2 simple facts:

1) that graph of object creation is NOT equal to graph of object usage

2) if you don't use DI, problems won't automagically go away - code will _still_ have dependencies, just they'll be hidden and tightly coupled

Re:Astonishing Performance of .NET 5 by zzbzq on Thursday November 12, 2020 @11:28AM (#25071514)
I hope that's a typo because it's literally the opposite of what you're saying in #2.

It is precisely when you use a DI container that the problem is hidden, whether or not it's solved.

In most projects that use a DI container, the problem is usually not solved correctly, but the developers are oblivious and overconfident. They think, as you do, using a DI container means they did it right. False! The DI container only guarantees everything is hoisted up to the object constructor. This is NOT DEPENDENCY INVERSION. The objects can be in the constructor, but the dependency arrow can still point the wrong way. An obvious example of this I've seen a million times is an interface sitting right next to its only implementation. That's NOT Dependency Inversion.

If you don't use a DI container, the problem also may or may not be solved, but it is never obscured, it is completely visible.

Re:Astonishing Performance of .NET 5 by ivanche on Thursday November 12, 2020 @11:39AM (#25071606)
It's not a typo - without DI (i.e. by using new operator freely whenever dev feels like) code still has dependencies, just this time hard-coded and invisible until you read the source.

Also, one can use DI without DI containers. Actually I prefer not using DI containers when possible.

Re:Astonishing Performance of .NET 5 by didibus on Thursday November 12, 2020 @02:06PM (#25073547)
That's the point I'd like to see discussed. What's wrong with hard-coding "new".
Re:Astonishing Performance of .NET 5 by sharpercoder on Thursday November 12, 2020 @02:28PM (#25073826)
That multiple usages of the same concrete types requires changes on multiple places. For small programs, the di container itself can probably be skipped (i.e. instantiate an object graph by newing up). For larger programs, this is too cumbersome and therefore error-inducing.
Re:Astonishing Performance of .NET 5 by didibus on Friday November 13, 2020 @01:15AM (#25079471)
> That multiple usages of the same concrete types requires changes on multiple places

Write a util function then, or like some like to call it, one of the many Factory pattern.

Re:Astonishing Performance of .NET 5 by shireboy on Saturday November 14, 2020 @06:14AM (#25091565)
So then you’re writing your own one-off DI of sorts. And you have more code to write than if you’d just used DI.
Re:Astonishing Performance of .NET 5 by ivanche on Thursday November 12, 2020 @05:51PM (#25076323)
Re:Astonishing Performance of .NET 5 by didibus on Friday November 13, 2020 @01:10AM (#25079437)
Yup, unit tests, and in my mind, that's bad. There's two reasons:

#1 Because the language provides no means to arbitrarily mock fields of a class, an entire design pattern and framework needs to be created just to do so. Why can't the language just have such a feature?

#2 This actually temps people in building worse design, because instead of creating pure units that don't have dependencies to begin with, it facilitates the opposite of creating deeply nested chains of dependencies, because "DI framework wires it up for me". Where if you didn't have that luxury, you'd be pushed towards pure units that don't have state dependencies, and integ tests instead, which in my mind is much better overall.

Re:Astonishing Performance of .NET 5 by ivanche on Friday November 13, 2020 @03:25AM (#25080259)
#1 is just moving the goalpost. You jumped from "why new is bad" to "why can't language mock fields".

#2 What stops you from creating a complex system without having dependencies, thus avoiding DI? Also, I think it would make an interesting case study if you're willing to write it.

Re:Astonishing Performance of .NET 5 by didibus on Friday November 13, 2020 @04:21AM (#25080589)
> #1 is just moving the goalpost. You jumped from "why new is bad" to "why can't language mock fields".

I don't think I did. Someone says, well if you use new, how are you going to unit test your class?

And one answer from a user of the language would be: Ya, I guess you'd need to change the way you're creating dependencies so they happen in the caller, and then you'd need to change your class so it takes the instance on its constructor, etc.

And this is the original OPs issue with C#, all the ceremony involved.

Another answer would be that the C# language designer could build a language level feature that avoids having to do that and allows mocking new inside a unit so it can be easily tested without shenanigans.

In fact, in Java-land, there is a library that lets you unit tests classes that use new, it's called Powermock. So it is feasible.

> #2 What stops you from creating a complex system without having dependencies, thus avoiding DI? Also, I think it would make an interesting case study if you're willing to write it.

I've moved to a functional language instead personally. That said, I do still like C# and Java, and think they are great languages. I'm also not against DI, or other enterprise patterns, some have legitimate uses. But I have definitely seen what the OP is complaining about, those languages are too deep in their own rabbit hole sometimes. To the point that half the developers don't know why they use DI, that's just part of the template they used to bootstrap their app. There's no thought process about, wait, what is the issue in my code structure and design that I'm facing, and what could I do to solve it. Instead it's just, I'm using all the "best practices", they are the best, and I'm using them all, all the time, so my code is the best it can be. Without any thought about what advantages they're even getting out of it.

That's why I asked about the "new". Most people don't really know the pros/cons. They only repeat what they read blindly: "New" bad bad, no use "new", never, very bad, antipattern, here link proof, must use DI instead.

And sometimes when they know of a cons, they don't think about tradeoffs against alternatives. They just say, well it has this one con, so it's very bad! An antipattern!

I think that creates a setting where you get monstrous framework and code bases, where people just throw every known pattern at it, no matter if it was called for or not.

Re:Astonishing Performance of .NET 5 by christophilus on Thursday November 12, 2020 @11:36AM (#25071580)
I spent maybe 15 years using C# and DI (for most of that time), and understand it pretty well. I still dislike it.

> just they'll be hidden and tightly coupled

They're more hidden with DI than without, in my experience.

At any rate, having left the .NET stack around 5 years ago, I certainly don't miss DI. My current code has more and better tests than my C# code ever did, so DI didn't really help me there (nor did it hinder me-- it was neutral). But my current code is much more explicit, direct, and a fair bit more compact. I'm definitely happier with it.

Re:Astonishing Performance of .NET 5 by ivanche on Thursday November 12, 2020 @05:57PM (#25076385)
Compare 2 classes. Class A expects all its dependencies to be passed as constructor parameters. Class B has a default no-arg constructor, but buried inside 5 of its methods calls Dep1 dep1 = new Dep1(); or Dep2 dep2 = new Dep2(); Now, which class has obvious and loosely coupled dependencies? Which class has hidden and tightly coupled dependencies?

To me, answer is clear - class A has obvious and loosely coupled ones. Lo and behold, class A comes from program which uses DI. Class B doesn't.

Re:Astonishing Performance of .NET 5 by apta on Friday November 13, 2020 @04:25AM (#25080607)
Which stack did you move to?
Re:Astonishing Performance of .NET 5 by mrits on Thursday November 12, 2020 @11:18AM (#25071384)
It sounds like it's you that does not understand there are alternatives.
Re:Astonishing Performance of .NET 5 by ivanche on Thursday November 12, 2020 @11:40AM (#25071612)
Been there, done that. Most popular alternative is new operators sprinkled throughout the codebase at will. Absolute horror!
Re:Astonishing Performance of .NET 5 by mrits on Thursday November 12, 2020 @12:26PM (#25072123)
I can see how IoC containers seem like a good idea to you then
Re:Astonishing Performance of .NET 5 by didibus on Thursday November 12, 2020 @12:56PM (#25072560)
> the reason for DI is to support the Dependency Inversion Principle : "High-level modules should not depend on low-level modules. Both should depend on abstractions (e.g. interfaces).

You can still depend on abstractions without DI. Just use an interface or asbtract class in your code.

DI only plays into how you acquire yourself an instance of the concrete class for that abstraction you depend on.

So it can be given to you by your caller (DI). You can go fetch it somewhere (ServiceLocator). You can create it through a utility (Factory). Or you can create it yourself old fashion way with new.

> But you don't have to use a library; many times I'm writing a simple-ish console app and just use good old "Poor Man's DI" where I manually construct my object graphs at startup

I will support that. I'd like people to be precise in their criticism, do you find the DI pattern troublesome, or some particular DI framework?

Re:Astonishing Performance of .NET 5 by chunkyfunky on Thursday November 12, 2020 @01:02PM (#25072637)
Neither, I'm a fully paid up and card-carrying DI-club member :)

I was kind of making the same point as you did, that you don't need to use any kind of DI library to achieve the DIP, but that in something like ASP.Net it is there and simple to use.

Re:Astonishing Performance of .NET 5 by starik36 on Thursday November 12, 2020 @12:00PM (#25071807)
One of the issues with solving a problem via constructor injection is that anytime you need to access a new object in the class is you need to DI it. We'll now you have to go change a 100 unit tests that are failing because of this.

I am not sure what is a better way to solve this problem, but the original OP is right - it's far too much ceremony.

Re:Astonishing Performance of .NET 5 by tored on Thursday November 12, 2020 @01:00PM (#25072618)
Yes, this can be a problem, that is why I have come to the conclusion that unit tests in larger projects (not libraries) is mostly a waste of time, because as soon you change the dependencies of a class you should rewrite your unit test for that class anyways because the class is not really the same class anymore (it works differently), you are just keeping the class name for convenience. And there is always a danger of changing a unit test, are you sure you are testing the same thing?

I think it is ok to depend on a DI-container in your unit tests for dependencies you are not directly testing, instead of stubs or manually instantiating them, to avoid updating unrelated unit tests when some class changes it's dependency somewhere in your project.

Instead I prefer system/integration tests where you test lets say a complete request from start to finish. Now your code base can change as much as you like, dependencies can be added or removed or classes or packages can be completely deleted, the tests stays the same. And now you are having tests that much closer matches reality instead of tons of mocks and stubs that can easily fool you to believing that they represent a good estimate of reality.

By doing this way a constructor based DI does not become a nuisance instead it helps you to organize your project, as it should be. Using a DI container makes it natural to break down your classes and automatically share the same decencies between them.

Counterargument to my argument is that if you don't use constructor based DI you can rewrite your class in anyway you like and the test stays the same, that is all true, however what DI gives you is the possibility to change the behavior of a class from the outside by injecting different dependencies, this makes your code better structured and easier to reuse.

If you want to accomplish that in the non-DI case you have to go thru trouble of configurable proxy classes which just introduces one more layer of bureaucracy, the thing you wanted to avoid by not doing DI.

My own criticism of DI containers is that they introduce magic to the project, personally I truly dislike code magic, however a DI container is nothing more than on the fly factory creator. In theory you could remove the DI container from a project by manually writing factories for each execution path, for me that becomes an acceptable level of magic as long as the DI container doesn't do lots of other things that factory couldn't solve.

Edit: misspelled convenience

Re:Astonishing Performance of .NET 5 by kords on Thursday November 12, 2020 @02:56PM (#25074134)
Sometimes I find this useful. This should also help the test errors you mention.

   public class MyTest()
   {
      private readonly IServiceProvider _serviceProvider;
      public MyTest(IServiceProvider serviceProvider)
      {
         _serviceProvider = serviceProvider;
      }

      public void MethodA()
      {
         var serviceA = _serviceProvider.GetService<IServiceA>();
      }

      public void MethodB()
      {
         var serviceB = _serviceProvider.GetService<IServiceB>();
      }
   }
Re:Astonishing Performance of .NET 5 by zzbzq on Thursday November 12, 2020 @10:40AM (#25071002)
Unit tests don't do anything to validate the existence of DI. Most people don't even use DI in their tests. DI is just spaghetti code.

The main thing holding C# back is the culture around the DI and weird hostbuilder code associated with ASPNET. If you just skip that part, it's great. Unfortunately a lot of web examples, solutions, and code libraries themselves are ASPNET-focused, and more and more of the code becomes some truly bizarre, unreadable framework injection in an inside-out fluent builder.

Re:Astonishing Performance of .NET 5 by legulere on Thursday November 12, 2020 @02:48PM (#25074046)
Do you mean DI (dependencies being added through the constructor abstracted by an interface) or DI Containers (magic code that magically creates objects for you)?
Re:Astonishing Performance of .NET 5 by balfirevic on Thursday November 12, 2020 @11:01AM (#25071214)
> Then it's just a massive waste of time and gets in the way.

I find it very useful for several purposes that have nothing to do with mocking or testing.

> and have become blind to just how much extra code it generates

It doesn’t generate any extra code at all.

For the record, I think that built-in .NET DI is pretty bad. It would be better if they managed to avoid including that abstraction in the framework, even if I personally choose to use DI in most of my projects.

Re:Astonishing Performance of .NET 5 by aloner on Thursday November 12, 2020 @12:23PM (#25072093)
What DI library do you use instead?
Re:Astonishing Performance of .NET 5 by balfirevic on Thursday November 12, 2020 @12:35PM (#25072266)
DryIoc whenever it’s up to me to choose one: https://github.com/dadhi/DryIoc

I’ve also used Autofac in projects where it was already in place - I don’t hate it but I like DryIoc better.

Re:Astonishing Performance of .NET 5 by shireboy on Thursday November 12, 2020 @11:00AM (#25071202)
I really am trying to understand this better. Can you give me an example with some concrete type names where it's massive waste and in the way?

When I think DI, I think: //Startup.cs has all the config "goo" I don't want to repeat elsewhere.

services.AddDbContext<MyDbContext>(o=>o.UseSqlServer(config.GetConnectionString("foo"));

services.AddTransient<MyService>();

//MyController.cs (or Page, etc) and others get to use it with no ceremony:

public MyController(MyService foo){ this.foo = foo; }

vs no DI, where the config "goo" has to be repeated in every place I intend to use it (or in this case it could also be buried in MyService.cs):

public MyController(){this.foo = new MyService(new MyDbContext(ConfigurationManager.GetConnectionString("foo")));}

public Dispose(){this.foo.Dispose();}

If I knew MyService would never be swapped out and only ever used in one place, I may opt for the no-DI route. I'll often start there then move it to DI when I want testability, reuse of config, plugability, etc..

Re:Astonishing Performance of .NET 5 by DougWebb on Thursday November 12, 2020 @11:50AM (#25071699)
The way to manage this without DI would be a static method someplace (Startup.cs or elsewhere) which creates the new MyService, stores it, and returns a reference. Then any controllers or pages that need the reference call the static method.

The method could return a MyService, or an IMyService if you want to be more flexible. It can always create a fresh object, manage and return a singleton object, or manage a pool of objects. For the new and pool cases, you can have another static method for 'returning' the object when the controller/page is done with it, so you can manage disposal or pool availability.

The biggest advantage I see to this approach is in debugging: there is a clear stack trace back to the source of the object, and also to its implementation if you're not using an interface. With DI you often can't tell where an object came from, and sometimes it takes some digging to even find out its exact type (unless you only have one implementation of each interface, which is often the case.)

Re:Astonishing Performance of .NET 5 by ivanche on Thursday November 12, 2020 @12:11PM (#25071933)
This is well known Service Locator anti-pattern. Described in many places, maybe this one is the most famous https://blog.ploeh.dk/2010/02/03/ServiceLocatorisanAnti-Patt...
Re:Astonishing Performance of .NET 5 by whelming_wave on Thursday November 12, 2020 @12:57PM (#25072574)
It seems like GP meant a static method specialized to whatever resource the program needs rather than a pluggable factory. All of the issues in that post appear to arise from the fact that they expect the locator to need configuration before it will work, while my reading of GP is that their configuration is which type the method returns, no registering a class or allocator necessary. Yes, this restricts you to a series of services known at build time, but... it seems to me that you knew what your services were anyway, whether it was directly in the locator, in an xml file, or in a registration call.
Re:Astonishing Performance of .NET 5 by DougWebb on Thursday November 12, 2020 @07:23PM (#25077210)
Absolutely nothing in that blog post applied to what I intended, because I did not say that a generic method that looks up implementations in a registry should be used. My static method would be explicitly coded to return a particular implementation, and there would be a separate static method for each kind of service you need. (Eg: one per interface if you're using interfaces for the return types.)

No registration or configuration is needed, because the types are hard coded. If you need mocking support, a single IsTest config setting could be used in a conditional statement to determine which implementation to return.

That's very little additional coding if you use a ternary statement, and it lets you opt-in to the mocking mechanism if/when/where you need it, instead of permiating your entire architecture with it.

Re:Astonishing Performance of .NET 5 by didibus on Thursday November 12, 2020 @02:18PM (#25073704)
Nah, ServiceLocator is another overly abstruse pattern.

What you do instead is just:

public static IMyService myService;

public static IMyService getMyService() { if myService return myService; else if(isInTest()) return mockedMyService; else return new MyProdService(wtv); }

And call that in your controller that needs to use MyService.

Re:Astonishing Performance of .NET 5 by sharpercoder on Thursday November 12, 2020 @02:39PM (#25073952)
Above code is the servicelocator pattern. It's just for one service.
Re:Astonishing Performance of .NET 5 by didibus on Friday November 13, 2020 @01:05AM (#25079412)
ServiceLocator has you create a runtime service registry where you can dynamically register and fetch instances too and from. And often that means it bypasses static type checking, as you might be adding and fetching services by name using a string.

This is different in that it's static. You don't add a service to it, it creates it the first time you ask for it (if singleton), or everytime you ask for it (otherwise), or pools it, etc.

I recon some similarities, but most enterprise "service locator" involve a lot more than this, and often are meant to give you this runtime dynamism where you can load and unload services as the app is running, etc. making them way more complex for apps that don't care about this.

Re:Astonishing Performance of .NET 5 by shireboy on Thursday November 12, 2020 @03:38PM (#25074639)
Actually, as written, myService never gets set, but I think I know what you mean. This is not thread-safe and assumes you want singleton. To use it you would in each controller do:

var service = Startup.getMyService();

And potentially know if the controller should dispose service.

This doesn't seem much less "in the way" or "massive" than:

services.AddSingleton<IMyService,MyService>();

Re:Astonishing Performance of .NET 5 by ThrowawayR2 on Thursday November 12, 2020 @10:08AM (#25070637)
Not having used .NET recently, is what they've implemented something like Spring? The description of DI everywhere and inscrutable failures at run-time remind me of that.
Re:Astonishing Performance of .NET 5 by chunkyfunky on Thursday November 12, 2020 @10:25AM (#25070830)
Not sure how Spring does it, but for example in ASP.Net Core, it's really simple. In the app startup class there is a method that's automatically called by the framework whereby it supplies a services container. In this method you "wire up" your interface->concrete mappings

  public void ConfigureServices(IServiceCollection services)
  {
      services.AddScoped<IMyDependency, MyDependency>();
  }
Later on when for e.g. an APIController is instantiated, once you've declare a constructor dependency on IMyDependency, it gets resolved for you automatically and whatever concrete class is mapped to gets created and passed to the constructor.

Outside of ASP.Net (console app for example) you can either do this manually, or you can get a ServiceCollection object from the framework, or you ca nuse a 3rd party DI library, etc.

Generally speaking if you don't configure this correctly you get a pretty simple message telling you that the container could not service the request for an IMyDependency or whatever and then it's pretty simple to figure out what you missed in the wire-up.

Re:Astonishing Performance of .NET 5 by bebop on Thursday November 12, 2020 @11:04AM (#25071249)
If you understand Spring then Asp.net Core will feel right at home. I think .Net tends to be more explicit in the configuration, with DI being no exception. For instance, in Spring you can just annotate a service with @Service and the DI framework will pick that up. In Asp.net Core, you actually have to say IThing is backed by Thing as a singleton when running the application and TestThing when running tests.

Edit: Also as others have noted, constructor injection is the way to do DI.

Re:Astonishing Performance of .NET 5 by codebolt on Thursday November 12, 2020 @03:16PM (#25074345)
Forget mocking, the major benefit of DI for me has always been proxies.

For our multi-tiered system, this means managing caching and logging of certain calls and events at the level of data access. And at the service level, it means dealing with things like authorisation.

Smart use of DI sets the system up in a way were it's easy to handle these types of cross-cutting concerns where appropriate, and with minimal boilerplate. It also simplifies refactoring.

Re:Astonishing Performance of .NET 5 by manigandham on Thursday November 12, 2020 @10:56AM (#25071152)
What exactly is the issue with DI? How else are you going to pass dependencies? How are the errors "inscrutable" when they tell you the exact type that it can't load?

Do you just want to `new SomeClass()` instead? If so, what's stopping you from just doing that?

Re:Astonishing Performance of .NET 5 by elboru on Thursday November 12, 2020 @10:13AM (#25070703)
Honest question, what does stop you from simply not using DI in .NET?
Re:Astonishing Performance of .NET 5 by shireboy on Thursday November 12, 2020 @10:24AM (#25070819)
This was going to be my question. For your own classes and services, nothing is stopping you. You can new up classes without DI all day long. ASP.NET does layer on it's things using DI, but it's boilerplate built into templates. For example, OOB you may use the built in UserManager to authenticate users and store their info in a db. If you want to customize that and NOT use the built-in, you may have 10-20 lines to write in Startup.cs to inject a different UserManager or configure the built-in one differently. I've never felt it was massive or wasted my time vs Node/express work I've done.
Re:Astonishing Performance of .NET 5 by decafninja on Thursday November 12, 2020 @11:26AM (#25071480)
Because if you don't tow the line, you'd be accused of heresy and blasphemy from the community and/or coworkers - I'm only partially joking.
Re:Astonishing Performance of .NET 5 by lodi on Thursday November 12, 2020 @01:31PM (#25073036)
"toe the line"
Re:Astonishing Performance of .NET 5 by mandeepj on Thursday November 12, 2020 @11:05AM (#25071263)
“ what does stop you from simply not using DI in .NET?”

Duh! Then how’d you wire up interfaces with implementation aka constructor injection?

Re:Astonishing Performance of .NET 5 by acupofnope on Thursday November 12, 2020 @12:14PM (#25071973)
Like so: `ISomething something = new Something();`

Construction injection is a type of DI, and it's optional, you don't have to use it.

edit: for clarity

Re:Astonishing Performance of .NET 5 by mandeepj on Thursday November 12, 2020 @02:44PM (#25074007)
OMG! I was wondering you might be proposing this. You should not be using "new" keyword anywhere in your code. If you have hard coded implementations like that in your code then how will you mock them in unit tests? I hope you'll not reply-with saying "don't write unit tests".
Re:Astonishing Performance of .NET 5 by acupofnope on Sunday November 15, 2020 @02:32PM (#25103998)
"OMG! I was wondering you might be proposing this. You should not be using "new" keyword anywhere in your code"

That sounds like dogmatism, and I'm going to take a special note of the emotionally charged language you're using here; it's symptom of some of the underlying issues I see in our industry (more to be said on this).

That said, I do agree with the sentiment in general, but you can (and sometimes should) use the `new` keyword in your code, especially when writing tests. In some cases, it makes testing so much easier and helps with the maintainability.

"I hope you'll not reply-with saying "don't write unit tests"

After 2 decades in this profession, the only think I'm sure of is there is no "silver bullet". Of course, as a general rule, it's a good idea to have a test coverage of your codebase but sometimes it's not valuable and not worth adding it. So it's a "it depends" from me!

Re:Astonishing Performance of .NET 5 by Thiez on Friday November 13, 2020 @01:24AM (#25079531)
I am a big fan of DI, but you can often get a lot of useful unit testing done when you try and keep I/O mostly seperate from the rest of the code. If you have ever programmed in Haskell you will know what I mean.
Re:Astonishing Performance of .NET 5 by RobCrusoe on Thursday November 12, 2020 @09:54AM (#25070478)
> If you don't want to write any unit tests, for which there are a myriad of reasons not to, whether you're prototyping, throwing together a small once and done for a client, etc. Then it's just a massive waste of time and gets in the way.

A massive waste of time? Adding a constructor and one line to startup.cs is a massive waste of time? Just how long does it take you?

> It's also something that if you're not working regularly with it can be very mysterious and when it fails, fails at run-time, quite inscrutably sometimes.

If DI fails it’s usually just because you’ve forgotten to add that one line to the startup.cs, and the error you get will tell you that. Can you give me a concrete example of how DI is inscrutable?

Re:Astonishing Performance of .NET 5 by dustinmoris on Thursday November 12, 2020 @11:14AM (#25071348)
To be fair there are some very questionable design decisions with ASP.NET Core. The whole way of initialising a Host and configuring things around it is a huge myriad of nested factories and builders which honestly looks like a huge mess. It's hugely overcomplicated for 95% of web applications in my opinion.
Re:Astonishing Performance of .NET 5 by nurettin on Thursday November 12, 2020 @09:08AM (#25069966)
Do use DI, it's great. It helps with structuring into entity/model/service/controller and treats DI providers as a global resource. But don't require configuration and instantiate lazily as a class member like a sane framework instead of having to pass it to constructors.
Re:Astonishing Performance of .NET 5 by KallDrexx on Thursday November 12, 2020 @09:27AM (#25070192)
Constructor DI is extremely important though, because time and time again lazily injected dependencies via properties results in circular dependencies and sometimes missing dependencies that fail at runtime. I'm not talking about simple cycles either, every time I have seen lazy dependency injection done has ended up in an A -> B -> C -> D -> A scenario.

Passing required dependencies by constructors makes this extremely apparent, not just to the DI framework but to the developers themselves. With constructor injection I can immediately grasp exactly what dependencies an object depends on without even going into the full code flow to look at all the code to find all the IOC container calls.

Edit: Also constructor injection is critical for testing dependency injection. IT allows you to have automated tests that construct every relevant object using the same DI setup as your live application and you can verify that the DI framework can resolve dependencies for everything.

If your DI is lazily done this cannot happen unless you explicitly call all code flows, opening yourself up to runtime errors that may be missed. Unit tests won't catch this because the dependencies of your production site will be different than the dependencies of your test scenarios.

Re:Astonishing Performance of .NET 5 by mumblemumble on Thursday November 12, 2020 @09:47AM (#25070417)
I'd go a step further and say that if calls to the IoC container are scattered all around your code, you're not actually doing DI. You're following the service locator antipattern.

(https://blog.ploeh.dk/2010/02/03/ServiceLocatorisanAnti-Patt...)

Re:Astonishing Performance of .NET 5 by legulere on Thursday November 12, 2020 @03:11PM (#25074286)
Dependency injection is just using passing your dependencies as interfaces, especially in the constructor. Nothing more. Dependency injection frameworks are DI combined with a service locator.

Dependency Injection Frameworks have the same issues: - understanding what is going on is harder than injecting objects by hand. - you have limited control over object lifetimes (when objects are created and disposed). Permanent, scoped and transient might be enough most of the time for a web service, but as soon as you fire off tasks that can outlive the requests or when you use it in different circumstances like UI it’s getting a problem.

Re:Astonishing Performance of .NET 5 by jolux on Thursday November 12, 2020 @03:46PM (#25074749)
The core of a DI container is generally extremely simple — objects are constructed by scanning collections of registered dependency types for matches and constructing them with the same process before passing them on. It has a recursive structure that I would even call elegant.
Re:Astonishing Performance of .NET 5 by gpderetta on Thursday November 12, 2020 @11:48AM (#25071678)
Very much so.

We are currently on a long term process of migrating a large C++ codebase from a service locator model to just passing dependencies through constructors. New code is significantly simpler to both use, understand and test.

Re:Astonishing Performance of .NET 5 by beauzero on Thursday November 12, 2020 @10:09AM (#25070657)
C# 9.0 records with init only setters is a large step to solving this issue. Still has security concerns with injection into serialized objects...it's a difficult problem to solve.
Re:Astonishing Performance of .NET 5 by jolux on Thursday November 12, 2020 @09:37AM (#25070310)
Constructor injection is the preferred way to do DI because construction is a strong guarantee that an object’s state is properly initialized.
Re:Astonishing Performance of .NET 5 by mumblemumble on Thursday November 12, 2020 @09:12AM (#25070006)
In .NET, the usual convention is that you make required things constructor arguments, so that there's no room for confusion.

Personally, I quite like that quite a bit compared to platforms and frameworks where the convention seems instead to be, "RTFM or die (at run time)."

Re:Astonishing Performance of .NET 5 by mwcampbell on Thursday November 12, 2020 @09:51AM (#25070458)
> In .NET, the usual convention is that you make required things constructor arguments, so that there's no room for confusion.

Except in Windows Forms, where the norm is a zero-argument constructor and setting everything via properties, because that approach works with component-based design-time tools. Come to think of it, I think WPF and its descendants do the same.

Re:Astonishing Performance of .NET 5 by mumblemumble on Thursday November 12, 2020 @10:33AM (#25070923)
It's been a while since I touched either WinForms or WPF, but, if I recall correctly how things worked, I don't think this is actually an exception to the convention. Don't they also make everything optional? In which case, the correct way to follow the pattern would be to also leave the constructor parameterless and configure everything via properties.
Re:Astonishing Performance of .NET 5 by ygra on Thursday November 12, 2020 @10:12AM (#25070693)
You can tell the designer how a particular type has to be created if it doesn't have a parameterless ctor, but yeah, it's generally easier to do it that way.
Re:Astonishing Performance of .NET 5 by mikewhy on Thursday November 12, 2020 @09:07AM (#25069956)
NodeJS has had various libraries to mock dependencies for a long time. So for me, I've always seen it as an extra layer on top of something that was already possible.
Re:Astonishing Performance of .NET 5 by daza on Sunday November 15, 2020 @06:06AM (#25100180)
https://www.youtube.com/watch?v=0kTq77ViAek&list=TLGGH6pJOtw... I strongly recommend this talk about DI in JS (and Angular).
Re:Astonishing Performance of .NET 5 by jolux on Thursday November 12, 2020 @09:21AM (#25070127)
NodeJS is dynamically typed.
Re:Astonishing Performance of .NET 5 by HeyHoJoe on Thursday November 12, 2020 @09:10AM (#25069989)
Going off of the dot net core 5 release thread, I assume it’s because of misunderstanding or lack of familiarity with the platform. There was a very confused top level comment that seemed to be complaining about DI and dependency drilling down several layers. That’s just not using DI at all. In general DI is a great pattern that encourages lose coupling and testability, so I also don’t get the complaint.
Re:Astonishing Performance of .NET 5 by mattmanser on Thursday November 12, 2020 @10:22AM (#25070804)
If you're talking about my comment, you couldn't be further from the truth.

I've actually worked with C# for over 15 years now and written apps with (in order of age) VBScript, webforms, web services (the MS SOAP stuff), MVC 1, MVC 2, MVC 3, MVC 4, Web API, Web API 2, the OData one I forget the name of and asp.net core. Oh and Silverlight. I've probably missed something. On yeah, WCF. And even WWF! Basically EVERYTHING web-related to C#. Plus enough work in PHP, Python, Ruby, Express, etc. to be able to compare different approaches. And even sometimes VB.net, I've maintained and then migrated entire code-bases from that to C#.

I'm not entirely sure what more familiarity I need?

I'd also note that there are a lot of other people agreeing with my in that thread, almost all of whom show a decent technical understanding. And it's got a lot of upvotes.

But, even if I "misunderstood" or have a "lack of familiarity", that speaks of how poor the design/documentation actually is. If you can so easily shoot yourself in the foot with it, it's not fit for purpose.

Re:Astonishing Performance of .NET 5 by manigandham on Thursday November 12, 2020 @10:54AM (#25071128)
None of that is familiarity with DI, which wasn't as prominent or included in the framework itself until .NET Core. Perhaps it's just not a fit for you.
Re:Astonishing Performance of .NET 5 by mattmanser on Thursday November 12, 2020 @12:44PM (#25072383)
Ironically one project I joined and then worked on for 3 years used Unity, so I was already familiar with it.

Any other reasons you think I might be unqualified to talk about the language I've been using for 15 years?

Just to cover some more bases:

1. I've worked in teams

2. I've worked alone

3. I've made apps from scratch

4. I've maintained large existing code bases

5. I've made enterprise apps, e-commerce apps, BI apps, and even just simple websites

6. Millions of people have used my code

7. Apps I made over a decade ago are still being used today

8. I admit I often forget to floss

Re:Astonishing Performance of .NET 5 by manigandham on Friday November 13, 2020 @01:09AM (#25079435)
Again, none of that means familiarity with DI. Why deflect about the language? This has nothing to do with C#.

You never answered what your actual issue with DI is (the concept, implementation, containers, etc), or what your alternative would be, even though numerous people have asked. That makes your complaint seem largely unfounded or a combination of confusion and lack of experience with DI.

Re:Astonishing Performance of .NET 5 by christophilus on Thursday November 12, 2020 @11:39AM (#25071609)
Not the OP, but I never used .NET core, but used DI pretty heavily for most of my 15 years writing C#. It was there before .NET Core. Maybe you mean it's improved with .NET Core?
Re:Astonishing Performance of .NET 5 by manigandham on Thursday November 12, 2020 @12:20PM (#25072046)
"wasn't as prominent or included in the framework itself"

There was no built-in DI container before, you had to use your own like Windsor/Autofac/Ninject/etc, and it wasn't as popular because of it as many people skipped it for smaller/less enterprise projects. I'd say exposing more people do it, even if the built-in DI is rather basic, helped improve many new projects that otherwise might not have chosen to do so.

Re:Astonishing Performance of .NET 5 by HeyHoJoe on Thursday November 12, 2020 @10:45AM (#25071044)
I don’t know if it was your comment, but you can tell me you’re the queen of Scotland for all I care. Just look at your complaint above in this thread about DI and how no one can make sense of it. If you have so much experience you hide it well.
Re:Astonishing Performance of .NET 5 by mattmanser on Thursday November 12, 2020 @12:24PM (#25072103)
Funny, I've just checked those comments and again, a bunch of people agreeing with me. Are you wearing your "I can only see comments that back my biases" glasses?

To me, it's clear that some people love DI. SOME. Use it if you want. I don't want to. Stop dictating what's "good" code to experienced developers.

If it helps you, fine, but it hinders me.

Re:Astonishing Performance of .NET 5 by HeyHoJoe on Thursday November 12, 2020 @12:50PM (#25072480)
Yeah, I can see the thread just fine, I can also see the majority of posters and the more substantive posters disagreeing with you. Also the only person who comes close to dictating anything here is you.

And I’m still not seeing the benefit of all that experience by the way.

Re:Astonishing Performance of .NET 5 by oaiey on Thursday November 12, 2020 @08:04AM (#25069390)
Regards ceremony and DI: I think the templates are more Ruby on Rails style while the framework can be trimmed down to nodejs + express simplicity. This sample here is node+express like equivalent (thanks to C# 9.0 top level statements, there is not even a Program class and a Main entry point)

    WebHost.CreateDefaultBuilder().Configure(app => 
    {
        app.UseRouting();
        app.UseEndpoints(e => 
        {
            e.MapGet("/", c => c.Response.WriteAsync("Hello world!"));
            e.MapGet("hello/{name}", c => c.Response.WriteAsync($"Hello, {c.Request.RouteValues["name"]}"));
        });
    }).Build().Run();
I also stumble over that once in a while but I have no hard feeling on it.
Re:Astonishing Performance of .NET 5 by oaiey on Thursday November 19, 2020 @04:11AM (#25147642)
This here is the official answer of the Architect of .NET David Fowler (with a full TODO use case):

https://github.com/davidfowl/Todos/blob/master/TodoBasic/Pro...

Re:Astonishing Performance of .NET 5 by rishav_sharan on Thursday November 12, 2020 @09:11AM (#25069998)
There is nothing low ceremony in .Net.

I recently ran through the entire ecosystem thinking that there must be something akin to Sinatra (micro web framework) in .Net. Nope. Every single thing is built on top of ASP .net.

I did find a WIP library where they are trying to go for a low ceremony framework https://github.com/featherhttp/framework, but even that is built on top of ASP .net

For me the worst bit about .Net is their treatment of F#. IMO, it is one of the most practical and usable functional languages out there. But none of the official docs have anything on F# at all. Here is an example doc; see if you can find any code example for F#. https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor...

Its always C#. And I have 0 interest in that kitchen sink language.

Between ASP.Net and C# being the entire world for .Net, I have really not much interest in using it for anything. There are plentiful of interesting languages and ecosystems that I can use for my small time projects.

Re:Astonishing Performance of .NET 5 by aggieben on Thursday November 12, 2020 @12:56PM (#25072558)
ASP.NET is pretty bare bones, all by itself. It's pretty much just a simple pipeline of request handlers with DI support (which is also optional). MVC, routing, Razor - all unnecessary if you don't want to use them.

I agree that the ASP.NET documentation is lacking in F# code samples (although the example you picked is a bad one as Razor doesn't support F#, and so naturally wouldn't have F# code samples). You might find that Giraffe is a more comfortable framework, as it's essentially an F#-ified shim on top of ASP.NET.

Re:Astonishing Performance of .NET 5 by kinjba11 on Thursday November 12, 2020 @07:06PM (#25077069)
A lot of this thread feels like Microsoft's terrible naming having not surprising negative consequences. "ASP.NET" can mean so many things to so many people.

To me it's usually a synonym to the full-fat MVC with controllers, DI, everything. This is reinforced by most of the dotnet templates and documentation, which make it feel like if you ask for a banana you're given a gorilla and the entire forest whether you want it or not.

In comparison, if you look at Go you'll see the "net/http" package. It's the HTTP server. Extendable. Built in - not something to download from NuGet. Only does HTTP - not reinventing its own DI, configuration management, IIS, etc.

Re:Astonishing Performance of .NET 5 by manigandham on Thursday November 12, 2020 @11:04AM (#25071248)
You can use .NET without ASP.NET. You also don't have to use all of ASP.NET either, it just comes with a full featureset and the default templates are configured for easy productivity. You can bind directly to sockets and write TCP responses using the fantastic memory and networking code, or use the robust Kestrel webserver to write low-level HTTP responses, or go up the stack and let it handle everything while you only deal with objects.

.NET supports as much ceremony as you want to deal with.

Re:Astonishing Performance of .NET 5 by dustinmoris on Thursday November 12, 2020 @11:24AM (#25071458)
> You can use .NET without ASP.NET. You also don't have to use all of ASP.NET either, it just comes with a full featureset and the default templates are configured for easy productivity

This is only true in theory, but couldn't be further away in reality.

Microsoft suffocates everything which is not built in-house 1), so there is absolutely no OSS ecosystem going on in .NET which would allow a choice of different non-ASP.NET web frameworks.

Other languages have a wealth of different web frameworks and some are super basic and lightweight and others are huge with batteries included.

You don't get that in .NET at all. Everything is ASP.NET Core, and ASP.NET Core is a typical Microsoft product - an attempt to build a one size fits all solution, the magic silver bullet to solve everyone's problems at once. Like with all silver bullets, when trying to please everybody you end up pleasing nobody.

1) Except F#. In F# you will find a more vibrant OSS community and non ASP.NET alternatives (most famously Suave), but only because Microsoft doesn't care about F#. Instead of creating an equal level playing field for C# and F# they are morphing C# into an F# hybrid and eventually will stop caring about F# even more than now.

Re:Astonishing Performance of .NET 5 by manigandham on Thursday November 12, 2020 @12:11PM (#25071938)
It's completely true in reality. I've used .NET for the last 4 startups and use various layers as needed for performance and flexibility. I know many other people and companies doing the same, and it's one of the main advantages of how much .NET gives you to pick and choose from.

ASP.NET is not a single monolithic thing, the Core evolution has made everything modular and you can plug and play the parts you want. You can use just routing to translate URLs to endpoints, or just the view engine, or just the serialization bindings, or just razor pages, or just MVC, or just low-level HTTP responses, or just GRPC, or anything else. The entire pipeline is a series of middleware, which itself layered on the Kestrel webserver, which itself is layered on low-level sockets wrapped with Pipelines and Memory APIs.

There is no one-size fits all, and asp.net explicitly recognizes and solves for it. The issue might be your expectation that there is a small/light and large/heavy framework. There isn't, you just make one to fit you.

Re:Astonishing Performance of .NET 5 by decafninja on Thursday November 12, 2020 @11:30AM (#25071535)
I'd say it's the community that suffocates everything not developed by Microsoft, not Microsoft itself directly.

It's probably a cover your ass situation, especially at the larger, more conservative, enterprise-y, non-tech companies .NET is frequently used at. No middle manager would get fired for suggesting to use a Microsoft developed & endorsed solution instead of using some hipster open source framework.

Re:Astonishing Performance of .NET 5 by rraghur on Friday November 13, 2020 @04:59AM (#25080780)
On the first part - I agree - and it's exactly this (MS's overwhelming influence on forcing direction) that keeps the .NET ecosystem back.

For ex, AFAIK, there was no community participation on DI Design and community feedback on DI design was rejected. Then it was made the default in ASP.NET.

https://blog.simpleinjector.org/2016/06/whats-wrong-with-the...

Re:Astonishing Performance of .NET 5 by zzbzq on Thursday November 12, 2020 @11:57AM (#25071780)
Well they're basically turning C# into Scala, and Scala is (rightfully) dead/dying, can't die fast enough IMO, so maybe they are just hastening the demise of C# so F# can take the throne.
Re:Astonishing Performance of .NET 5 by mdpm on Thursday November 12, 2020 @09:32AM (#25070244)
Low ceremony? Complexity in real world applications requires complexity in the frameworks that address them. Users will be more disappointed by simplicity that leaves them addressing complexity without guardrails, conventions, and tooling support.

If your view of low ceremony is matching HTTP verbs to methods, you may happily code your own against the HTTP primitives; if you want a framework that abstracts the complexity and provides a shiny-happy path, you may have to allow for some ceremony. The tooling is the antidote to this.

I think the place you trip up here is in not wanting to use a batteries included approach, while using a framework that makes the necessary abstraction/complexity tradeoffs for projects of mid to large scale. The appropriate tradeoffs _cannot_ be one size fits all.

F#'s support is tricky, as the number of users here is dwarfed by those in C#; and although .NET supports this language diversity, there are no direct idiomatic 'conversions' possible between C# and F# in many cases. This multiplies the effort of providing documentation and examples. I too would like to see it treated as a first class citizen, and for that - the code is OSS.

Re:Astonishing Performance of .NET 5 by rishav_sharan on Thursday November 12, 2020 @10:12AM (#25070692)
> I think the place you trip up here is in not wanting to use a batteries included approach, while using a framework that makes the necessary abstraction/complexity tradeoffs for projects of mid to large scale

You have hit the core of my issue here. I am more used to the node-express or golang's way of working where you start off with the smallest and simplest scaffolding and then add on the bits that you need. Rails and ASP .Net are not something I want to use for my small time projects.

Its probably unreasonable for me to expect .Net to be something completely different from what it really is, but I really hope that .Net grows up to enable other way of using it.

Re:Astonishing Performance of .NET 5 by manigandham on Thursday November 12, 2020 @12:33PM (#25072233)
(ASP).NET is also like that. The default templates just include more to start with since the platform is designed to scale to many scenarios and features.

You can trim out a lot. Take a look at the techempower benchmarks to see examples of different usage of the framework.

Re:Astonishing Performance of .NET 5 by christophilus on Thursday November 12, 2020 @11:41AM (#25071624)
> Complexity in real world applications requires complexity in the frameworks that address them.

Does it? The frameworks I use today are really, really simple. Polka on Node and Go + a few helper libraries. It's all really simple and clear what's going on, and I can solve problems of just about any complexity I've come across with just those basic tools.

Re:Astonishing Performance of .NET 5 by mdpm on Thursday November 12, 2020 @12:03PM (#25071853)
XSRF, rate limiting, permissions/RBAC, feature toggles/TIP, analytics, profiling, silly examples like recent samesite changes - Just a few examples, and that's without touching the developer tooling.

As each of these orthogonal concerns starts drifting in, applications become more and more complex as they 'tack on' support for these in code, rather than having structures in place to allow for extensions and modifications.

Abstractions always have their cost. Complexity exists in the problem domain of the web, and always will. .NET Core is generally well architected in response to a long experience in enterprise and developer concerns. It's not a magical answer to every domain's requirements, but it's generally a damn good compromise ime.

Re:Astonishing Performance of .NET 5 by christophilus on Thursday November 12, 2020 @12:53PM (#25072521)
Every one of those things is just composable middleware in the Node/Go stacks, and I think in Phoenix and most FP stacks. Middleware composition seems like the right approach to me.
Re:Astonishing Performance of .NET 5 by mdpm on Friday November 13, 2020 @05:36AM (#25080960)
.NET Core shares your opinion. Many of these are just registered/configured by default.
Re:Astonishing Performance of .NET 5 by jtdev on Thursday November 12, 2020 @10:17AM (#25070747)
> “ Complexity in real world applications requires complexity in the frameworks that address them.”

This is a dangerous way to think about complexity management.

Re:Astonishing Performance of .NET 5 by manigandham on Thursday November 12, 2020 @11:00AM (#25071201)
Why is it dangerous?
Re:Astonishing Performance of .NET 5 by mdpm on Thursday November 12, 2020 @10:56AM (#25071153)
This falls under the principle of "Complexity has to go somewhere".
Re:Astonishing Performance of .NET 5 by oaiey on Thursday November 12, 2020 @09:25AM (#25070179)
NancyFX was a Sinatra Port for .NET Framework. I belief the current .NET Core variant is called Carter.

And for sure, they are all based on ASP.NET Core. ASP.NET Core is extremely modular which allows, e.g. a middleware stack like Sinatra being built on top of ASP.NET Core's Kestrel webserver (which ... cite once again Techempower benchmarks) beats everything nearby in the current situation. It would be a horrible choice to built a web server framework right now on .NET without using Kestrel. You will never achieve to get close to the performance of that.

Re:Astonishing Performance of .NET 5 by rishav_sharan on Thursday November 12, 2020 @09:27AM (#25070206)
Yeah. I want to be able to use Kestrel without using ASP .NET.

Not very likely, but I think separating the two out would help the ecosystem a lot in the long run.

Re:Astonishing Performance of .NET 5 by oaiey on Thursday November 12, 2020 @09:54AM (#25070490)
It is technically separated out. Just shipped with .NET Core in a big framework bundle called ASP.NET Core (which is in all containers etc anyway).

Look at the techempower benchmarks implementation .. they run as close as possible to Kestrel. They have variants with raw kestrel interface, some with low-level middleware (I guess with express like routing) and then full-blown MVC like comfort.

Re:Astonishing Performance of .NET 5 by rishav_sharan on Thursday November 12, 2020 @10:00AM (#25070561)
Thanks for the pointer. I will check it out
Re:Astonishing Performance of .NET 5 by dfgdghdf on Thursday November 12, 2020 @09:15AM (#25070038)
Suave is a low ceremony web framework for .NET
Re:Astonishing Performance of .NET 5 by rishav_sharan on Thursday November 12, 2020 @09:28AM (#25070215)
I really liked Suave, but its performance I fear was too low to realistically use it for my project.

Here is the last techempower for it; https://www.techempower.com/benchmarks/#section=data-r19&hw=...

Re:Astonishing Performance of .NET 5 by thrower123 on Thursday November 12, 2020 @10:29AM (#25070875)
You could still use Nancy. It sucks a whole lot less than the pile of abstractions that have been built into ASP.NET lately.
Re:Astonishing Performance of .NET 5 by goto11 on Thursday November 12, 2020 @09:18AM (#25070072)
API's are the same for F# and C#, so it should be trivial to translate the code examples from C# into F#. Just remove the curly braces and change "var" into "let".
Re:Astonishing Performance of .NET 5 by oaiey on Thursday November 12, 2020 @10:00AM (#25070567)
F# deserves more love in their communication. Definitely. F# appeals to many, however, from a product management perspective (aka MS perspective) there is a ratio of 100 C# dev to 1 F# devs (MS showed statistics once on it).

Also, F# is community owned to my understanding (up to the statement of a MS Research Employee and F# inventor Don Syme to say that the "Microsoft." prefix on ASP.NET Core are not open source community friendly) while C# is 100% design & developed by MS.

Which - IMHO - makes it very delicate for Microsoft to communicate well here.

Re:Astonishing Performance of .NET 5 by pjmlp on Thursday November 12, 2020 @11:00AM (#25071203)
They also have a few high profile personalities that are pretty much into the "us vs them" towards C# developers and Microsoft, which turns off many enterprise developers to even bother with F#.
Re:Astonishing Performance of .NET 5 by mdpm on Thursday November 12, 2020 @11:34AM (#25071564)
This would remove the benefit of functional idioms, and mitigate any advantages the differing approaches have. F# and C# and not just syntactically different.
Re:Astonishing Performance of .NET 5 by goto11 on Thursday November 12, 2020 @01:02PM (#25072641)
True, but the code examples in the BCL documentation is to show how to use the API, not to teach the languages. See something like F# for Fun and Profit https://fsharpforfunandprofit.com/ to learn to write idiomatic F#.

More F# documentation and support from MS would be great, but IMHO F# examples in the BCL documentation would not be the best use of resources.

Re:Astonishing Performance of .NET 5 by rishav_sharan on Thursday November 12, 2020 @09:54AM (#25070480)
two problems here;

1. For a new comer to the language, this is still too much of a hurdle. 2. If I wanted to use F# only as a proxy for C#, then I would rather use C#. I want to write F# code in a functional first and idiomatic way.

This is the stock answer I have gotten in the .Net Community and as someone who wants to use F# for web apps, its a huge turn off. There are pretty much no tutorials, no recent articles and no performant native F# libraries out there. There is no push from MS to improve the situation. and the community is like - This is fine!

Expecting a new user to write c# code with "let" isn't going to fix that.

Re:Astonishing Performance of .NET 5 by piaste on Thursday November 12, 2020 @10:44AM (#25071034)
> There are pretty much no tutorials, no recent articles and no performant native F# libraries out there.

Giraffe [1] is the de facto standard F# web framework. It's a plugin on top of ASP.NET (for all the reasons described elsewhere - performance, security, ecosystem) that lets you write functional-style 'route >=> function' code without controllers.

If you want a more batteries-included approach, Saturn [2] builds on top of Giraffe to provide, well, more backend batteries (database layer, etc.)

Finally, the SAFE stack [3] are a set of project templates that combine the above with a F# frontend (via the Fable JS compiler) and some Azure deployment helpers.

[1] https://giraffe.wiki/docs

[2] https://saturnframework.org

[3] https://safe-stack.github.io/

Re:Astonishing Performance of .NET 5 by eric_b on Thursday November 12, 2020 @11:28AM (#25071513)
The .Net Core documentation is indeed a dumpster fire. As a longtime C# guy I can't even find the up-to-date "blessed" way to do things with ASP.NET anymore. They change it every version it seems. The DI/IoC stuff is definitely too pervasive, particularly in an ASP.NET context.

That said, the new C# language features really do reduce boilerplate when used judiciously - multiple return is now available, "expression-bodied properties", improved template strings etc. Lots of good stuff that is hard to find good documentation for :)

Re:Astonishing Performance of .NET 5 by rblatz on Thursday November 12, 2020 @11:51AM (#25071705)
Oh man, flashbacks to when Go style channels were added. I ended up digging through the code in github, and looking at examples from MS devs on twitter to piece together how they worked.
Re:Astonishing Performance of .NET 5 by balfirevic on Thursday November 12, 2020 @03:36PM (#25074602)
Can you clarify what you mean by Go style channels? Not sure what that refers to in .NET
Re:Astonishing Performance of .NET 5 by GordonS on Thursday November 12, 2020 @08:48AM (#25069779)
I don't really feel like there is that much more boilerplate with C# than there is with TypeScript (although I do like TypeScripts's ctor shorthand that creates members for you from ctor params).

C# 9 also brings top-level programs, which essentially eliminate all ceremony for the entrypoint[0] - an app can now be as simple as:

  using System;
  Console.WriteLine("Hello World!");
[0] https://dotnetcoretutorials.com/2020/08/30/top-level-program...
Re:Astonishing Performance of .NET 5 by brundolf on Thursday November 12, 2020 @09:36AM (#25070308)
It depends how you write TypeScript. It's explicitly designed so that you can write it like C# if you want to (classes, interfaces, enums, dependency injection), but you can just as easily compose plain data types and write plain first-class functions and never touch classes.
Re:Astonishing Performance of .NET 5 by tester34 on Thursday November 12, 2020 @08:57AM (#25069858)
Aren't top level programs basically "baby mode" for relatively simple programs or web webassembly based examples that target beginners?

As far as I've heard it does not exist e.g when it comes for ASP and I believe that what "OP" meant.

I may be very wrong here

Re:Astonishing Performance of .NET 5 by nathanaldensr on Thursday November 12, 2020 @09:07AM (#25069953)
My understanding of this feature is that it's to encourage beginners to write code that does something without first having to learn about namespaces and the entry point concept. I expect most commercial apps and open-source projects will continue to use namespaces and an entry point method in their code.
Re:Astonishing Performance of .NET 5 by whizzter on Thursday November 12, 2020 @10:15AM (#25070726)
Exactly! And on top of that I've mentioned in many conversations how teaching Java and C# as a first language often confuses people into believing that programming is about syntax rather than logic, because they spend so much time searching for syntax errors in their first hello world application.

For hello world with 29 tokens if i count correctly for C# vs 4 tokens for a Python program, guess where beginners have an easier time to fail?

Re:Astonishing Performance of .NET 5 by elboru on Thursday November 12, 2020 @10:19AM (#25070765)
It’s also great for testing concepts or libraries, “what happens if I call this object like this or like that?”

I used to use LINQPad for that, now I don’t need to, VS Code and this new feature is enough!

Re:Astonishing Performance of .NET 5 by GordonS on Thursday November 12, 2020 @09:03AM (#25069910)
I haven't used C# 9 yet, but I write a lot of console apps and services/daemons using .NET Core (the world is bigger than web apps :), but I don't see why you can't use top-level programs for ASP.NET Core apps, as they have an entrypoint too.

You would of course still have all the usual ASP.NET configuration and DI setup to do though, so the impact would be rather limited.

Re:Astonishing Performance of .NET 5 by tester34 on Thursday November 12, 2020 @09:06AM (#25069936)
>as they have an entrypoint too.

I meant that (as I've heard) you cannot write big app using "top level style" only/mostly

It probably isnt going to reduce "the boiler plate" that people complain about

Re:Astonishing Performance of .NET 5 by jolux on Thursday November 12, 2020 @09:20AM (#25070117)
It will reduce some boilerplate but only for the entry point method
Re:Astonishing Performance of .NET 5 by jpalomaki on Thursday November 12, 2020 @09:48AM (#25070421)
Maybe they were thinking about REPL, scripting and Jupyter style notebooks.

Having this feature aligns nicely with those use cases.

Re:Astonishing Performance of .NET 5 by jve on Thursday November 12, 2020 @09:38AM (#25070326)
Don't you guys think that entrypoint is only 0.0000...1% of your development time? Not having to write Namespace, class, main method (which comes in template anyway), is not something I would use to compare languages.

Its nice for beginners, not having to explain every weird word they see, but not much for professional development.

However managing complexity with various language features all over the project makes impact.

Re:Astonishing Performance of .NET 5 by recursive on Thursday November 12, 2020 @10:09AM (#25070655)
If you're working on the same code-base for years, then yes.

If you write a few programs per day for throw-away data manipulation or system maintenance or something, then no.

Re:Astonishing Performance of .NET 5 by nurettin on Thursday November 12, 2020 @09:03AM (#25069918)
.net core web is pretty much a mess. The very sight of dependency injection configuration is cringe. Even having to make the decision to go tables first or code first is a burden. I'm surprised at myself for saying this but given the chance I'd much prefer spring boot.
Re:Astonishing Performance of .NET 5 by tester34 on Thursday November 12, 2020 @09:08AM (#25069969)
>Even having to make the decision to go tables first or code first is a burden

>he very sight of dependency injection configuration is cringe.

I'm curious - why?

Re:Astonishing Performance of .NET 5 by gortok on Thursday November 12, 2020 @09:15AM (#25070044)
Coming from a different perspective: Once you've been using Entity Framework for a while (I assume the OP is referring to EF, since there tends to be a 'Use what microsoft ships' culture in the .NET community), is that the APIs available to a "Code First" approach vs. a "Model First" approach are different. If you use Code First and Code Migrations, you don't have access (without getting out of Code First entirely!) to creating Views; and in EF 6 at least, creating indexes was a chore as well. I believe this has been fixed in EF Core; but regardless the mainpoint still stands: The APIs are different and what is natively available is different. At some point doing "Code First", you'll still need to write raw SQL, and that's unexpected if you are planning on doing your work in C# only.

Regarding Dependency Injection: It's very much suited towards enterprise web applications; and its failure mode is trying to get DI to work seamlessly in a non-web application sense (C# is a general language; and .NET supports console, GUI, and web applications) and once you get out of the we application thread-per-request pipeline, you find yourself hitting rough patches.

Re:Astonishing Performance of .NET 5 by chrismeller on Thursday November 12, 2020 @09:32AM (#25070249)
I've iterated on the style of my own development over time, and I hadn't really stepped back to look at where I was now for a while. Interestingly enough, I find that I've "worked around" both of the things you mentioned in one way or another.

I use EF, but generally only for migrations, and use Dapper for all the actual access. This avoids a lot of the headache I've had in the past with EF tracking, lazy loading, and foreign keys. I also avoid using views for anything, even at work where I can guarantee with many 9's worth of certainty that I will always be using MSSQL. Part of this is because EF doesn't support it for Code-First, but part of it is also generally trying to be proactive rather than reactive and pre-generate anything I'd be using a view for. Being able to more easily switch providers and move to a different RDBMS is just a "perk" that I'll likely never take advantage of.

I despise the Microsoft DI system. I won't bother going into details, it just doesn't seem to work "right" (that is, the way I want or expect it to). On the other hand, I've used Autofac for years and just seem to "get" it, so I sometimes go to relatively great lengths to use it, even when the Microsoft version would have been a lot easier to get up and running.

Re:Astonishing Performance of .NET 5 by jolux on Thursday November 12, 2020 @09:27AM (#25070194)
I believe the smart advice says don’t go code first if you already know what you’re doing with SQL but it’s definitely sad that there’s such a huge barrier between these modes.

As for DI it can definitely be used fruitfully outside of a web application, I suggest the book Dependency Injection: Principles, Practices, and Patterns if you’re curious. It covers examples from ASP.NET Core MVC to console apps to GUI.

Re:Astonishing Performance of .NET 5 by Rayan123 on Thursday November 12, 2020 @09:20AM (#25070110)
Op HSCK 12
Re:Astonishing Performance of .NET 5 by jtdev on Thursday November 12, 2020 @10:16AM (#25070732)
EF alone is a great reason to avoid the .NET ecosystem in my experience.
Re:Astonishing Performance of .NET 5 by manigandham on Thursday November 12, 2020 @11:19AM (#25071394)
You aren't forced to use it. It's strange that a single library would make you avoid the entire ecosystem, even though it's one of the most advanced ORMs available.
Re:Astonishing Performance of .NET 5 by jtdev on Thursday November 12, 2020 @11:27AM (#25071498)
It permeates everything .NET; try finding documentation that doesn’t assume you’re an EF adherent.
Re:Astonishing Performance of .NET 5 by manigandham on Thursday November 12, 2020 @12:08PM (#25071912)
Any documentation that doesn't have to do with EF has nothing about EF. You can use whatever data access code you want. There are thousands of examples of Dapper, for example.
Re:Astonishing Performance of .NET 5 by willtim on Thursday November 12, 2020 @09:31AM (#25070237)
"Dependency injection" frameworks look to me like a hack. In a more expressive language, such as F#, one could probably describe what needs to be done symbolically, and then write interpreters that implement the different behaviours required.
Re:Astonishing Performance of .NET 5 by HeyHoJoe on Thursday November 12, 2020 @09:13AM (#25070023)
The entire web platform is a mess because of an unclear complain about configuration? You could at least try being specific if you’re going to make such stark claims.
Re:Astonishing Performance of .NET 5 by spyke112 on Thursday November 12, 2020 @08:22AM (#25069537)
> I have to say, documentation is all over the map, and the old DI / enterprisey boilerplate is still alive and well.

First of .NET has excellent documentation, right up there with the PHP. Still my favorite documentation site to snowball through sometimes.

Second, "old DI/enterprisey boilerplate" is what saves you when you get handed the project 5 years down the road, and have to be productive as fast as possible.

Edit:

> So, what’s the best-organized resource for getting up to speed on .NET these days?

Probably just the official documentation: https://docs.microsoft.com/en-us/aspnet/core/?view=aspnetcor...

Re:Astonishing Performance of .NET 5 by pianoben on Thursday November 12, 2020 @11:36AM (#25071584)
> First of .NET has excellent documentation, right up there with the PHP

.NET had excellent documentation. I still pine for the truly-comprehensive MSDN of yore (where "yore" == 2007 or so). Back then, they had less ground to cover (only one .NET Framework and it ran on Windows only), and a bigger budget to do it.

These days, and especially after the big migration to a new CMS a few years back, it's really hit-or-miss for me, especially when it comes to UI framework docs.

Re:Astonishing Performance of .NET 5 by GordonS on Thursday November 12, 2020 @08:51AM (#25069794)
There has been a lot of churn in the "Microsoft.Extensions." packages, and the docs aren't always up to date for those.

Overall though, I have to agree that the .NET docs are very good.

Re:Astonishing Performance of .NET 5 by phillipcarter on Thursday November 12, 2020 @11:54AM (#25071742)
If you want to cut down on the ceremony and use F#, check out Giraffe or Saturn.

If you want to build apps in an entirely different way that looking nothing like the wretched enterprisey nonsense of the C# and Java worlds, check out SAFE: https://safe-stack.github.io/

Re:Astonishing Performance of .NET 5 by jackfoxy on Thursday November 12, 2020 @11:34AM (#25071572)
Most people really like the Ionide VS Code plug-in for F#. I still think Visual Studio is better, but VS in its full glory is only available on Windows. Ionide should work for you.

As far as starting up F#, I try some of the resources here https://fsharp.org/

Re:Astonishing Performance of .NET 5 by modernerd on Thursday November 12, 2020 @11:39AM (#25071611)
https://fsharpforfunandprofit.com/ is also great once you have the tooling installed.
Re:Astonishing Performance of .NET 5 by oaiey on Thursday November 12, 2020 @08:19AM (#25069508)
Regards Documentation: As a fanboy this is hard to say: While there is documentation for everything, the split between .NET Framework 4.x and .NET Core/.NET 5+ is a tough thing.

However, especially in the HTTP land, the namespace give away instantly on any sample (System.Web => .NET Framework vs. Microsoft.AspNetCore => .NET Core/.NET 5+).

To speed yourself up when you have previous experience: I think the docs.microsoft.com page is not too bad on that.

Re:Astonishing Performance of .NET 5 by jen20 on Thursday November 12, 2020 @08:38AM (#25069684)
With regards to tooling, Rider is where it’s at on any platform.
Re:Astonishing Performance of .NET 5 by holtalanm on Thursday November 12, 2020 @09:03AM (#25069912)
Ive been using VSCode with the C# extension whenever I can, and it has been worlds better than Visual Studio. The only thing it has issues with is multi-solution projects.

I should say, as someone who wrote Java/Kotlin for years on IntelliJ, Rider is a welcome addition to the C# world for tooling. JetBrains really does try to produce the best editors they can.

Re:Astonishing Performance of .NET 5 by jmnicolas on Thursday November 12, 2020 @09:25AM (#25070181)
I can't comment on Rider specifically, but after 10 years of C# on VS Studio (no Resharper), I was sorely disappointed by Android studio's "intellisense" (same base as Rider afaik).

I should mention I use Dart / Flutter, this might not be a problem on Java or Kotlin.

If I don't use the right case it's unable to find the right keyword and most of the time doesn't offer the most relevant option after 'myObject.'

The other day I was joking that my main mode of programming on Visual Studio is pressing CTRL+Space and let the IDE code for me. I can't say the same thing for Android Studio.

Re:Astonishing Performance of .NET 5 by KronisLV on Thursday November 12, 2020 @11:43AM (#25071641)
I think case-insensitive auto completion is actually a setting that you can change in the IDE settings: https://www.jetbrains.com/help/idea/auto-completing-code.htm...

> Match case - Select if you want letter case to be taken into account for completion suggestions. Choose whether you want to match case for the first letter or for all letters.

Also, there are a few interesting plugins that improve the autocomplete in IntelliJ further, such as Codota: https://www.codota.com (language support varies)

Re:Astonishing Performance of .NET 5 by jen20 on Thursday November 12, 2020 @11:08AM (#25071298)
It's not the same "intellisense". The UI shell is the same, but Rider's autocompletion is provided by Resharper running out of process.

I don't know what Android Studio uses for Dart, but it's definitely not that! It's definitely not an issue for Java, Kotlin, Go, or even languages with more complex semantics like Rust.

Re:Astonishing Performance of .NET 5 by kaba0 on Thursday November 12, 2020 @10:22AM (#25070792)
That’s strange, though probably due to dart being a small language. For java and kotlin intellij absolutely blows visual studio out of the water and you really can program with only pressing ctrl+space
Re:Astonishing Performance of .NET 5 by solarkraft on Thursday November 12, 2020 @08:46AM (#25069764)
Absolutely. Visual studio is a pile of garbage in comparison and it probably reflects negatively on .NET as a platform.

They're noticeably working on making it less terribe lately, but at their current speed and considering the work ahead it's going to take multiple years until they have anything anywhere close to Rider today while JetBrains are developing it at multiple times the speed.

Drawbacks: No XAML hot reloading in WPF, lacks GUIs for Microsoft's questionable file formats (resx). That's it.

Re:Astonishing Performance of .NET 5 by mdpm on Thursday November 12, 2020 @09:34AM (#25070274)
Seconding this - as someone who's been developing software for 22+ years, using everything from SmallTalk to the MS stacks, Rider is an amazing IDE.
Re:Astonishing Performance of .NET 5 by GordonS on Thursday November 12, 2020 @08:45AM (#25069751)
Yep, I use Rider on both Windows and MacOS, and it works just as perfectly on MacOS as it does on Windows.
Re:Astonishing Performance of .NET 5 by DonnyV on Thursday November 12, 2020 @08:40AM (#25069705)
Not sure how Ruby has better documentation. This is the official Ruby docs vs .Net's https://docs.ruby-lang.org/en/2.7.0/ https://docs.microsoft.com/en-us/dotnet/

Ruby's site even does that visual thing where you can tell it was made only to be seen on Macs.

Re:Astonishing Performance of .NET 5 by steinuil on Thursday November 12, 2020 @08:46AM (#25069763)
It's been a while since I've used Ruby for anything serious, but I think most people still use https://ruby-doc.org/ for the official docs. What you linked is the site generated by rdoc, which has never looked very good.
Re:Astonishing Performance of .NET 5 by cosarara on Thursday November 12, 2020 @09:33AM (#25070261)
What visual thing?
Re:Astonishing Performance of .NET 5 by manigandham on Thursday November 12, 2020 @12:36PM (#25072269)
Light skinny fonts that are hard to read. The absolute opposite of how text on a documentation site should be.
Re:Astonishing Performance of .NET 5 by rienbdj on Thursday November 12, 2020 @08:43AM (#25069740)
For F#, VS Code and Ionide works well on all platforms.
Re:Astonishing Performance of .NET 5 by christophilus on Thursday November 12, 2020 @09:04AM (#25069928)
Not with .NET 5, though. But yeah. I may give it another shot when the tools update.
Re:Astonishing Performance of .NET 5 by modernerd on Thursday November 12, 2020 @11:20AM (#25071413)
.NET 5 support is shaping up well — progress here:

https://github.com/fsharp/FsAutoComplete/pull/656

Re:Astonishing Performance of .NET 5 by aitchnyu on Thursday November 12, 2020 @08:19AM (#25069512)
I'm also waiting for a Linux friendly way to make stateless web apps in .Net.
Re:Astonishing Performance of .NET 5 by oaiey on Thursday November 12, 2020 @09:44AM (#25070390)
So ....

    - runs on x86, x64, arm32, arm64
    - runs on Linux
    - RedHat adding RedHat specific networking adapters
    - runs in Docker
    - supports systemd as service manager
    - is faster than anything else
    - stateless is implementor's choice and easily doable
    - Redis, memcached, postgres, mysql, ... driver
    - Works on AWS and Azure on Linux OS
    - VS Code, Rider (and VS on macOS) and dotnet templates for development
I am not exactly sure what is missing.
Re:Astonishing Performance of .NET 5 by aitchnyu on Friday November 13, 2020 @08:48AM (#25082063)
I'll need tutorials about starting a new web app, running it in dev mode without ide, developing with stateless architecture and deploying it. There is a wealth of resources about developing stateful web apps in Windows+VS and deploying it to IIS but learning .net from scratch outside this norm is a huge challenge.
Re:Astonishing Performance of .NET 5 by fuzzy2 on Thursday November 12, 2020 @08:35AM (#25069661)
What qualifies a Linux-friendly way that’s currently missing?
Re:Astonishing Performance of .NET 5 by f8o on Thursday November 12, 2020 @10:08AM (#25070645)
You can gradually apply DI: if you don't want to register all of your components that's OK. Still, I think it's very useful and lightweight on .net core/.net 5. Python's Fast API has some kind of lightweight DI too... and that's great.