News for hackers. Stuff that matters.
Re:Bflat: C# as you know it but with Go-like tooling by attractivechaos on Friday June 25, 2021 @05:03PM (#27636253)
I really like C# as a language, but as a Linux programmer, I found it difficult to install the dotnet sdk without the root permission. With that barrier, I can't recommend C# over Java, D or Go which are much easier to install.
Re:Bflat: C# as you know it but with Go-like tooling by josteink on Friday June 25, 2021 @05:31PM (#27636523)
> but as a Linux programmer, I found it difficult to install the dotnet sdk without the root permission

It’s a tarball. Unpack it wherever you like.

What exact problems did you have?

Edit: I’ve even “installed” the .NET SDK on ARM/Aarch64 devices this way. Zero issues.

Re:Bflat: C# as you know it but with Go-like tooling by attractivechaos on Friday June 25, 2021 @05:58PM (#27636771)
The lack of the ICU library. As you mention it, I searched around and found setting "export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true" could solve the problem. I stand corrected. Nonetheless, adding an env variable is still an extra step especially when the dotnet cli doesn't tell you what to do. An enduser has to google around to find the answer.
Re:Bflat: C# as you know it but with Go-like tooling by skneko on Friday June 25, 2021 @08:01PM (#27637720)
An "end user" will not install the SDK anyway. You do not need it to run .NET, it's for making your own apps.
Re:Bflat: C# as you know it but with Go-like tooling by VWWHFSfQ on Friday June 25, 2021 @08:07PM (#27637765)
An end user of an SDK is a developer that uses the SDK
Re:Bflat: C# as you know it but with Go-like tooling by BuckRogers on Friday June 25, 2021 @06:03PM (#27636814)
>An enduser has to google around to find the answer.

Welcome to Linux?? Not to be sarcastic but if you want your hand held install Windows for your .Net development. It's pretty nice over there.

Re:Bflat: C# as you know it but with Go-like tooling by jsight on Friday June 25, 2021 @08:02PM (#27637726)
> Welcome to Linux??

Maybe more like, "Welcome to MS tools on Linux?" There are no similar issues with installing a JDK, for example.

Re:Bflat: C# as you know it but with Go-like tooling by josteink on Saturday June 26, 2021 @05:26AM (#27640427)
The OP is complaining about needing root to satisfy som third-party library dependency (libicu) when installing the .NET SDK outside the system package-manager, with the tarball only.

I think that’s a pretty far fetched complaint. There are tons of software out there on Linux which will break if you don’t satisfy their dependencies.

I’m sure the OpenJDK-tarball has some system-wide dependencies too (libssl?), but you can’t tell that because you probably installed it as root, using a package-manager instead.

If you do the same with the .NET SDK (use root, install via package-manager) you will find everything working equally smooth.

Re:Bflat: C# as you know it but with Go-like tooling by jsight on Saturday June 26, 2021 @11:02PM (#27648153)
I generally do install JDKs as root from the system's package manager. This is primarily due to the system integration that it provides.

However, I often keep a collection of older versions and different patch levels in my home directory. These work fine for testing with the non-openjdk distributions for compatibility purposes.

I wasn't familiar with the icu library issue, so maybe it is something straightforward, but it seems odd that the fix was an env var. I certainly wouldn't say something like "welcome to linux" because of a scenario like this.

Re:Bflat: C# as you know it but with Go-like tooling by josteink on Sunday June 27, 2021 @08:09AM (#27650928)
> I often keep a collection of older versions and different patch levels in my home directory.

And they are obviously going to work because you’ve satisfied all the main OpenJDK dependencies through the install with your package-manager.

If you repeat your own scenario with the .NET SDK instead, you will have the exact same experience.

Re:Bflat: C# as you know it but with Go-like tooling by jsight on Monday June 28, 2021 @10:16AM (#27662277)
That's actually not true. They'd work even if I removed the main one.

Its how I did it before the distribution packaged OpenJDK, which really wasn't that long ago.

