top | item 44622260

(no title)

database64128 | 7 months ago

> One problem with Go is the lack of fine-grained control over allocation. In particular, no arena allocation support. How does C# compare?

Go has an experimental arena package [0], but the proposal is on hold and the code may be removed in the future.

C# does not support arenas. But it does provide the stackalloc keyword, whereas in Go you kind of need the compiler's blessing for avoiding heap allocations.

> Another problem is relatively high cost of FFI interop with C. It's gotten better, but Go still needs to switch stacks, etc. How is C#?

Async in C# is implemented as stackless coroutines. Calling into FFI is cheap.

> How does C# compilation speed compare?

In my experience, release builds are a bit slower than Go.

> Does the compiler optimize more aggressively than Go (which does very little optimization)? I've heard the C# AOT compiler is lacking, but it's not clear in what way.

Not much to say on this, but with each new .NET release, a core .NET team member posts a blog post about performance improvements in the new release. The most recent one: https://devblogs.microsoft.com/dotnet/performance-improvemen...

> Does C# have the equivalent of "go run"?

  dotnet run
> What's the package management situation like?

NuGet Gallery [1] is like a centralized DLL registry. Definitely not as good as Go.

> Can you use LINQ against databases like Postgres on Linux, without having to buy into a lot of Microsoft/.NET stuff?

Probably not. This is usually done with EF Core and the Postgres provider.

[0] https://github.com/golang/go/issues/51317

[1] https://www.nuget.org/

discuss

order

banashark|7 months ago

>> Can you use LINQ against databases like Postgres on Linux, without having to buy into a lot of Microsoft/.NET stuff?

>Probably not. This is usually done with EF Core and the Postgres provider.

You can use Npgsql[0] alone or with non-EF Core interfaces, since it's just a ADO.NET Data Provider (for others: the common interface for database access in dotnet).

The GP question is interesting because it asks about using LINQ with databases "without having to buy into a lot of Microsoft/.NET stuff". I'm going to assume they mean "without using all-microsoft-sourced libraries and frameworks like Entity Framework" (since LINQ is a .NET library interface thing anways).

A couple of example of alternatives that support utilizing Npgsql for database access:

1. Linq2DB: https://linq2db.github.io

2. Dapper: https://github.com/DapperLib/Dapper?tab=readme-ov-file#will-...

3. SqlHydra: https://github.com/JordanMarr/SqlHydra?tab=readme-ov-file#co...

There are a number of other libraries, some more or less complete/maintained than others. EF and Dapper are by far the most popular libraries folks are using on top of Postgres, but there are alternatives, and using the ADO interface on its own works fine (I've done this in very small projects to limit dependencies).

[0] https://www.npgsql.org/doc/index.html