|
PIEBALDconsult wrote: So I was (am) very glad to find that WinForms in .net (with C# of course) was (is) so easy to use.
I agree. C# WinForms seriously took over and I left all my C++/MFC behind. Alas.
PIEBALDconsult wrote: On the other hand, I may be back to using just-plain-C soon
PIEBALDconsult wrote: Yay, C!
Yes, I agree. Or even yay, C++ (console-based like the old K&R C, but C++ would be nice.)
Unfortunately there isn't a lot of call for that type of code. Arduino (embedded) allows me to do that kind of coding. But then sometimes over there I'm like, "Why can't I do X easier? I'm limited by this doggone framework."
|
|
|
|
|
You might like this blog?!
https://moderncpp.com/
From someone who has never stopped working on C++ UI and now works at Microsoft
Basically the Microsoft recommended way of making C++ UI on Window is through UWP. And UWP is better used in C++ with moderncpp (still work in progress last I know) but can be done (in released fashion) using C++ /Cx
|
|
|
|
|
Super Lloyd wrote: And UWP is better used in C++
Hmm...I was trying to find out if you could build XAML (UWP basically XAML) UI and C++.
WPF never did get to C++ you were stuck in C# basically.
And I'm not sure that moderncpp is still going. It mentions Win/RT which I believe was left behind by MS also.
You really can't tell where MS is going with C++.
They're kind of leaving it behind....but they're kind of supporting it via Win API /SDK type of framework which is weird and old.
MS probably has no idea theirselves.
|
|
|
|
|
Well.. UWP is a failure but.. it has some redeeming qualities nonetheless.
- All new devices API (like GPS, accelerometer, etc..) they are UWP
- (relatively) easy to mix and match DirectX and XAML (i guess if you are a game developer might be good? dunno you might go 100% Unity anyway)
- Best Microsoft provided API to write GUI application in C++ IMHO, or at the very least the most modern one
- easy deployment, but stringent limitations, so it's a tossup
|
|
|
|
|
So my work is now cutting edge? That's a good laugh!
|
|
|
|
|
That's very cool because I was thinking about Win API and MFC --- where would anyone ever learn it nowadays??--- even though it is still supported.
It doesn't make any sense because someone has to be doing legacy work at least and there are plenty of examples at MS site that show that they are using Win API type of tech and when Win/RT released they were showing all the samples as Win API even though the tech is ancient.
I mean, it does still work though. MS is confusing.
|
|
|
|
|
From the release notes for VS 2019 Preview 2: The following C++ ATL/MFC wizards are no longer available: ATL COM+ 1.0 Component Wizard, ATL Active Server Pages Component Wizard, ATL OLE DB Provider Wizard, ATL Property Page Wizard, ATL OLE DB Consumer Wizard, MFC ODBC Consumer, MFC class from ActiveX control, and MFC class from Type Lib. Sample code for these technologies is archived at Microsoft Docs and the VCSamples GitHub repository.
I assume that this means that MFC is still present. Perhaps it is not installed by default (you may have to drill down in the installation program, and select it...)
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Maybe this is an effort to force C++ people to use WinRT/UWP instead of MFC.
They will end up forcing everyone to switch to Qt.
|
|
|
|
|
afigegoznaet wrote: Maybe this is an effort to force C++ people to use WinRT/UWP instead of MFC.
They will end up forcing everyone to switch to Qt.
That would serve them right! Qt for everyone.
|
|
|
|
|
I notice the event loop in the template still doesn't deal with the return from GetMessage being TRUE, FALSE or -1. For details on this little treasure of the Win32 API see the middle-bottom of the following page (under return value):
GetMessage function | Microsoft Docs[^]
Regarding MFC, I always found it a bit of a cludge in places and fairly incomplete. I often had to resort to Win32 calls to get stuff done. I recently had to do some additions to an old MFC project and started to think this wasn't all that bad...until I realised that a list control needs each line measuring to determine whether to show a horizontal scrollbar! Mercifully, you get a vertical one automatically.
When the .NET framework/Forms/WPF came along this sort of thing just went away. The API was much more complete, along with the revelation that you can still use something that looks like C++ (C++/CLI, NOT managed C++ which needed taking out the back and shooting) to program it - it seemed like a whole new world! I still use C++/CLI rather than p/invoke as I find it much cleaner where I need to get down to low level stuff or interface with pure C++ libraries.
|
|
|
|
|
Great post. I can tell you have some advanced experience with the framework.
And yes, there were incomplete things where they hadn't wrapped up stuff.
But then .NET became the twinkle in their eye and they basically left MFC behind.
|
|
|
|
|
standard microsoft practice.
they do what they want and they don't care.
if there is popular unrest that will imply negative $ outcome they'll think about it, but still do what they know is "for the good of the world". they can sustain negative $ outcome for a couple of years before they cancel the "for the good of the world" action, but in those years they will support countless trolls in the fight for their "good of the world" view.
interestingly, my developing path was the opposite of yours. i switched from turbo pascal on dos to c++ on windows programming with mfc, that's what we used in the firm. we could do some things but i soon discovered that nor me nor the seniors knew how things worked and just to say that, in c or pascal, pointers are one of my strongest points and i knew (1998 year) c++ well enough so virtual destructors, copy constructors and assignment overloading were a piece of cake for me.
then i got me the win32 forgers tutorial and later the petzold's programing windows.
i never looked back at mfc or even oop for that matter.
c++ is okay because you can switch to plain c anytime you decide. it is not c here that is important, it is the liberty to chose your style to organize the code and the liberty to pass by value or pass by reference as you like. unlike java that puts a constraint on you.
oop and graphical user interfaces got popular at the same time and they are a perfect match. gui's best match for a data type would be a hierarchy of objects.
other than that it has more weak points that strengths compared to common good programming practice.
of course "in matters of taste, there can be no disputes". my taste is for freedom.
i fight for a standard where c compilers would not issue a compile time error if you pass a "wrong" type of argument to a function without type casting, but a warning would be mandatory.
let the juniors learn programming in the most strict type safe languages, but when they come to work in c they'll have to face complete freedom and responsibility.
|
|
|
|
|
K&R C is great / required for writing interrupt handlers and low level drivers - those tasks assigned to a few selected bit fiddlers with at least ten years of experience. They can handle the freedom and responsibility. In the old days, they were assembly coders; today they are K&R C coders.
It was said that the core part of Lotus 1-2-3 (for the below 50y: The grandfather of spreadsheets) was coded in assembly to fit on a 360 Kbyte floppy. Today, you might have to code in C for your code to fit on a memory stick ... It sometimes seems like application developers have completely lost control over code size. Yet: I don't think the solution to that problem is to ve them the "complete freedom and responsibility" of K&R C - preferably not even C++. Even though the freedom is not "complete", it is too high, even in C++.
|
|
|
|
|
Great post and interesting experience.
sickfile wrote: then i got me the win32 forgers tutorial and later the petzold's programing windows.
i never looked back at mfc or even oop for that matter.
Very interesting.
sickfile wrote: let the juniors learn programming in the most strict type safe languages, but when they come to work in c they'll have to face complete freedom and responsibility.
Interesting philosophy.
I like compilers to warn me about things as much as possible. And type checking is quite helpful.
I think of "string programming" often and how that if everything is based upon a string then you can hurt yourself terribly because the "string" is only evaluated at run-time and then maybe that string has the wrong type in it and everything fails. I lean as far away from that idea as I can because those types of things can be very difficult to find in production code.
By saying this I'm not saying your advocating "string programming", it's just a way of explaining why I do like modern frameworks and compilers to a certain extent...but not beyond that extent as some things try to take it to the place where devs "dont ahve to think".
|
|
|
|
|
i am talking about providing people who have learned programming (3+ years) in the most strict type safe languages the ability to work in a language that permits to call a function defined as having one integer parameter with a floating point argument.
or something else like this:
float f;
char funct1(char c);
char b = funct1(f);
without a compile time error, only with a warning.
i ask this because you can call an assembly subroutine that does logical floating point operations on some address in memory regardless i you put in that address something that for you is logically an integer. the subroutine will do it's job.
and because the compiler sees that the function parameter should be of type char it will push to the stack frame for the function only char size data from the address of the float f.
i advocate to make C more powerful not by moving it in the java (ex-hype) direction, but in the assembler direction on one side and on the other side by working on the preprocessor to make it as powerful as LISP is.
the above floating point example is trivial and meaningless, but if you have structures composed of other structures that are hierarchically alined i am getting at something.
and of course i am not going to hire for a C programmer someone who has not learned every bit of strict data types, but when this guy starts working in C i don't want the compiler to impose restrictions on him, only warnings.
there is a big difference between a guy who values every byte and a guy who converts everything into string to avoid type errors.
|
|
|
|
|
Nice post. I understand exactly where you're coming from. One bit I can add is that I can remember, about 15 years ago, taking a relatively large application written in C++/MFC and recompiling it with C++/CX, adding .Net features, hooking it up to WCF, and even having it support auto-install when new versions were available. As far as I was concerned, that was the future.
Little did I know how strongly Microsoft was hated. Why didn't C++/CX catch on? Because it was Microsoft-only, and that meant you couldn't write software for the 5% Mac/Linux market that zealots struggled mightily to target. Then Java comes along and, though it does have some strong points, it really has nothing over VB other than it's not Microsoft.
Finally, someone figures out the right coding gymnastics and mystical incantations to get javascript to work in a browser. True, the resulting software was and still is vastly inferior, but it does have one thing going for it: It's not Microsoft! So now a generation of developers is condemned to a world where javascript is actually considered capable of making production-quality code because the users have been conditioned to accept it. So here we are now writing software whose responsiveness would make the 90's VB guys laugh all while laboring under platform burdens: *Types, what's that? *Threads, you mean link on my shirt? *Oh, F5? Yeah, don't touch that. *No, don't use that menu, that's the browser's menu. Use the menu within the menu. *No, that window can't be moved. It's just drawn to look like a window. *Sorry, you need Internet access to use the software, but have I mentioned that it doesn't require Windows to run? Yeah, I know most people still run Windows, but Windows isn't open source! <sigh>
|
|
|
|
|
Great post. It is very interesting that the weakest language choice of all (JavaScript) has become the defacto standard for coding.
I really, really like JavaScript but I also hate a lot of it. There are still no great debuggers for it -- setting them up is annoying and you don't get the kind of debugging you get from other compiled languages.
JavaScript teaches many anti-patterns of coding that have to later be torn out. And, as Internet rumors go sometimes those anti-patterns are vehemently fought for and almost become an issue of, "well, who can say really?" Meanwhile we had these better stronger languages that got ignored because of ease. Python is kind of the same travesty. Anyone can Python something. Just add a library.
|
|
|
|
|
CygnusBMT wrote: Little did I know how strongly Microsoft was hated. Why didn't C++/CX catch on? Because it was Microsoft-only I sure recognize that. It frustrates me even more in another area, one that is not MS-only, just that MS was the first major company to adopt it:
When I for the 17th time that day have to specify a password to get access to some service, I expel words that migth cause my post to be censored, if I wrote them down here. For 25+ years, we have had a very well designed solution for that.
Every time I read about another passord leak, where x million passwords have come out in the wild, I sigh: For 25+ years, we have had a very well designed solution for that.
Why should a cleartext password ever be transmitted over Internet? There is no need whatsoever for that! It is like every border crossing insisting on a specific passport for that crossing. Or a movie theater ticket where I have to specify a secret code before being allowed to use it to enter the theater.
MIT did an excellent job designing the Kerberos system. Sure, version 5 does have some functional limitations, such as safe forwarding of authorization to backend servers - but none of the solutions used today handle that! Those limitaions is definitely not the reason why Kerberos authentication was not adopted on a wide scale. Nor is it explained by any sort of "proprietary" arguments - it is free and open source code. Its origins are in the Unix world, and it standardized in the RFC series - it is not steered and controlled by some commercial company (the way e.g. Java is). It has been thoroughly testet on a wide range of operating systems. There are several (very well written) articles describing the principles, and these are well known in the academic communities.
So why are we still fighting with umpteen daily password entries, with lots of password leaks, with every service making different requirements for "secure" passwords...
The is one essential reason: When Kerberos 5 arrived, Microsoft was the first major commercial vendor to adopt it, before it had gained foothold on other platforms (notably *nix and open-source). Rather than saluting the early MS adoption, MS antagonists concluded that "If MS is going to use it, we, sure as h*** are not going to!" In theory there shouldn't be a Not Invented Here syndrome - MIT isn't Microsoft. Yet, being the first major adopter had that effect.
My guess is that if MS had held back for, say, five years, letting *nix/open-source communities be proud of the great design of Kerberos, we could have had decent network authentication and authorization for twenty years by now.
In spite of it being well known in academic cirles, there really weren't many active Kerberos proponents in non-MS environments, and the typical two-week-student-internet-project couldn't be burned by "unneccessary" functionality like authentication and authorization. Yet, I believe that if MS had kept back, it would have been promoted as The authentication solution. It is a pity that it didn't go that way.
I do think that NIH (or: the decision to adopt it wasn't driven by us) is quite essnetial. From other turf wars, such as the OSI protocol stack vs. the TCP/IP suite, I know of very explicit Not Invented Here: In the 80s, a former colleague of mine was essential in develoment of an X.400 email system. He got involved in IETF work when SMIME was being defined, and in a couple areas he suggested that a the solution developed for X.400 was adopted, both because it was well designed, and to ease mail exchange between the two mail standards. The proposal was bluntly rejected by the meeting: If X.400 does it that way, we will certainly not! We are not here to define anything OSI like! ... This X.400 expert soon learned that he might get a few good solutions through, as long as he presented it as his own thoughts, and kept shut about X.400. None of the SMIME people would touch OSI solutions with a ten foot pole, and didn't know anything about it to reveal where his ideas were found.
|
|
|
|
|
Thank you, sometimes its good to read some sanity.
Quote: So here we are now writing software whose responsiveness would make the 90's VB guys laugh all
Oh god, we now have web-browser based text editors! Type key, wait 300 ms (on a 2019 i9 with 64 GB RAM) and then the text shows on screen. I hate it.
|
|
|
|
|
I had a look at my VS2019 installation.
I had to install the Visual C++ MFC x86 and x64 before I could create a MFC desktop application.
All working as expected now.
|
|
|
|
|
I posted the update on the original post with a link to that image for others.
|
|
|
|
|
Chances are about zero that MS would drop MFC at this point, but I am still only going on indicators.
1) MS has recently redesigned all the MFC code generation templates. They were looking pretty outdated. They now have the slick look of the VS Installer now. VS 2019 Preview is their first attempt at redesigning the rest of the project creation wizard. I think it has promise. MS is even experimenting with the Office-style semantic ribbon for the aging menu-based Visual Studio. (See WinDbg x64 Preview).
2) MS has in the last year released a very critical piece of technology called ARM64 meaning your exact same MFC code re-compiled should be able to run on SnagDragon chip sets with no overhead. Think MFC for the mobile market. What framework did they release it on? MFC. See VS Installers' Individual components.
3) IMO, it was inevitable that MS would eventually migrate back to ISO standard C++. MS finally realized it shouldn't be in the business of inventing (and maintaining) computer languages. The computing world has legitimate teams of well-qualified people that do this in the ISO standards org. And MS got out, but only after trying everything else. My point is, MFC provides a "very efficient way of connecting (windows) messages to (your) message handlers (in C++)" as Jeff Prosise wrote in his MFC book many years ago, while staying within the standard maintained by the rest of the world. And according to Herb Sutter, chair of ISO C++, the number of academic papers submitted to the committee this year has increased from 120 to 200 in one year. The one thing MS has over its competitors is backwards compatibility and MFC does just that with the added plus of the world advancing it for them.
I write all my code in C++17 MFC. Never left it. I have been nervous for 15 years that MS would "embrace, expand, extinguish" MFC, but to their credit, they haven't, or more likely, they couldn't after many many attempts. It is paramount that my code be maintainable and the advances C++ has made over the years have let me do that. For example, my current app contains a real-time recursive parser which can be destructed without leaks for any depth or recursive complexity thanks to the std::shared_ptr C++ smart pointer innovation. And there are many more such innovations in the language I get for free in MFC.
|
|
|
|
|
Great post, very interseting.
rtischer8277 wrote: ARM64 meaning your exact same MFC code re-compiled should be able to run on SnagDragon chip sets with no overhead.
Very cool. I hadn't heard about that.
rtischer8277 wrote: IMO, it was inevitable that MS would eventually migrate back to ISO standard C++
That's exactly what I was thinking and hoping to always be true.
rtischer8277 wrote: "very efficient way of connecting (windows) messages to (your) message handlers (in C++)" as Jeff Prosise wrote in his MFC book many years ago,
I always thought so. Also, that Prosise book is one of my knock-down, all-time greatest favorites of the tech book world. It covered stuff like no one else did and the "story of the technology" was presented so well. It felt like he was Charles Petzold II. But sometimes better.
|
|
|
|
|
"Chances are about zero that MS would drop ..." That's what we said about OleDB back in 2012 when they announced that they were dropping it... And of course they had to bring it back last year.
Maybe they've learned?
|
|
|
|
|
Is a lazy baby kangaroo a pouch potato?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|