News for hackers. Stuff that matters.
Re:My preferred .NET console stack by erikbye on Friday January 15, 2021 @11:45AM (#25792828)
Dependencies, dependencies, dependencies. All for a simple console program. And you end up with a console app that is 20-100MB. Traditionally this program was a few KB. It can still, if you use the right language(s).

Making software should not be about making the life of the developer as easy as possible, it should be about making things easy, small, and FAST for the user.

Re:My preferred .NET console stack by lol768 on Friday January 15, 2021 @12:19PM (#25793327)
> And you end up with a console app that is 20-100MB

What are you talking about? It's 1.4MB.

This is the easiest thing in the world to verify:

    $ dotnet publish -c Release           
    Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
    Copyright (C) Microsoft Corporation. All rights reserved.

      Determining projects to restore...
      All projects are up-to-date for restore.

      ConsoleApp -> /tmp/ConsoleApp/bin/Release/net5.0/ConsoleApp.dll
      ConsoleApp -> /tmp/ConsoleApp/bin/Release/net5.0/publish/


    $ cd /tmp/ConsoleApp/bin/Release/net5.0/publish/
    $ du -h
    1.4M .
And no, I don't want to hear about any figures for self-contained builds. It's an article about useful packages to help architecture your .NET console app. It's to be read in that context, where the .NET 5 runtime is available.
Re:My preferred .NET console stack by erikbye on Friday January 15, 2021 @12:39PM (#25793570)
> And no, I don't want to hear about any figures for self-contained builds.

Then what is your point? When talking about the size required for a program to run, you have to weigh all of its dependencies.

For anyone interested, such a binary ends up at least 50MB, if we include the dependencies mentioned in the article in question.

Re:My preferred .NET console stack by lol768 on Friday January 15, 2021 @01:14PM (#25794038)
> For anyone interested, such a binary ends up at least 50MB

.. if you don't make any use of assembly optimisation/trimming, sure.

    $ dotnet publish -c Release
    Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
    Copyright (C) Microsoft Corporation. All rights reserved.

      Determining projects to restore...
      Restored /tmp/ConsoleApp/ConsoleApp.csproj (in 18.97 sec).
      ConsoleApp -> /tmp/ConsoleApp/bin/Release/net5.0/linux-x64/ConsoleApp.dll
      Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
      ConsoleApp -> /tmp/ConsoleApp/bin/Release/net5.0/linux-x64/publish/
    $ cd /tmp/ConsoleApp/bin/Release/net5.0/linux-x64/publish/
    $ ls
    total 29M
> When talking about the size required for a program to run, you have to weigh all of its dependencies.

Except the dependencies might not even be relevant depending on which OS you're targeting - and in the context of this article, why is this even interesting? You can make all of the same criticisms of the JVM, or .NET web apps or anything else - do you statically link libc?

Re:My preferred .NET console stack by loic-sharma on Friday January 15, 2021 @01:25PM (#25794185)
Just to be clear, a self-contained build includes the .NET runtime and all its libraries in your build output.

Most people just install .NET on their machines. If so, that 1.4mb executable will run just fine.

Re:My preferred .NET console stack by wtetzner on Friday January 15, 2021 @02:14PM (#25794945)
The .NET framework is usually expected to be installed at the system level.

And to what extreme do you take that line of thought? Should the kernel size be included?

Re:My preferred .NET console stack by tester756 on Friday January 15, 2021 @02:47PM (#25795391)
in my opinion it is not the greatest argument

You write:

>And you end up with a console app that is 20-100MB.

Yea, but you can also say

>And you end up with a decent size app that is 20-100MB.

and also you can say

>And you end up with a decent size app that is 2MB

because you already have runtime, because you use .NET apps.

Re:My preferred .NET console stack by kcartlidge on Saturday January 16, 2021 @07:49AM (#25801892)
You may well be right for Windows. However, many command line tools need to be cross-platform, and in that situation (especially on Linux) the .NET framework/runtime very likely won't be installed.

Unless you are only doing Windows tooling, you probably do need to bear that in mind.

Re:My preferred .NET console stack by nick_ on Friday January 15, 2021 @11:53AM (#25792940)
That is demonstrably untrue. Very few users care at all about the size of an app, and even fewer devs care to put in all the extra effort to use some unfamiliar tech stack just to save their ambivalent users' machines from using up some extra, but (usually) imperceptible CPU and RAM resources.

EDIT: That said, I do wish that the trimming/tree-shaking systems could do more to get the size and speed of easy-to-code solutions way down.

Re:My preferred .NET console stack by AnIdiotOnTheNet on Friday January 15, 2021 @12:10PM (#25793184)
They do care, they've just gotten used to bloated software and therefore don't have high expectations. I submit that this is indicative of our failings as an industry.
Re:My preferred .NET console stack by WarChortle on Friday January 15, 2021 @01:19PM (#25794116)
Not a single non tech person I know has ever complained about the size of an app on download. Not one. They don't even look at the size its not relevant to them. They want to do something that some app enables. Besides how well it lets them do it no one cares about the size until they are out of space, which is usually because they have so many videos and photos stored.

You're kidding yourself if you think the average person looks at the size of an app.

Re:My preferred .NET console stack by quickthrower2 on Friday January 15, 2021 @06:03PM (#25797745)
The only case I can think of is mobile apps on slow connections. Even on a fast connection waiting a minute to download an app seems a bit annoying.
Re:My preferred .NET console stack by wongarsu on Friday January 15, 2021 @12:47PM (#25793667)
I don't see much evidence that they care until it notably impacts their free disk space, which at current storage sizes is when you reach about 1GB (or even much later, depending on your target demographic)
Re:My preferred .NET console stack by erikbye on Friday January 15, 2021 @11:58AM (#25793001)
> Very few users care at all about the size of an app

That depends on the target audience. IME the target audience of console/CLI programs are more likely to care about size. CLI apps tend to cater more to power users. And many users do definitely care about resource usage, and smaller size apps do in fact tend to use less resources.

All users definitely care about performance. A fast app feels nicer. Smaller-sized software tends to be faster. Weird correlation? I think not.

Re:My preferred .NET console stack by nick_ on Friday January 15, 2021 @12:04PM (#25793116)
I agree. Your points about size and speed are valid.

I think what made me defensive was the implication that these CLI libraries can be easily replaced with some small hand-coded solution. This particular library adds color coding, a structured help message based on the configuration, and some building blocks for DI, etc. Getting that stuff right in a hand-coded solution that isn't thousands of lines would take most developers a lot more time and effort.

Re:My preferred .NET console stack by erikbye on Friday January 15, 2021 @12:14PM (#25793245)
> these CLI libraries can be easily replaced with some small hand-coded solution.

If that was your takeaway from what I wrote that was definitely not my intention. I do not think that.

I am sure several of these libraries are well-crafted, the developer(s) behind them might be excellent and have cared a great deal about performance and did their best to optimize every function. My point was more: people tend to pull in a lot more functionality/features than they need, and the few things you do need, it is often better to write yourself (you may disagree again).

This will often give you the most optimized solution, and the one with the smallest binary.

In another HN thread, someone mentioned Unity and the size of the binary required just to display a pixel, a square, or whatever their example was--although their example was not an apple-for-apple comparison and not quite fair, the point still stands, that Unity is a general solution, and if your only requirement is drawing a pixel, of course Unity is not the correct solution.

Re:My preferred .NET console stack by watermelon0 on Friday January 15, 2021 @12:33PM (#25793489)
I deeply care about performant and small apps. I definitely don't want to have 100GB+ games on my disk, 150MB+ Electron based messaging apps, Docker images with 1GB+ node_modules/ folders, or even worse, Docker images with 600MB+ of binaries (looking at Terraform and it's plugins.)

However, I care even more about having apps/tools that help me achieve the desired goals, in an easy, clear, and elegant way.

If having bigger apps means that developers have more time to implement or improve features, and solve bugs, I'm all for it.

Re:My preferred .NET console stack by Rapzid on Friday January 15, 2021 @03:04PM (#25795607)
On a tangentially related note. Apparently the huge game sizes are on purpose these days. With downloads and storage so fast and cheap the developers ship assets in a format optimized for the in-game experience instead of space savings. Better to use more space and reduce the initial startup and loading times.

Contrast this with a game like Detroit.. It took my system(5700 XT and 3950x) what seemed like nearly 30 minutes to arrive at the menu screen due to having to compile all the shaders and who knows what else. I'm sure there were other considerations there, but still..

Re:My preferred .NET console stack by ripley12 on Friday January 15, 2021 @12:23PM (#25793377)
> And you end up with a console app that is 20-100MB.

FWIW, this is sort of a legacy of .NET's "enterprisey" history. Code size and trimming wasn't really a priority when most .NET code ran server-side or inside enterprises, now it is.

There's been a lot of work happening recently to trim .NET executables and publish them as single files, and it looks like .NET binary sizes will eventually be in the same ballpark as Go: https://blog.kalalau-cantrell.com/2021/01/make-smaller-conso...

Re:My preferred .NET console stack by oblio on Friday January 15, 2021 @01:26PM (#25794199)
Don't hold your breath. I've been keeping an eye on CoreRT and it actually slowed down and even regressed compared to Dotnet Core's rate of development while I was watching it.

I think maybe in 2016? 2018? they were committing a lot to it, probably hoping to make it production ready. Then priorities shifted and they barely advanced and now they moved it into "runtimelab" which doesn't bode well to me.

Re:My preferred .NET console stack by merb on Friday January 15, 2021 @07:59PM (#25798788)
> Don't hold your breath. I've been keeping an eye on CoreRT and it actually slowed down and even regressed compared to Dotnet Core's rate of development while I was watching it.

you do not need CoreRT for trimming. but trimming is already there: https://devblogs.microsoft.com/dotnet/app-trimming-in-net-5/

it's still a long way to go, tough.

Re:My preferred .NET console stack by ripley12 on Friday January 15, 2021 @02:37PM (#25795253)
My understanding is the opposite; now that they're planning to merge Mono and CoreCLR, there is significantly more pressure on the .NET team to have a proper AOT solution.

"Early adopters can experiment with native AOT form factor" is a priority-zero (highest priority) epic for .NET 6: https://github.com/dotnet/runtimelab/issues/248

Re:My preferred .NET console stack by manigandham on Friday January 15, 2021 @06:15PM (#25797879)
CoreRT was an experiment and it's concluded. The learnings and components like RyuJIT have now been moved to the new project called NativeAOT which has high priority.

https://github.com/dotnet/runtimelab/tree/feature/NativeAOT

Re:My preferred .NET console stack by throwawaybutwhy on Friday January 15, 2021 @01:11PM (#25793995)
> 'in the same ballpark as Go'

Not the lowest rung on the ladder.

Re:My preferred .NET console stack by lkxijlewlf on Friday January 15, 2021 @01:25PM (#25794194)
> FWIW, this is sort of a legacy of .NET's "enterprisey" history.

So is this type of boilerplate.

Re:My preferred .NET console stack by godzillabrennus on Friday January 15, 2021 @11:56AM (#25792974)
In photography they say the best camera you can own is the one you have on you when you want to take a picture. Most cameras these days are cell phones.

In software, the best software is one that was built and works to solve a problem, not necessarily one that is engineered perfectly.

Otherwise slack, chrome, etc... wouldn’t routinely eat up 1GB of ram just to open.

They do, they are well liked.

Re:My preferred .NET console stack by moksly on Friday January 15, 2021 @11:51AM (#25792905)
Beyond that, the fact that you have to do any of this is silly. The .Net tooling used to be easy, now you’ll be able of building your entire application in python before you’re even done configuring your .Net environment.

I know I’m grossly exaggerating, but the fast movement and the lack of ease of use has been one of the primary reasons to see us slowly move toward python and powershell after nearly two decades of C#. Being a windows happy enterprise org, we still make plenty of use of the .Net family and friends of course, but not really for development.

Re:My preferred .NET console stack by nightski on Friday January 15, 2021 @11:59AM (#25793023)
Who said you have to? In fact you don't at all. He's only pulling in 5 dependencies. One is a command line option parser which you'd have to pull into a python project as well. The second is a bridge for that parser to integrate with the dependency injection - which you arguably may or may not need. Third & Fourth are for logging. The last one is completely unnecessary and can be ignored. Again it's just his way of doing things.

But lets not create this false narrative that somehow .NET has become super complex. Anyone can create a console application with -

dotnet new console -n TestConsoleApp

Re:My preferred .NET console stack by switch007 on Friday January 15, 2021 @12:01PM (#25793074)
https://docs.python.org/3/howto/argparse.html

Python has an argument parser in the standard library

Re:My preferred .NET console stack by watermelon0 on Friday January 15, 2021 @12:17PM (#25793308)
Yes it has, but argparse is not even comparable to [1] Click, or similar libraries.

[1] https://click.palletsprojects.com/en/7.x/

Re:My preferred .NET console stack by switch007 on Friday January 15, 2021 @12:26PM (#25793407)
Yes but I was responding to the “have to” in: “...a command line option parser which you'd have to pull into a python project...”
Re:My preferred .NET console stack by oblio on Friday January 15, 2021 @01:18PM (#25794095)
There you go: https://docs.microsoft.com/en-us/archive/msdn-magazine/2019/...

argparse - or close to it :-)

Re:My preferred .NET console stack by majkinetor on Friday January 15, 2021 @12:00PM (#25793041)
> The .Net tooling used to be easy

Net tooling used to be horror. Now its good. Speaking as someone who does CI/CD work on it for a long time. You seem to speak as someone who doesn't have .net muscle memory.

Programming is complex, unless you finish with hello world (even hello world is complex in enterprise environments).

Re:My preferred .NET console stack by oblio on Friday January 15, 2021 @01:20PM (#25794124)
He's probably looking at it from a different angle.

As someone who has had to set up MSBuild & other BS for a CI server, I definitely agree with you.

For a dev used to double click Visual Studio, the current setups are more complex.

Re:My preferred .NET console stack by majkinetor on Saturday January 16, 2021 @10:07AM (#25802638)
Indeed.

If 'it works on my computer' is a measure, then pre dot.net core era is as good as it can get.

Re:My preferred .NET console stack by moksly on Monday January 18, 2021 @07:53AM (#25821289)
Except it isn't. We obviously had setups that mirrored production long before docker and CI/CD became a thing, but spending time configuring those things, for every project is just insane.

Even pythons virtual environments take less time to use than .NET.

Sure I actually liked the "double click" thing in Visual Studio, but that had nothing to do with "if it works on my computer", it simply saved bundles of time because we'd publish every project to the same damn IIS instance and not have them all run their independant web-servers with their independant setups.

Hell we still put things behind the same damn IIS instance and it's load balancer and all that, because why wouldn't we? We're not Netflix, we don't need to scale to two billion people. Our max load is 50.000 concurrent users, yet our build load and our deployment pipeline is now so best-practice, SOLIDVOLID, Buzzworded, CONSOLELIEK and complicated might actually work for Netflix with enough iron.

What's worse is that, it's now your job. Not the operations dude who actually specialize in this, no yours, along with keeping up with you know, actual programming.

Being the public sector, we benchmark everything, and the things we don't benchmark we hire E&Y to benchmark, and you know what our most expensive resource has seen the biggest increase of their time going into over the past 30 years? Configuring and maintaining their tooling. Not developing new things that are useful for our actual business, no sir, but working with the tools that allow them to develop things. It's up by 130% compared to 1998.

I'm not sure what you'd call that inside big-tech, but in non-tech, we tend to call that, a waste of resources.

At least we can lower the cost by vendor-lock-in with azure, right?

Re:My preferred .NET console stack by erikbye on Friday January 15, 2021 @12:23PM (#25793367)
> The .Net tooling used to be easy, now you’ll be able of building your entire application in python before you’re even done configuring your .Net environment.

> I know I’m grossly exaggerating...

I do not even think it is an exaggeration. Even the non-performant Python still feels like a hacker's, get-shit-done language compared to .Net. Anything .Net still feels like slow, enterprise bloat. Even "dotnet build/run" is slow, no matter size of your project.

https://github.com/dotnet/sdk/issues/8697

Re:My preferred .NET console stack by nend on Friday January 15, 2021 @12:07PM (#25793149)
>Making software should not be about making the life of the developer as easy as possible, it should be about making things easy, small, and FAST for the user.

Seems a bit presumptive to decide the requirements for every console app ever made. Shouldn't it be determined on a case-by-case basis whether a 20mb difference in app size matters?

Also, why exactly does a 20mb app size mean an app is too slow? I'm not really following that line of logic.

The title of the post is "My preferred .NET console stack", not "this is how every console app should be written."

Re:My preferred .NET console stack by jesseryoung on Friday January 15, 2021 @01:02PM (#25793886)
> Making software should not be about making the life of the developer as easy as possible, it should be about making things easy, small, and FAST for the user.

To be honest, I don't think the typical use case for a template like this is to "Make software", it's to solve a problem as quickly and cheaply as possible. Building software to solve these types of problems is 99% about solving the problem and 1% about how well it performs.

Re:My preferred .NET console stack by brtkdotse on Friday January 15, 2021 @12:15PM (#25793271)
> Making software should not be about making the life of the developer as easy as possible, it should be about making things easy, small, and FAST for the user.

I think you’re vastly optimistic about the ratio of ESR-“real-hacker” to “I just work here” developers, as well as the amount an end user cares if the executable is a 100kb vs 100 megs.

Re:My preferred .NET console stack by codeulike on Friday January 15, 2021 @12:02PM (#25793078)
It makes a lot of sense to make development and maintenance easy, because that is where all the costs are. Size of the resulting app only matters in certain circumstances (say, distribution of ios apps) and rarely matters for Console stuff.

Dependencies, dependencies, dependencies = Reuse, modularisation, standardisation of boilerplate

Re:My preferred .NET console stack by romanovcode on Friday January 15, 2021 @11:55AM (#25792964)
>it should be about making things easy, small, and FAST for the user.

If that would be true people would be using IRC, not Slack or Teams. Users don't care and your statement is completely false.

Re:My preferred .NET console stack by erikbye on Friday January 15, 2021 @12:01PM (#25793064)
I am not sure most users would agree with your assessment that IRC is easy. To many it is arcane.

If you created two Telegram alternatives, that was identical except for performance, would users not choose to use the most performant one?

Statistics like these (I just found at random, but there are many like it available) demonstrates that your average user do in fact care a lot about performance:

https://www.marketingdive.com/news/google-53-of-mobile-users...

Re:My preferred .NET console stack by WarChortle on Friday January 15, 2021 @01:26PM (#25794217)
In a perfect world yes they would, but how many times has the better tech died in our history. Its too many to count.

If I wrote the perfect chat app tomorrow, I'm talking universally loved by anyone who uses it. I'm not guaranteed to succeed. If someones whole family is on iMessage and they are happy they aren't going to be able to get them to switch. So they couldn't use my app if they wanted too.

Thus they stay with the "inferior" product. Average people aren't interested in the latest greatest. They just want it to work and as long as it does, they don't care about shortcomings that don't affect them. IE app size, speed(as long as its good enough)

Re:My preferred .NET console stack by prime31 on Friday January 15, 2021 @01:16PM (#25794067)
Ahhh, the good old days when people wrote quality software. I remember them fondly.
Re:My preferred .NET console stack by oblio on Friday January 15, 2021 @01:18PM (#25794107)
When were those days and how do I get back to them?

I'm being sarcastic :-)