Re:Bflat: C# as you know it but with Go-like tooling by attractivechaos on Saturday June 26, 2021 @01:29PM (#27643919)
Have you installed jdk before? I installed jdk quite a few times without root and never had a problem. Jdk only depends on essential system libraries like libc. It ships other necessary libraries in the tar-ball. Do you have a reference to your claim that Java requires libssl?
Re:Bflat: C# as you know it but with Go-like tooling by josteink on Sunday June 27, 2021 @08:14AM (#27650963)
> I installed jdk quite a few times without root and never had a problem. Jdk only depends on essential system libraries like libc.

The Ubuntu repos suggests there are more dependencies than just plain libc.

https://packages.ubuntu.com/hirsute/openjdk-11-jre

Could it be you have those dependencies satisfied through other things you’ve already installed?

> Do you have a reference to your claim that Java requires libssl?

None at all. It was an example of something I found it reasonable it might depend on, since .NET also depends on that on Linux :)

Re:Bflat: C# as you know it but with Go-like tooling by jsight on Monday June 28, 2021 @10:17AM (#27662288)
The package manager provided distributions tend to have different dependencies than the tarballs from Oracle.
Re:Bflat: C# as you know it but with Go-like tooling by cebert on Friday June 25, 2021 @05:27PM (#27636488)
You don’t need to install the SDK to run a dotnet core app. They can ship what’s required to run and there’s even single executable options now as well.
Re:Bflat: C# as you know it but with Go-like tooling by spaetzleesser on Friday June 25, 2021 @08:01PM (#27637721)
One caveat: If you ship a self contained app you often end up with 200MB of assemblies to ship. and the single file executables tend to load very slowly. It's basically an archive that first gets extracted and then executed. I had to give that up with a recent app because it was just too slow.
Re:Bflat: C# as you know it but with Go-like tooling by GordonS on Saturday June 26, 2021 @05:01AM (#27640334)
This hasn't actually been the case since dotnet Core 2.

Since dotnet Core 3, you can use assembly trimming to remove unused assemblies. That results in a package of around 10MB for a Hello World app, or more like 40-70MB for large, real-world apps.

From dotnet 5 there is also member trimming, which will trim unused parts of assemblies, which will further reduce the size. I haven't used this yet, but Microsoft claim it can result in packages 5x smaller than with assembly trimming, e.g. only 2MB for a Hello World app.

There is also AOT compilation, but I wouldn't hold my breath on seeing that become production-ready any time soon (Microsoft have been hyping it and saying it's "coming soon" for 10 years or so).

Re:Bflat: C# as you know it but with Go-like tooling by Measter on Saturday June 26, 2021 @06:49AM (#27640818)
I just tried it on a small project of mine. It's 955 lines of C#[0], 6 dependencies, already configured for publishing a single file, self contained, for win-x64, ready to run. I built in release mode with publish trimmed, and trim mode set to link. The final size of the binary is 24.6 MB (not counting CLR DLLs), with a build time of 23.2[1] seconds.

I also have a Rust version of the project. 710 lines of Rust[0], 128 total dependencies in the tree, building in release mode with the MSVC Windows compiler. Final size of the binary is 2.29 MB, build time of 22.2[1] seconds.

Things are not great when your build times rival Rust's, and the output is slower and an order of magnitude bigger.

[0] Note that the C# version does have more robust handling when writing its output file than the Rust version, which adds couple dozen lines. Also the style conventions for brackets puts opening brackets on a new line for C#, the same line for Rust.

[1] Measured with hyperfine configured to run "dotnet clean -c Release" and "cargo clean" before each run.

Re:Bflat: C# as you know it but with Go-like tooling by GordonS on Saturday June 26, 2021 @10:58AM (#27642408)
FWIW, I reckon 25MB forba self-contained build is pretty good! Build times are annoyingly if you use trimming tho, I'll certainly agree there.

But Rust is such a very different beast than dotnet, that I'm unconvinced it's a useful comparison; IMO a better comparison would be Golang.

Re:Bflat: C# as you know it but with Go-like tooling by e12e on Saturday June 26, 2021 @08:12AM (#27641198)
> not counting CLR DLLs

