News for hackers. Stuff that matters.
Re:Official proposal for Type Unions in C# by LtWorf on Friday August 09, 2024 @09:00AM (#41201420)
Lol trivially… unless you want to distribute your software that is.
Re:Official proposal for Type Unions in C# by neonsunset on Friday August 09, 2024 @10:39AM (#41202308)
You can make a single file executable that does not require any dependencies with just the following. No runtime is required on the host, which I assume you allude to as lacking necessary package in the official feed might cause issues if it's required (and given it's present in everything that is not Debian, it is a Debian issue and something Debian must address).

JIT: dotnet publish -p:PublishSingleFile=true -p:PublishTrimmed=true

AOT: dotnet publish -p:PublishAot=true -p:OptimizationPreference=Speed*

Use -o to specify destination.

By default targets the host's OS RID, but can be overriden with e.g. `-r linux-musl-arm64`. Cross-architecture compilation is supported within OS, and there is a nuget package that switches the publish to Zig toolchain to allow publishing for Linux under Windows without relying on WSL2: https://www.nuget.org/packages/PublishAotCross This only concerns AOT as .NET uses the same linker to produce the final binary as your regular C/C++ code. It is a true native executable through and through that is understood by all standard tooling like native code profilers. For JIT binaries, anything that .NET supports can be published for under any other OS and ISA.

* my recommendation as the size impact is negligible but codegen quality in edge cases improves quite a bit. Other flags that may be useful are -p:IlcInstructionSet=x86-x64-v3 (AVX2 and friends) and -p:IlcFoldIdenticalMethodBodies=true (it's disabled by default because it can mess up stack traces, naturally, in .NET 9, disabling stack trace information enables it as well).

Re:Official proposal for Type Unions in C# by LtWorf on Friday August 09, 2024 @12:57PM (#41203536)
> You can make a single file executable that does not require any dependencies

Which is not distribution friendly. Thanks for finally understanding you were wrong all along.

Re:Official proposal for Type Unions in C# by neonsunset on Friday August 09, 2024 @01:26PM (#41203761)
> Which is not distribution friendly.

Why is that?

Re:Official proposal for Type Unions in C# by LtWorf on Friday August 09, 2024 @03:53PM (#41204867)
Can such a monstruosity be part of a distribution? No. Then...
Re:Official proposal for Type Unions in C# by neonsunset on Friday August 09, 2024 @04:04PM (#41204952)
What makes it a monstrosity? Why should it be (or not be) a part of distribution?
Re:Official proposal for Type Unions in C# by metaltyphoon on Friday August 09, 2024 @06:45PM (#41205985)
Don’t bother he is just saying things in bad faith.
Re:Official proposal for Type Unions in C# by LtWorf on Saturday August 10, 2024 @01:33AM (#41207548)
I think you replied to the wrong comment.