News for hackers. Stuff that matters.
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.