15 ms·
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 / en
by christophilus 6y ago
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?
- oaiey 6y agoRegards 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.
- oaiey 6y agoThis 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/Program.cs https://github.com/davidfowl/Todos/blob/master/TodoBasic/Pro...
- oaiey 6y agoRegards 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.
- aitchnyu 6y agoI'm also waiting for a Linux friendly way to make stateless web apps in .Net.
- fuzzy2 6y agoWhat qualifies a Linux-friendly way that’s currently missing?
- oaiey 6y agoSo .... - 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.
- aitchnyu 6y agoI'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.
- hobby-coder-guy 6y agoWhat is a hot minute?
- spyke112 6y ago> 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=aspnetcore-5.0 https://docs.microsoft.com/en-us/aspnet/core/?view=aspnetcor...
- GordonS 6y agoThere 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.
- pianoben 6y ago> 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.
- jen20 6y agoWith regards to tooling, Rider is where it’s at on any platform.
- GordonS 6y agoYep, I use Rider on both Windows and MacOS, and it works just as perfectly on MacOS as it does on Windows.
- solarkraft 6y agoAbsolutely. 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.
- holtalanm 6y agoIve 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.
- jmnicolas 6y agoI 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.
- 6y ago
- DonnyV 6y agoNot 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.ruby-lang.org/en/2.7.0/ https://docs.microsoft.com/en-us/dotnet/ 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.
- steinuil 6y agoIt's been a while since I've used Ruby for anything serious, but I think most people still use https://ruby-doc.org/ https://ruby-doc.org/ for the official docs. What you linked is the site generated by rdoc, which has never looked very good.
- cosarara 6y agoWhat visual thing?
- manigandham 6y agoLight skinny fonts that are hard to read. The absolute opposite of how text on a documentation site should be.
- rienbdj 6y agoFor F#, VS Code and Ionide works well on all platforms.
- christophilus 6y agoNot with .NET 5, though. But yeah. I may give it another shot when the tools update.
- modernerd 6y ago.NET 5 support is shaping up well — progress here: https://github.com/fsharp/FsAutoComplete/pull/656 https://github.com/fsharp/FsAutoComplete/pull/656
- GordonS 6y agoI 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-programs-in-c9/ https://dotnetcoretutorials.com/2020/08/30/top-level-program...
- brundolf 6y agoIt 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.
- tester34 6y agoAren'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
- GordonS 6y agoI 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.
- tester34 6y ago>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
- shireboy 6y agoI’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?
- mikewhy 6y agoNodeJS 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.
- nurettin 6y agoDo 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.
- jolux 6y agoConstructor injection is the preferred way to do DI because construction is a strong guarantee that an object’s state is properly initialized.
- rishav_sharan 6y agoThere 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 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-pages/sql?view=aspnetcore-5.0&tabs=visual-studio 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.
- dfgdghdf 6y agoSuave is a low ceremony web framework for .NET
- rishav_sharan 6y agoI 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=ph&test=plaintext&l=yyku7z-1q https://www.techempower.com/benchmarks/#section=data-r19&hw=...
- goto11 6y agoAPI'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".
- rishav_sharan 6y agotwo 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.
- f8o 6y agoYou 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.
- eric_b 6y agoThe .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 :)
- rblatz 6y agoOh 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.
- balfirevic 6y agoCan you clarify what you mean by Go style channels? Not sure what that refers to in .NET
- jackfoxy 6y agoMost 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/ https://fsharp.org/
- modernerd 6y agohttps://fsharpforfunandprofit.com/ https://fsharpforfunandprofit.com/ is also great once you have the tooling installed.
- phillipcarter 6y agoIf 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/ https://safe-stack.github.io/
- deleted 6y ago[deleted]