Where should a programmer use C++ instead of C#?
from GreenTea2@lemmy.org to programming@programming.dev on 07 May 2026 11:00
https://lemmy.org/post/5747960

#programming

threaded - newest

bizdelnick@lemmy.ml on 07 May 2026 11:06 next collapse

Everywhere except some Windows only apps.

SleeplessCityLights@programming.dev on 07 May 2026 11:52 next collapse

It’s entirely depdent on the project and the team. Use C++ when you need something low level. Use C# when you need a very high level language and want to create an object oriented mess. Honestly, people will shit on C# all day long, but as far as utility goes, it is a fine language. People get caught up in the, well deserved, MS hate and ignore that it is a powerful performant language. Would people actually choose Java over C#? Dotnet compiles to Linux without having to install the Dotnet SDK on the Linux machine. It’s not Windows only anymore.

_tasten_tiger@feddit.org on 08 May 2026 10:48 collapse

.NET is genuinely awesome, I’d wish more people would use it

refalo@programming.dev on 07 May 2026 13:42 next collapse
  • you need predictable latency

  • you don’t want garbage collection

  • you don’t like MS

  • toolchain doesn’t exist for your target

thingsiplay@lemmy.ml on 07 May 2026 14:11 next collapse

When you don’t want to depend on .NET runtime. And if there are libraries you want to use that is available in C++, but not in C#.

e8d79@discuss.tchncs.de on 07 May 2026 18:28 collapse

When you don’t want to depend on .NET runtime.

There is an option for that in .NET.

thingsiplay@lemmy.ml on 07 May 2026 18:36 collapse

Oh wow! Since when is this possible? I looked it up, it even works with Linux (and bunch of other OSes).

Kissaki@programming.dev on 07 May 2026 18:45 next collapse

Microsoft has been working on AOT a lot for a few years now, for the last few dotnet versions. More and more became trimmable and compilable.

e8d79@discuss.tchncs.de on 07 May 2026 18:49 collapse

I think they added AOT with .NET 6 and they are supporting Linux ever since the .Net Framework, .NET Core split.

e8d79@discuss.tchncs.de on 07 May 2026 18:40 next collapse

You can use C# for pretty much anything the question is how convenient it is to do so. There are even some people who try to use .NET with embedded systems. I would use C++ only in cases where performance is the most important aspect of the product and even that niche grows smaller and smaller as time marches on. For example, at my current job we are using C# to implement some pretty intense image processing algorithms. Initially we wanted to use C++ for the performance critical parts, but we are still well within our performance targets using C# alone.

Kissaki@programming.dev on 07 May 2026 18:43 next collapse

Nowhere. Until you have a reason to.

Maybe it’s integration, or existing code, or performance, or close to hardware, or reference lib or docs

In most industries and cases, you probably won’t have to, and it makes no sense to.

TehPers@beehaw.org on 07 May 2026 19:05 next collapse

When should a programmer use C over Python?

They both solve different kinds of problems. C# has a lot of overhead built into the language compared to C++, but it is also a lot easier to write. Unless you need C++ or prefer it due to experience/performance/etc, there’s no reason to choose it over C#, JS, Python, or any other language really.

So to answer your question, thet should use C++ if they need to or will work more effectively in C++, or if the contributors want to.

moonpiedumplings@programming.dev on 07 May 2026 23:04 next collapse

When your app is written in C++ and rewriting it is too expensive.

moonpiedumplings@programming.dev on 07 May 2026 23:06 next collapse

You’re using unreal engine and not unity engine.

entwine@programming.dev on 07 May 2026 23:17 collapse

You shouldn’t be using corpo slop languages anyways. That includes Swift, Go, C#, Kotlin, etc. C++ is independent from big tech. Even though it’s so complex, there are TWO open source and independent state of the art compiler implementations (including one that’s free software).

Also Mono (open source .NET runtime for Linux) is shit, and .NET apps sometimes struggle to run on Wine. The compatibility situation will probably get worse when Microsoft adds Copilot integration directly into the .NET runtime.

Edit: if you want a similar alternative, try Haxe!

fuzzzerd@programming.dev on 08 May 2026 02:53 collapse

Mono is not great because for the last ten years Microsoft shipped .net runtime has run native on Mac and linux without wine, so mono has not been seen the investment.