Why would you exclude those in this comparison - they're already (guaranteed to be) installed on your windows targets?

How about linux/Mac targets?

I think 20-30MB is quite good - puts it in the ballbark of golang.

2MB+ for rust actually sounds a bit big -that's stripped?

Re:Bflat: C# as you know it but with Go-like tooling by Measter on Saturday June 26, 2021 @10:05AM (#27641961)
> > not counting CLR DLLs

> Why would you exclude those in this comparison - they're already (guaranteed to be) installed on your windows targets?

Note that this is a stand-alone build; it doesn't require the runtime to be installed. With that in mind, you're right they should be included, which would increase the build size by 8.3 MB.

> How about linux/Mac targets?

I can't build a Mac target because I don't have a Mac. I just built for a linux-x64 target in WSL, and the resulting binary is 35.0 MB. The Linux build looks like it's packaged the CLR into the main binary instead of keeping them separate, which would account for the greater size.

I did do a benchmark with hyperfine, which gave a 25.5 second build time. However, this is on WSL1 building off and on to an NTFS drive, which has known performance issues.

> I think 20-30MB is quite good - puts it in the ballbark of golang.

I've never used Go, but my understanding is that the Go compiler is very fast but doesn't do as much in the way of optimizations. If that's the case, having a larger and slower binary compared to Rust would be expected before you get to the packaged runtime.

The issue I'm taking here is that doing a trimmed dotnet build is (in this case) giving the same build time as Rust, but is only doing some AoT compilation and dead-code elimination. Rust is already doing that in addition to a whole host of other optimizations.

From a user perspective, this feels like dotnet is giving me a worse end product for the same time taken. Especially given the Rust version wasn't harder to write than the C# version (in fact, due to bad documentation the C# version was harder).

> 2MB+ for rust actually sounds a bit big -that's stripped?

No, that is not stripped, and with the standard release profile.

Re:Bflat: C# as you know it but with Go-like tooling by spaetzleesser on Saturday June 26, 2021 @01:13PM (#27643724)
Maybe this is better for command line and server stuff. The app I was building used WPF with Core 3. The regular size was 180MB if built as self contained. Trimming took off maybe 30 MB but build times were painfully long. And the initial load took around 30 secs or more on some machine.
Re:Bflat: C# as you know it but with Go-like tooling by GordonS on Saturday June 26, 2021 @05:35PM (#27646115)
I haven't used WPF in 10 years or so. Come to think of it, I haven't done any desktop stuff with .NET Core at all - wow, 180MB is pretty damn big!

Just took a look at my current project, which has several components: an ASP.NET web UI is 80MB, an ASP.NET API is 65MB, and backend services range from 40-55MB (these are all pretty complex, production-grade components).

Re:Bflat: C# as you know it but with Go-like tooling by kqr on Saturday June 26, 2021 @04:57AM (#27640312)
Yes, this deployment option makes tradeoffs that are clearly more in line with the use case of pushing out long-running server applications to machines with minimal configuration, rather than for desktop user applications.
Re:Bflat: C# as you know it but with Go-like tooling by spaetzleesser on Saturday June 26, 2021 @01:15PM (#27643744)
That’s my impression too. Seems these days in general desktop applications are more of an afterthought in the .NET world and most new features are built mainly for server stuff.
Re:Bflat: C# as you know it but with Go-like tooling by boudin on Saturday June 26, 2021 @02:45AM (#27639718)
Re:Bflat: C# as you know it but with Go-like tooling by e12e on Saturday June 26, 2021 @08:07AM (#27641174)
Of all the possible ways to handle toolchains on Linux, I'm quite happy with asdf[1]. I've successfully built stand-alone fsharp/csharp "Hello worlds" off of dotnet via asdf - but I've not used dot.net in anger.

I chiefly like asdf because I typically need at least two toolchains (with various versions for various projects) - eg ruby and nodejs, or python and nodejs.

https://asdf-vm.com/

https://github.com/emersonsoares/asdf-dotnet-core