Hacker News new | ask | show | jobs
by neonsunset 666 days ago
You will probably like .NET's CLI tooling after Python:

    brew install dotnet-sdk
    # or
    sudo dnf/apt install dotnet-sdk-8.0
    dotnet new web
    dotnet run
    curl localhost:5050
C# will give you, in some ways, Python-esque experience if you make many one-off programs as you can simply write Main as python script but with 10-50x performance. You can also go very low-level with C syntax with unsafe, or take a middle ground with performance-oriented APIs - it's a language closer to the metal than Kotlin or Go.

To build a native binary, just make a template with --aot arg. like dotnet new console --aot or do dotnet publish -p:PublishAot=true -o. {folder} (if template doesnt have it). .NET 8 build toolchain sometimes not the fastest (it's seconds but still) but .NET 9 improves upon that quite a bit.

Great for back-end, gamedev, crossplat GUI apps, low-level data-crunching with SIMD and high-level data crunching with Parallel and Task APIs, all kinds of background daemons.

2 comments

> Python-esque experience if you make many one-off programs as you can simply write Main as python script

For simple scripts, you don't even need to bother with a `Main` method anymore; you can just write statements outside of any structure like in PHP or JS: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals...

Thanks for the run down !

Though I was under the impression that C# was closely related to Microsoft services and thus Windows OS ?

Not that I mind as I also run Windows on my personal machines but could be an issue for specific projects if it was the case.

It hasn't been the case for about 8 years already :) And even before that with Mono!

The windows-only thing is a sad lie spread by people with irrational dislike to something that can make their life much better.

I daily drive it with macOS and it's awesome, a friend of mine uses it with Neovim and csharp-ls.

I see !

I will look into it as I did a bit of Java and a tiny bit of C# during my education and liked both the syntax and the OOP approach !

Just a note that C# DevKit extension in VS Code is not needed. You only ever need base C# extension[0] which gives you code completion, navigation, etc. with Roslyn LSP. Other than that, I recommend skipping complex UIs in VS or Rider for building projects for now and just using CLI - it's a much more streamlined experience.

With that said, if you have JetBrains license, Rider is great and works everywhere if you prefer rich IDE approach.

For debugging when you press F5 in VSC, it will offer you to create build and debug config - just say yes and pick the project. It will launch it next time you press F5.

[0]: https://marketplace.visualstudio.com/items?itemName=ms-dotne...