News for hackers. Stuff that matters.
Re:.NET for Beginners (2020) by imgabe on Tuesday April 20, 2021 @11:08PM (#26885005)
I'm currently trying to write a windows app and coming from web development (Python/Django and React) it is bewildering.

Part of the problem is with web development, complicated as it is, the tutorials at least get you to a complete, working example. The windows tutorials seem to be very piecemeal where you start with a mostly complete app and fill in a couple things, but never get the whole picture.

And like in your first link, click on "Desktop". Ok, I want to make a desktop app. Now there are four options WPF, WinForms, UWP and Xamarin. Ok...Why are there four options? What are the differences? Are one or more of them about to be deprecated? What do I need to consider in order to choose one over the others?

I could go on. The windows developer website did point to some helpful C# tutorials and the language is actually pretty nice to work with, but figuring out how to do basic things like -- how do I store state in the application, has been very confusing.

Re:.NET for Beginners (2020) by jiggawatts on Wednesday April 21, 2021 @12:57AM (#26885576)
> Are one or more of them about to be deprecated?

All of them are.

Not officially, of course, but practically speaking all of them are dead-ends.

MAUI is the "new hotness", which means that it'll only become obvious that it is also a dead end in about a year and a half.

I wish I was joking.

Re:.NET for Beginners (2020) by andi999 on Wednesday April 21, 2021 @02:14AM (#26885971)
At least until last year, I think the community used mostly winforms if it is for Windows operating system. MS is not too happy about that.
Re:.NET for Beginners (2020) by cosmodisk on Wednesday April 21, 2021 @07:24AM (#26888116)
Winforms is easy to use and understand, everything is pretty much there and I can get started with no issues. WPF,on the other hand,is a clusterfuck, not even sure who managed to come up with it.
Re:.NET for Beginners (2020) by valdiorn on Wednesday April 21, 2021 @12:22PM (#26891723)
There are a lot of great ideas in WPF, but sadly the implementation of those ideas is really, really clunky.

If you're experienced with WPF you can build very complex applications quickly, but the learning curve is very steep. There's also a million gotchas when it comes to performance, and when things go wrong, they go wrong bad, and you end up spending many hours trying to figure out why you're getting a stack overflow exception :)

WinForms is a joy, though, and making custom GDI+ components is easy. I just wish they made WinForms 2, called it DotNetForms, made it cross-platform and high-DPI aware.

Re:.NET for Beginners (2020) by ethbr0 on Wednesday April 21, 2021 @03:24PM (#26894265)
Seriously. Microsoft is one of the few companies with enough historical successes that teams can have "not invented here"isms about first party products.

Maybe start with why people are still using a 19 year old UI framework.

Re:.NET for Beginners (2020) by Traubenfuchs on Wednesday April 21, 2021 @06:49AM (#26887798)
Because winforms is an incredibly easy and solid technology. It's a joy to work with.
Re:.NET for Beginners (2020) by kaba0 on Wednesday April 21, 2021 @07:03AM (#26887901)
CPU rendering should not be a thing in 2021
Re:.NET for Beginners (2020) by jiggawatts on Wednesday April 21, 2021 @07:16AM (#26888035)
When WPF was first released, toy applications would make both my CPU and GPU fan spin up to gas turbine levels.

Now only WPF applications that try to show more than a dozen controls at a time make the GPU fan spin up, a huge improvement. I suppose this explains the new "flat" style with huge amounts of white space. It's not about elegance, or style -- it's the only way to keep fan speeds tolerable.

Re:.NET for Beginners (2020) by citrin_ru on Thursday April 22, 2021 @07:12AM (#26901392)
CPU GUI rendering was reasonably fast for Win32 apps on Pentium III. Modern CPU many times faster and I expect GUI rendering to use negligible fraction of CPU resources. Why this is not the case? Display resolution nowadays is higher, but the difference in pixel numbers is smaller than difference in CPU performance.
Re:.NET for Beginners (2020) by kaba0 on Thursday April 22, 2021 @07:41AM (#26901596)
Older graphics were much more simpler, like draw a line here and here, where you have to iterate through like 400px per line of a window border. Also, smaller resolution.

CPUs are fast, and rendering could be multithreaded, but 4-16 very fast cores will still be slower than the very very wide SIMD of GPUs that can simultaneously operate on many many pixels. GPUs can also change to a different “lane” to compute while it waits on IO like some graphics. You also got gradients, transparency and the like, so you basically always have to do a full pass over every pixel, so on the order of 1000*1000 pixels. So GUI rendering definitely doesn’t use negligible CPU resources. It is the canonical example for a task that can be parallelized, so it only makes sense to do so.

Re:.NET for Beginners (2020) by citrin_ru on Thursday April 22, 2021 @10:37AM (#26903239)
> smaller resolution

In early 2000s I've used a PC with 800x600px CRT monitor and one of early Intel Celerons. My memory is fuzzy, but at best it was cheapest Coppermine Celeron (more likely Mendocino). Nowadays I use notebook with Intel Core i5 2540M (quite old) and the biggest display I use has 2560x1440 pixels (much newer than notebook).

Now I have at most (2560x1440)/(800x600) ~ 8 times more pixels. I didn't find numbers from the same benchmark for Coppermine and i5 2540M, but I expect 2540M to be at least 10 times faster than slowest Coppermine.

So I think modern CPU are fast enough to render GUI at least as fast as 15-20 years ago. GPU of course can do this much faster, cannot argue with this.

> You also got gradients, transparency and the like

I wonder if users really want this or we have it for other reasons (like developers want to show-off and companies want to sell new OS/App). For me the peak GUI was around Windows 2000 - most of what come next was not really an improvement for me. I'm not representative (and mostly use i3 WM, not Windows), but the fact that Widnows XP was used well beyond official support ended and many users around the world still use Windows 7 tells that many users don't really want to follow the latest GUI trends, but instead they are forced to.

Re:.NET for Beginners (2020) by kaba0 on Thursday April 22, 2021 @11:12AM (#26903649)
Well, drawing GUIs one pixel (okay with SIMD 4-8) at a time on a CPU core is still way too big of an overkill, especially that for display it usually gets through a GPU, so it gets written to memory and then copied over vs being generated into video memory itself. A CPU core is way too expensive for these “easy” calculation, like paint it black.

And I’m not sure about the dates, but iGPUs have been around for quite some time now. Also, Windows 7 (I think the change happened at Vista) most definitely uses a compositor, so there is no CPU rendering at that level.

Re:.NET for Beginners (2020) by t-writescode on Wednesday April 21, 2021 @01:05PM (#26892356)
CPU rendering is an implementation detail for the majority of WinForms. Unless you're running the paint component command yourself, that could be offloaded elsewhere.
Re:.NET for Beginners (2020) by kaba0 on Wednesday April 21, 2021 @02:35PM (#26893687)
It is an implementation detail, but we are talking about a concrete framework with one implementation, not an open spec API. And as far as I know it visibly flickers on any window that has like more than 3 input forms.
Re:.NET for Beginners (2020) by andix on Wednesday April 21, 2021 @07:48AM (#26888334)
I can confirm that. If you don't know exactly what you are doing, don't build a desktop application. Build a web application, you are safe and protected there.
Re:.NET for Beginners (2020) by valdiorn on Wednesday April 21, 2021 @12:19PM (#26891650)
I'm sad to say I agree, because building apps with WinForms and WPF is incredibly fast and enjoyable. Using the RAD approach to application design makes it super easy to stick together working, *useful* software very quickly, that doesn't have to look terrible.

I miss the days of writing desktop software, it was nice :)

Re:.NET for Beginners (2020) by t-writescode on Wednesday April 21, 2021 @01:04PM (#26892345)
See, I'm an old and crusty person because if I'm writing some internal tooling for a company and I could use C# and we're in Windows, WinForms is the obvious answer. I never liked WPF and WinForms was drag and drop and crazy easy, so I would just use it. It's not like it's actually going away, Microsoft doesn't fully deprecate anything that could be used by any of their enterprise customers and I'm sure looooots of them use WinForms.
Re:.NET for Beginners (2020) by jhgb on Wednesday April 21, 2021 @07:14AM (#26888002)
> MAUI is the "new hotness"

Wait, I thought that Blazor Desktop was the "new hotness" this week?

Re:.NET for Beginners (2020) by JustSomeNobody on Wednesday April 21, 2021 @10:52AM (#26890424)
Here we go again...

This is why people just stick with winforms.

Re:.NET for Beginners (2020) by imgabe on Wednesday April 21, 2021 @08:51AM (#26888965)
> MAUI

What?! This wasn’t even on the list!

Re:.NET for Beginners (2020) by mrweasel on Wednesday April 21, 2021 @03:20AM (#26886375)
> Now there are four options WPF, WinForms, UWP and Xamarin. Ok...Why are there four options? What are the differences? Are one or more of them about to be deprecated?

You're most likely best of picking WinForms. It's old school, but it seems like it's going to be the one Microsoft will have the hardest time killing.

WPF, UWP and Xamarin fine frameworks, but for the 0.9X developer who just want a window, with a few input and some buttons, you can't beat WinForms in ease of use.

My reasoning is that most of the developers who saw WPF and jumped on that, are the same who will more easily jump to UWP, and from there to what ever comes next. The WinForms developer aren't moving.

Re:.NET for Beginners (2020) by Gibbon1 on Wednesday April 21, 2021 @04:05AM (#26886665)
VS + WinForms is like the Playschool Windows GUI development kit.

That sounds like talking it down, but I'm not actually.

Good for things like the sales guy wants something that pulls data out of a company database and sticks it in a excel file. And wants it tomorrow.

Re:.NET for Beginners (2020) by jiggawatts on Wednesday April 21, 2021 @08:25AM (#26888685)
As a casual programmer, I've used WinForms successfully to write both trivial and somewhat complex GUI tools. I've never been able to use WPF to write anything useful, I just couldn't scrape together the patience required to adapt to it.
Re:.NET for Beginners (2020) by andi999 on Wednesday April 21, 2021 @06:00AM (#26887446)
Getting the job done is an important aspect of a toolchain.
Re:.NET for Beginners (2020) by brtkdotse on Wednesday April 21, 2021 @03:26AM (#26886405)
> 0.9X developer

That's pretty fantastic. Stealing this!

Re:.NET for Beginners (2020) by mr_overalls on Wednesday April 21, 2021 @10:04AM (#26889838)
Meh, everybody is a 0.9X developer in many areas outside of their specialty. I'm a data engineer who specializes in security. I only need to generate a GUI or CRUD webapp once in a blue moon. So a stack that makes sane choices for me and holds my hand a bit is greatly appreciated.
Re:.NET for Beginners (2020) by mikewarot on Tuesday April 20, 2021 @11:14PM (#26885039)
I have the opposite problem. On a PC, you can always store data, the graphics display exactly how you want, the feedback is instant, and you always know the state of things. You don't ever get disconnected from the user, nor have more than one at a time.

My favorite platform is Lazarus/Free Pascal. The documentation is a bit sketchy, but the IDE and the applications it outputs seem solid. I'd prefer Delphi, but they priced themselves out of my world 20 years ago.

Re:.NET for Beginners (2020) by lostcolony on Wednesday April 21, 2021 @12:56AM (#26885572)
Wow. I knew Delphi was priced high, but I just went and looked...$1600 + $400 a year every year thereafter.

And they have a community edition...but if you make $5k or more as a consultant, -even if it's not using Delphi-, you can't use it.

Re:.NET for Beginners (2020) by munchbunny on Tuesday April 20, 2021 @11:20PM (#26885066)
> how do I store state in the application

I can’t speak for all of the challenges you might be dealing with, but this one in particular seems like something specific to native development. You have a wealth of options, and at the same time because of that fact there is are fewer defaults compared to web dev and you have to do more work to make the decision. Personally I default to two options unless performance requires otherwise: SQLite or JSON stored in files.

Re:.NET for Beginners (2020) by manigandham on Wednesday April 21, 2021 @01:07AM (#26885626)
Desktop UI is very different from web, and most languages have multiple choices. WPF is the latest Windows-only, Windows Forms is legacy (from Windows XP era), Xamarin is cross-platform. These is in the descriptions on the page, or you can click on the documentation and follow the breadcrumbs to the main topic for the Desktop Guide: https://docs.microsoft.com/en-us/dotnet/desktop/?view=netdes...

However you can just use Electron if you want to reuse web UI skills on desktop (although HN hates that). Likewise you can solve the state problem the same as a web backend. Use an external database, or a local database, write to a file, just keep it in memory, or use any of the OS-specific options. I recommend starting with EntityFramework (an ORM) and using the Sqlite provider: https://docs.microsoft.com/en-us/ef/core/get-started/overvie...

Re:.NET for Beginners (2020) by tonyedgecombe on Thursday April 22, 2021 @04:13AM (#26900162)
>WPF is the latest Windows-only

No it isn't. WinRT, UWP and WinUI are all later than WPF.

Re:.NET for Beginners (2020) by andix on Wednesday April 21, 2021 @07:46AM (#26888323)
Native UI development is a mess. On any platform. It's super complicated.

You will always be unhappy with any choice of UI framework, on any platform :)

Re:.NET for Beginners (2020) by nizmow on Wednesday April 21, 2021 @02:57AM (#26886230)
This is probably more of a Windows problem than a .NET/C# problem, but it's a very real problem.