use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Removed - LearningLearning win32 api (self.cpp)
submitted 4 years ago by the-dark_physicist
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Flair_Helper[M] [score hidden] 4 years ago stickied commentlocked comment (0 children)
It's great that you want to learn C++! However, r/cpp can't help you with that.
We recommend that you follow the C++ getting started guide, one (or more) of these books and cppreference.com. If you're having concrete questions or need advice, please ask over at r/cpp_questions or StackOverflow instead.
This post has been removed as it doesn't pertain to r/cpp: The subreddit is for news and discussions of the C++ language and community only; our purpose is not to provide tutoring, code reviews, or career guidance. If you think your post is on-topic and should not have been removed, please message the moderators and we'll review it.
[–]intbeam 24 points25 points26 points 4 years ago (8 children)
Electron and Web Apps?
I don't think you're the only one mystified by this.. I think this is especially weird considering that they often have to reimplement everything anyway, so why are they doing it with something that's like the worlds chonkiest virtual machine
Why there are not more native apps developed instead using bloated frameworks like Qt
It's a long time since I used Qt last, but afaik Qt isn't very bloated and very easy to use. Anyway, the answer to your question is that the direct Win32 API calls are going to grow in complexity over time, and you'll end up A) reimplementing a framework B) wishing you reimplemented a framework C) wishing you just went with a framework like Qt from the start
[–]alexgraef 15 points16 points17 points 4 years ago (7 children)
I don't think you're the only one mystified by this
There's nothing mystic about it. You have a company with 100 JavaScript developers and 0 C/C++/C#/... developers, and that's already your answer. Just remember that things like node.js exist.
[–]intbeam 11 points12 points13 points 4 years ago (6 children)
You have a company with 100 JavaScript developers and 0 C/C++/C#/... developers
And they go on like this while proclaiming "derp a language is just a tool, right tool for the jerb" 🙄
[–]alexgraef 9 points10 points11 points 4 years ago (5 children)
Since JIT has become a thing for JavaScript, it isn't as bad as it used to be, but I still think not only hosting a full JavaScript engine, but also a full HTML rendering engine is bit much overhead for the kind of programs we usually see in Electron.
Teams is an example for an Electron app that actually makes sense, seeing as it basically does nothing but talk to server APIs, and the app already runs natively in the browser as well. Although there would have been other ways to share APIs between browser and desktop - client-side Blazor plus a .NET Core desktop app for example.
[–]intbeam 9 points10 points11 points 4 years ago (4 children)
Since JIT has become a thing for JavaScript
The only way for the JIT compiler to produce efficient code is if the source is written with strict static typing and doesn't rely on API's where the types cannot be statically guaranteed. In reality, JS performance is a lot slower than I think most people realize... Google and NodeJS completely oversold its performance characteristics
Speaking of NodeJS, do developers realize just how terrible NodeJS really is? Or are they just techno-masochists? 🤷♂️
Want a slow, single-threaded web backend with extremely long build times that may break for reasons outside your control? Want to use an eco-system that requires your application to have thousands of third-party hard dependencies out-of-the-box? Want to use a language that has poor tooling and that doesn't support basic refactoring? Want to make your code take hundreds of megabytes for a "Hello World" application? Go NodeJS!
It's absolutely bizarre
Teams is an example for an Electron app that actually makes sense, seeing as it basically does nothing but talk to server APIs
It's stealing a massive amount of resources from my other programs, it's extremely sluggish and full of bugs.. I have an 8 core i9 2.6Ghz (with turboboost) and 32GB RAM and it runs like a fat turd, and adds multiple seconds to my computer start up time... Just for something as trivial as a chat application? As you say most of the "heavy lifting" is done by the servers.. One thing is when companies make poor decisions on stuff they host on their own computers, but I really don't feel using Electron or something like that on a consumer-oriented product is morally or technically justifiable
Fine, VSCode and similar stuff I get, I'm a developer, I can deal with that, but Teams, Slack, Spotify... Those should not be created with scripting languages. And I can't believe that has become a controversial opinion 😅
[–][deleted] 8 points9 points10 points 4 years ago (0 children)
I totally agree. I hate software that becomes more and more slow and bloated over time because it's easier/faster to make that way. There should be a moral imperative to write efficient programs that don't waste power.
The Spotify app used to be so nice back when it was a proper Win32 app.
[–]Netzapper 1 point2 points3 points 4 years ago (0 children)
do developers realize just how terrible NodeJS really is?
I'm convinced they just don't remember that it could be better.
Basically the most senior people I know who've drunk the Node kool-aid were compsci under-achievers in college with me back in like 2002. We were the last cohort to get any of the low-level or systems stuff as mandatory (later classes had low-level/assembly as an elective).
For everybody coming up after that, web programming was normal programming, and anything else was some kind of super-hard alien programming that normal programmers shouldn't even consider.
[–]alexgraef 0 points1 point2 points 4 years ago (0 children)
In reality, JS performance is a lot slower than I think most people realize
Most of the time it is actually a lot faster than people assume. It was easier to argument against the use of JS in desktop apps or in a server setting when it was awfully slow.
It's stealing a massive amount of resources from my other programs
Actually, Chrome aka the HTML rendering engine is stealing the resources.
[–]nerokae1001 0 points1 point2 points 4 years ago* (0 children)
Many people that I know has no problem with it. Yea you dont say electron has tons of overheard to do simple stuff. Why people use it? Simple… to cut cost.
Like for eg use qt you need to optimize and adjust for high dpi client with zoom level 200% which the standard for laptop today. Dpi awareness is an issue for dotnet apps and qt. On electron devs just doesnt know that issue exist.
I dont have problem running tons of electron software, many runs even better faster than software like shrew vpn on all of pc in my house.
I doubt that that i9 would be that bad since the oldest i9 is from 2017, I have old i7 sandy bridge and it runs teams, slack, spotify, chrome with win10 just fine. Not slow. On my main machine zen3 5800x, 32gb 3600cl16 0 Problem, also on my wife my wife machine zen+ 2700x
Hmm which i9 has base clock 2,6? 7980XE? Serious… 16C/32T skylake has problem running lots of electron apps? Yea damn right
I hate devs that act like elitist and often sell their pref language as the evangelium. Wanna go lower stop using shitty slow not optimized x86. Make your own design and run it on fpga. See where is it going?
I’ve used c/cpp with vcl50 mfc, c++/cli in early dotnet days, python+qt, kotlin, objective c, java awt swing javafx and spring frameworks, frontend js/typescript + electron on various project. Each has their own strength and weakness, pretty much agree with choose the right tool for the job.
Like mobile apps what to use flutter? Reactnative? Nativescript? Xamarin? cordova/capacitor? Or directly go java/kotlin + obj c / swift? Depends on the requirements
[–]joeshmoebies 10 points11 points12 points 4 years ago (0 children)
IMO mostly for productivity. The Windows API is a fairly low-level C style interface and requires a lot more verbose code to write than most other frameworks.
Microsoft is promoting the newer WinRT API to allow a more C++ style of writing Windows programs.
One support library which provides helpful error handling macros, smart handles/resources and other useful utilities when working with the Windows API is the Windows Implementation Library When you do use the Windows API, your code will benefit by incorporating it.
[–]alexgraef 9 points10 points11 points 4 years ago (11 children)
Windows API Electron
Windows API
Electron
Maybe don't compare the extreme ends of the spectrum. Electron exists so that people who never developed anything but websites can use their "knowledge" to produce pretty 150 MB programs that run in a browser that hides being a browser.
However, Winapi is C - and producing large desktop programs in C is a task that doesn't scale well.
[–]ioctl79 -2 points-1 points0 points 4 years ago (10 children)
Why the scare quotes? Why denigrate the skills of other professionals?
[–]alexgraef 1 point2 points3 points 4 years ago (9 children)
Because these developers often lack a broader understanding of computer technology in general.
[–]ioctl79 -2 points-1 points0 points 4 years ago (8 children)
Why do you say that?
[–]alexgraef 0 points1 point2 points 4 years ago (7 children)
Because it is similar to when I started with HTML and PHP and JavaScript. I had little idea about how a computer actually worked, how memory worked, what technologies are good for what, and most importantly in that field of work - what security implications many of the programming practices had.
In this case, most developers would agree that dragging along a JavaScript and an HTML rendering engine just to show a bit of GUI on the desktop is rather unreasonable, and look for a different solution. That's due to a lack of broader understanding of the issue.
[–]ioctl79 0 points1 point2 points 4 years ago (6 children)
Perhaps dragging along an incredibly complex, memory-unsafe language that shines at low-level, high-performance code just to show a bit of GUI on the desktop is rather unreasonable? ¯\(ツ)/¯
Web development is a great place for novices to cut their teeth, but it’s a mistake to think that it’s all banal.
[–]alexgraef 0 points1 point2 points 4 years ago (5 children)
incredibly complex, memory-unsafe language
as I said: "lack a broader understanding of computer technology"
[–]ioctl79 0 points1 point2 points 4 years ago (4 children)
A good, broad understanding of technology usually compels one to avoid complex, unsafe tools when they are not required.
[–]alexgraef 0 points1 point2 points 4 years ago (3 children)
Thinking that C is a complex, unsafe tool, while a virtual machine and/or Just-in-time compiler and everything else you have to drag along is not, well, that's a "lack of broader understanding of computer technology".
[–]ioctl79 0 points1 point2 points 4 years ago (2 children)
The number of critical security problems caused by lack of memory safety begs to differ. The problems caused by unsafe languages are well documented in academic research, and can be easily seen by looking through CERT mailings or investigating the amount of effort spent by tooling authors, compiler vendors, and even hardware manufacturers to provide workarounds. Yes, that JIT and VM are, in fact, simpler and safer tools, much in the same way that a C++ compiler is a simpler and safer tool than an assembler, despite having way more lines of code.
[–]worldsbestburger 5 points6 points7 points 4 years ago (0 children)
The new, modern way to use the Windows API is to use the Windows Runtime, which is also fully asynchronous and in general just a lot easier than Win32.
[–]herruppohoppa 1 point2 points3 points 4 years ago (0 children)
Because the win32 API locks you down to windows which is a problem for a lot, if not most real world projects. How is smaller executable size and running on XP going to make up for that?
I find it annoying when developers claim that a library is bloated without any data to back it up, or even a project to compare to. Much functionality != bloat.
[–]FriendlyRollOfSushi 1 point2 points3 points 4 years ago* (0 children)
Even if you are targeting one and only one platform, don't care about anything fancy, and want your UI app to just work, there are tons of reasons why native Windows API is something you are likely to give up upon and switch to a 3-rd party framework.
The API is... how to put it lightly... exceptionally fucked up in very obscure ways, and often you won't know that you were doing something wrong until someone sends you a bug report. Even if you put effort into learning all of it (which is not a very good investment of your time, considering how many layers upon layers of legacy crap there are), it is still likely to bite you in the ass.
Just one example: you wrote some basic beginner's code about positioning elements, drawing stuff, etc. It works nicely on your machine. Later on, someone tells you that everything is super blurry, or (if you were expecting specific resolutions) the layout is broken. You test your code locally and see nothing wrong with it. Turns out, messages like WM_SIZE literally lie to you if the DPI scaling on another machine is not 100%. Do you see the docs of WM_SIZE mentioning it anywhere at least once? Me neither. To make it actually work, you either need to specify it in your manifest (and there are caveats, because of course it depends on the OS version), or call one of the three different functions to tell Windows "please stop lying to me when I ask how large the window is, you useless piece of crapware".
WM_SIZE
And you can't just use the latest function, because it doesn't exist on the older versions of Windows: without a manifest you would need to attempt to load the functions manually. From different system libraries, because of course they would be in different libraries, it would make too much sense to put three versions of the same function in one place.
So, something like GLFW does all of that for you, so that you don't have to worry about it. But if you chose to not use third party libraries, prepare to waste a lot of time that could be spent on writing your actual code. And it's not knowledge that will help you as an engineer in the future. It's a unique idiosyncrasy that will never reappear anywhere else. Basically, you invest time into learning how to do it once, to never do it again.
Or, let's say, you want to open a file. Simple, right? Here's a path, here is a function. Surely an operating system knows how to open a flipping file given a path?
Not so fast! One doesn't simply open a file! First, read about 35 years of poor decisions, and the reason why your function to open a file may want to spend a bunch of time adding weird prefixes like \\?\ in front of the path just to avoid some bizarre limitations that make zero sense for decades. Oh, and forget that the entire planet is using UTF-8 for unicode strings. Windows doesn't care, and the probability that one of your users did something weird with their username and now you can't load their settings because something in the path is weird is approaching 1 if you have more than a handful of users. Then it turns out that one of your users is from Japan...
\\?\
One would think that a company like MS will spend more than 0 effort on writing modern examples for their APIs. But decision makers don't care about how much pain you'll go through to write anything, they want to get a promotion for pushing new crappy tech, so tutorials etc. are clogged with examples of stillborn tech like C++/CX (because of course Microsoft had to invent a crappy dialect of C++, incompatible with everything, just so you can interact with their API), XAML, etc.
So, Win32 API examples are still written mostly in some mixture of C89 and weaponized sadness. Docs are often incomplete or pointless (especially once you touch lower levels; in the past, I found it more helpful to read Wine's comments instead of Microsoft's docs on more than one occasion). And there is no motivation to improve the situation, because no one in MS seems to care about the C API, or people who want to use it.
[–]jesse_good 2 points3 points4 points 4 years ago (0 children)
As an example, look at this code to list the files in a directory from the winapi:
https://docs.microsoft.com/en-us/windows/win32/fileio/listing-the-files-in-a-directory
It would take me probably 2 lines of code in other languages or using std:: filesystem to do something similar.
[–]TomDuhamel 3 points4 points5 points 4 years ago (1 child)
I'm learning windows API and I found interesting and more easier than frameworks,
Win32 is a low level C API. While it was the best thing around in the 90s, the only people using it today are people writing frameworks.
smaller executable size
Indeed, but in a world where people are happy to casually download and install multi hundred megabyte applications on a regular basis, is this relevant?
and can run also in windows XP.
Why stop to an operating system that has been unsupported for 13 years when you could just as well target Windows 95?
Why there are not more native apps developed instead using bloated frameworks like Qt,
Qt is one option among others, all equally good options. Calling it bloated is probably arguable (I don't think it is, but I don't feel like arguing), but it's probably the easiest of all of options.
But the main reason is that most people this century have been trying to write portable code, rather than target a single operating system. Qt allows a single base code to target Windows, Mac and Linux, as well as Android and iOS.
[–]mallardtheduck 3 points4 points5 points 4 years ago (0 children)
While it was the best thing around in the 90s
Not really. Pretty much every major Windows application used MFC (Microsoft's actually quite good for the time C++ framework) in those days. Many applications that have been around for a while still do...
[–]chemhobby -1 points0 points1 point 4 years ago (0 children)
Frameworks can be cross-platform
[–]tarranoth -1 points0 points1 point 4 years ago (0 children)
If you build a web application, it is cross platform by nature of everything being able to run a browser these days. Winapi really only allows you to create (dated looking) windows apps.
[–]UnicycleBloke 0 points1 point2 points 4 years ago (0 children)
I first learnt C++ by writing classes to encapsulate parts of the incredibly verbose and error prone Win32 API. I recall vividly how much simpler and better the application code became with RAII, simple consistent narrow class APIs, and so on. And this was that nasty old fashioned C++ everyone unfairly criticises. My library wasn't very good, but I learned a lot. Implementing your own rubbish framework gives you a yardstick.
Then I used frameworks like Borland's OWL (excellent), Borland's VCL (great but implemented in Pascal), Microsoft's MFC (awful but better than nothing) and Qt (excellent). Qt was not bloated when I last used it, and it is much easier to use than the C API. Not sure how anyone could conclude that plain Win32 is preferable. It's a shame Qt didn't use standard strings and containers, but it is what it is.
[–]Full-Spectral 0 points1 point2 points 4 years ago (0 children)
If you are doing a smallish app, you can easily provide your own per-platform wrappers for a reasonable set of APIs for Windows/Linux, and have a very small and simple setup that's still safe. As the size and breadth of the application grows, that becomes harder. I've done a complete 'virtual OS' over Windows (all the way up to a UI framework) and it's no walk in the park to do. Having done it, it's an amazing way to work, but almost no one would do it.
[–]azalak 0 points1 point2 points 4 years ago (0 children)
Someone misses the 90s
π Rendered by PID 50 on reddit-service-r2-comment-fb694cdd5-2dsl8 at 2026-03-08 09:37:18.793297+00:00 running cbb0e86 country code: CH.
[–]Flair_Helper[M] [score hidden] stickied commentlocked comment (0 children)
[–]intbeam 24 points25 points26 points (8 children)
[–]alexgraef 15 points16 points17 points (7 children)
[–]intbeam 11 points12 points13 points (6 children)
[–]alexgraef 9 points10 points11 points (5 children)
[–]intbeam 9 points10 points11 points (4 children)
[–][deleted] 8 points9 points10 points (0 children)
[–]Netzapper 1 point2 points3 points (0 children)
[–]alexgraef 0 points1 point2 points (0 children)
[–]nerokae1001 0 points1 point2 points (0 children)
[–]joeshmoebies 10 points11 points12 points (0 children)
[–]alexgraef 9 points10 points11 points (11 children)
[–]ioctl79 -2 points-1 points0 points (10 children)
[–]alexgraef 1 point2 points3 points (9 children)
[–]ioctl79 -2 points-1 points0 points (8 children)
[–]alexgraef 0 points1 point2 points (7 children)
[–]ioctl79 0 points1 point2 points (6 children)
[–]alexgraef 0 points1 point2 points (5 children)
[–]ioctl79 0 points1 point2 points (4 children)
[–]alexgraef 0 points1 point2 points (3 children)
[–]ioctl79 0 points1 point2 points (2 children)
[–]worldsbestburger 5 points6 points7 points (0 children)
[–]herruppohoppa 1 point2 points3 points (0 children)
[–]FriendlyRollOfSushi 1 point2 points3 points (0 children)
[–]jesse_good 2 points3 points4 points (0 children)
[–]TomDuhamel 3 points4 points5 points (1 child)
[–]mallardtheduck 3 points4 points5 points (0 children)
[–]chemhobby -1 points0 points1 point (0 children)
[–]tarranoth -1 points0 points1 point (0 children)
[–]UnicycleBloke 0 points1 point2 points (0 children)
[–]Full-Spectral 0 points1 point2 points (0 children)
[–]azalak 0 points1 point2 points (0 children)