News for hackers. Stuff that matters.
Re:Support Single-File Apps in .NET 5 by kyriakos on Thursday May 21, 2020 @12:06AM (#23254690)
Even small utilities in dot net core are ridiculously big and have tens of dll files. Maybe a proper dependency management is needed so that only what parts of the framework that are actually used are included in the executable.
Re:Support Single-File Apps in .NET 5 by SideburnsOfDoom on Thursday May 21, 2020 @04:25AM (#23256048)
> so that only what parts of the framework that are actually used are included in the executable.

This "publishTrimmed=true" is demo'd in this video https://channel9.msdn.com/Events/Build/2020/BOD106

Starting around 00:46:30

Re:Support Single-File Apps in .NET 5 by giulianob on Thursday May 21, 2020 @12:13AM (#23254724)
Trimming is already supported and they're investing heavily into making it more aggressive. A web app was about 17mb in one of the demos at the conference that I saw. You can get it smaller if you make it more aggressive yourself but you may have to whitelist specific namespaces if it accidentally removes that you're using that it can't detect.
Re:Support Single-File Apps in .NET 5 by vitorgrs on Thursday May 21, 2020 @02:25AM (#23255416)
I would consider this still VERY big. It's ok for backend stuff. But now you can also use .NET --Core-- with WinForms, WPF and WinUI. That means, GUI Apps.

You'll have several GUI apps installed on user system...

UWP already handled that years ago, thought.

.msix/.appx supports dependency properly. If the app target's a new .NET version, and it doesn't have downloaded, it just.... download automatically on install. UWP .NET on Windows it's also inside .appx packages.

Re:Support Single-File Apps in .NET 5 by BitterAmethyst on Thursday May 21, 2020 @02:29AM (#23255440)
Not every use-case has an always available high-bandwidth internet connection.
Re:Support Single-File Apps in .NET 5 by moron4hire on Thursday May 21, 2020 @02:43AM (#23255501)
Yeah, I often use this feature for "small" utility programs that I want to copy around without an installer and just want to make sure they work without trouble.
Re:Support Single-File Apps in .NET 5 by Ididntdothis on Thursday May 21, 2020 @12:17AM (#23254743)
How do you make it more aggressive? Are there options in project file?
Re:Support Single-File Apps in .NET 5 by MarkSweep on Thursday May 21, 2020 @01:29AM (#23255111)
With the right flags you can get Hello World down to about 2MB of managed assemblies. You will still have about 16 MB of native:

https://github.com/AustinWise/IlLinkerExample

You basically have to directly fiddle with the flags to the IL linker to really get the size down. It's a pain. They are working on designs to make it better:

https://github.com/dotnet/designs/pull/123

I think these changes can make self contained .NET apps compare more favorably to Go apps, at least for larger applications. It would probably take something more like CoreRT to get app size to be competitive with Rust and C.

Re:Support Single-File Apps in .NET 5 by throwaway_pdp09 on Thursday May 21, 2020 @03:50AM (#23255850)
> you can get Hello World down to about 2MB

(sobs woefully)

Re:Support Single-File Apps in .NET 5 by userbinator on Thursday May 21, 2020 @09:44AM (#23258241)
In contrast, a pure Win32 Hello World (with GUI) can be 2KB or less with only the addition of some non-default linker options.

That's 3 orders of magnitude difference. Obviously it won't be as much with more complex applications, but it's still funny to see others here considering a dozen MB or so for doing something trivial to be small, when that's the size of a full installation of Windows 3.11 complete with all its built-in apps.

Re:Support Single-File Apps in .NET 5 by lukyanovic on Thursday May 21, 2020 @06:16AM (#23256716)
You can see here an example of this aggressive reduction in CoreRT https://medium.com/@MStrehovsky/building-a-self-contained-ga...
Re:Support Single-File Apps in .NET 5 by throwaway8941 on Thursday May 21, 2020 @12:37AM (#23254841)
Re:Support Single-File Apps in .NET 5 by Ididntdothis on Thursday May 21, 2020 @01:02AM (#23254968)
I think I have tried all the options but could get my app only from 180 to 150MB. It uses WPF. Maybe that’s the problem.
Re:Support Single-File Apps in .NET 5 by monadic2 on Thursday May 21, 2020 @12:30AM (#23254808)
Why not statically compile and tree-shake? If this already exists why is it not effective?
Re:Support Single-File Apps in .NET 5 by localhost on Thursday May 21, 2020 @01:17AM (#23255050)
C# Source Generators [1] will help improve things considerably re: reflection.

[1] https://devblogs.microsoft.com/dotnet/introducing-c-source-g...

Re:Support Single-File Apps in .NET 5 by randombytes6869 on Thursday May 21, 2020 @10:31AM (#23258783)
Unfortunately I have doubts. This is one of the few features copied from Java instead of the other way around. You can pre-process code in Java and generate classes at build time instead of reflecting, but I know of just a handful of libraries that leverage this.
Re:Support Single-File Apps in .NET 5 by randombytes6869 on Thursday May 21, 2020 @07:09AM (#23256990)
reflection. Same problem Java has. Too many libraries fiddling with the code at runtime.

JS is also exposed to this. Some libraries can be shaken but I've always ran into random things breaking when trying it.

Re:Support Single-File Apps in .NET 5 by jayd16 on Thursday May 21, 2020 @01:03AM (#23254974)
Breaks reflection so I don't think its the most popular way. We're talking about saving how much disk space anyway?
Re:Support Single-File Apps in .NET 5 by monadic2 on Thursday May 21, 2020 @01:12AM (#23255028)
What kind of behavior relies on reflection in C#? Is this widespread or isolatable? Is it necessary to use strings to look up symbols in C# or can you distinguish between strings and identifiers?

> We're talking about saving how much disk space anyway?

Surely this is relevant to how the customer values disk space, not the developer.

Re:Support Single-File Apps in .NET 5 by eropple on Thursday May 21, 2020 @01:19AM (#23255061)
> What kind of behavior relies on reflection in C#?

Tons. Serialization, for one, And plugin systems are commonplace.

> You have zero grounds to dictate the value of resources.

Nonsense and worse words. We know how much disk costs. It is a rounding error for the overwhelming majority of people and the overwhelming majority of apps. Prioritize what matters.

Re:Support Single-File Apps in .NET 5 by fauigerzigerk on Thursday May 21, 2020 @04:13AM (#23255971)
>We know how much disk costs. It is a rounding error for the overwhelming majority of people and the overwhelming majority of apps.

We know how much disk costs, but at any given moment a certain non-negligible share of businesses will be working with very old equipment in some of their branch offices, self-service terminals, factory floors, labs, etc.

I agree that 17 MB will rarely be a show stopper in isolation. But resource consumption is critical if Microsoft wants .NET to be a universal solution for business computing needs. Memory is far more likely to be the bottleneck in my experience.

If a company has modern equipment in 95% of their locations, but the remaining 5% are difficult to upgrade for some reason (cost of disk is unlikely to be that reason), then those 5% will determine which technologies are even taken into consideration.

Re:Support Single-File Apps in .NET 5 by febstar on Thursday May 21, 2020 @03:03AM (#23255605)
Download size and speed matters. Disk space matters especially if you're working with relatively expensive SSDs. Of course, how much of a problem this is depends on which country you're working in, company's laptop policy etc
Re:Support Single-File Apps in .NET 5 by entha_saava on Thursday May 21, 2020 @03:58AM (#23255882)
Because size is rounding error for your high-end hardware, I don't have any space left to install your app.
Re:Support Single-File Apps in .NET 5 by cm2187 on Thursday May 21, 2020 @02:58AM (#23255585)
Isn't asp.net mvc also using relying massively on reflection?
Re:Support Single-File Apps in .NET 5 by monadic2 on Thursday May 21, 2020 @01:22AM (#23255075)
> Serialization, for one

Surely this is doable statically. What is the advantage of doing this at runtime rather than at compile time?

> Nonsense and worse words. We know how much disk costs. It is a rounding error for the overwhelming majority of people and the overwhelming majority of apps. Prioritize what matters.

Got a citation? Disk space is the only variable that people even know to complain about... Not sure what you're drawing this from but it stinks to high heaven of corporate propaganda.

Re:Support Single-File Apps in .NET 5 by tester34 on Thursday May 21, 2020 @03:09AM (#23255628)
>Got a citation? Disk space is the only variable that people even know to complain about... Not sure what you're drawing this from but it stinks to high heaven of corporate propaganda.

I'm not sure where "Disk space is the only variable that people even know to complain about" did come from, but games use 100-150 GBs nowadays, so things like 17 MB are basically irrelevant unless you do verrrrrrrrry specific stuff

Re:Support Single-File Apps in .NET 5 by tluyben2 on Thursday May 21, 2020 @03:26AM (#23255726)
Not everyone, let's say me, plays games. I find it insane that I am installing software packages that take up 10s of mbs or multiple gigs in some cases. It's just plain lazy in most cases that I saw. Maybe for games it's different, but I have a 256gb ssd in my macbook and it's complaining all the time it's full, without games; I don't find anything like this irrelevant. There is almost never a need for huge packages (maybe outside games, I don't know about that, again).
Re:Support Single-File Apps in .NET 5 by monadic2 on Thursday May 21, 2020 @03:21AM (#23255694)
> I'm not sure where "Disk space is the only variable that people even know to complain about" did come from, but games use 100-150 GBs nowadays, so things like 17 MB are basically irrelevant unless you do verrrrrrrrry specific stuff

If you have a phone with 8G of space like I do, obviously games which require 150G are beyond my means. How does this work towards disk space being irrelevant?

Re:Support Single-File Apps in .NET 5 by efdee on Thursday May 21, 2020 @04:01AM (#23255901)
I'm puzzled as to what a phone has to do with .NET in this particular discussion. It's not at all about phones.
Re:Support Single-File Apps in .NET 5 by jyrkesh on Thursday May 21, 2020 @01:35AM (#23255144)
Huh? I complain about RAM usage and garbage collection CPU time in my Electron apps just plenty. And those apps are huge too. I've never once needed to uninstall an application because I needed to reclaim the disk space. Just games and media files.

If you're talking about the server side....well I think you'd save a lot more on less vCPU than a little more attached storage.

So let me put it back on you: except maybe IoT, where do you run into problems where your app takes up too much disk space?

EDIT: Maybe it's an update/bandwidth thing? Or a Docker pull time in CI? I'm trying to play devil's advocate here...

Re:Support Single-File Apps in .NET 5 by monadic2 on Thursday May 21, 2020 @01:55AM (#23255248)
> I complain about RAM usage and garbage collection CPU time in my Electron apps just plenty.

What does this have to do with C#? Surely you hold it to a higher standard than electron of all things—C# has been around for 18 years. Electron is just repackaging a browser as an app. Is this the standard to which microsoft holds themselves? Might as well sell scripts for google docs....

Re:Support Single-File Apps in .NET 5 by JamesBarney on Thursday May 21, 2020 @10:26AM (#23258734)
Widespread.

Asp.net, entity framework, anytime you use an attribute, binding, autogenerating columns based on an object.

Re:Support Single-File Apps in .NET 5 by bmm6o on Thursday May 21, 2020 @11:50AM (#23259905)
Right. It's not that "normal" C# code uses a lot of reflection, but it's useful in a lot of small places. So the chances of any given program requiring at least some is pretty high.
Re:Support Single-File Apps in .NET 5 by JamesBarney on Thursday May 21, 2020 @03:12PM (#23263483)
Yeah, I very rarely write reflection code (and 90% of the time its attribute related) but I can't remember the last time I worked on a non toy project that didn't leverage reflection somewhere.
Re:Support Single-File Apps in .NET 5 by SideburnsOfDoom on Thursday May 21, 2020 @06:33AM (#23256805)
They do tree-shake. It's mentioned in the demo linked here

https://news.ycombinator.com/item?id=23256048