Hacker News new | ask | show | jobs
by CleanRoomClub 699 days ago
My biggest hurdle when trying C# (along with a very select few other languages) is that it’s very difficult to get working properly in my own environment.

I use an apple computer and prefer to write my code in a simple text editor. Getting C# (or god forbid C++) just running in such a way that I can just focus on the code and not the surrounding environment or build tools took me long enough the last time I tried, that I decided to just not use C#.

3 comments

I'm a macOS (MBP M1) daily driver doing .NET dev professionally; it's super simple to get up and running with VS Code or even vim or emacs.

Give it another look!

When was the last time you tried C#? These days, it's as simple as getting dotnet and executing "dotnet new <template> -o MyNewProject" to make a new project. Then "dotnet run" or "dotnet watch". Also, the VSCode extension (with C# Dev Kit) is pretty good nowadays compared to other languages (I personally find it as good as rust-analyzer), but certainly not as good as Rider for enterprises; I mainly use VSCode in fact.
Seconding sibling comment, all you need is:

    brew install dotnet-sdk
    dotnet new console -o ConsoleApp --aot
    cd ConsoleApp
    dotnet publish -o .
    ./ConsoleApp
(it may take extra time for bulding it for the first time, particularly pulling in IL Compiler dependency, but all subsequent compilations will be fast)

Feel free to comment out `PublishAot` property in .csproj file if you don't want AOT (i.e. using libraries that want JIT), or use dotnet watch and run commands for quick iteration.

Note that for rich editing experience you do not need C# Dev Kit (which requires an account), only a baseline C# extension which has all the good bits. For running and debugging the project out of VS Code - upon first F5 press it will suggest generating config assets for .NET project it managed to find in an opened folder - just agree and it will work on the next F5 press.

You can also write C# with Neovim and csharp-ls.