News for hackers. Stuff that matters.
Re:The Worst API Ever Made by erulabs on Monday July 31, 2023 @10:55PM (#36951780)
> I don’t think people who make APIs really appreciate how important it is to get them right, and how much unnecessary work their mistakes can cause for hundreds, thousands, sometimes even millions of other programmers.

When I was a kid I tried to build a windows app. Getting a notepad clone even kind of close was a triumph for me, but I decided I wasn’t smart enough to be a programmer, and it set me back about 8 years at least.

I was about 19 and a jr sysadmin changing air conditioning units when I finally sorted out the vast majority of coding is vastly simpler and vastly more fun than win32. Those windows APIs cost me a lot of time!

Re:The Worst API Ever Made by lockhouse on Monday July 31, 2023 @11:15PM (#36951887)
As a kid, I noped right out of raw Win32 API and reached for MFC instead. It made writing Windows applications so much easier.
Re:The Worst API Ever Made by user3939382 on Monday July 31, 2023 @11:29PM (#36951959)
I looked at WPF a few users ago and my impression was, I could spend 2 hours doing something I could easily do in the browser in 15 minutes. Maybe it's not that bad once you get the hang of it, but it looked so arduous I immediately decided I didn't have the will to go farther.
Re:The Worst API Ever Made by eternityforest on Monday July 31, 2023 @11:35PM (#36951988)
As far as I'm concerned the only easy UI is a declarative reactive UI. Vue and to a degree Flutter make everything look hard
Re:The Worst API Ever Made by worthless-trash on Monday July 31, 2023 @11:57PM (#36952100)
What is an example of this? (non ui programmer here).
Re:The Worst API Ever Made by eternityforest on Tuesday August 01, 2023 @12:21AM (#36952264)
https://vuejs.org/guide/quick-start.html

The "Global build" section shows off how easy it can be the best.

More complicated stuff with modules might be harder especially when dealing with NPM build stuff, but it's generally pretty nice.

Re:The Worst API Ever Made by deaddodo on Tuesday August 01, 2023 @02:40AM (#36953055)
The simple distinction is this (using abstract examples):

* Declarative: here is a UI that I designed ahead of time. I've set up these controls with these hooks. Your logic then plugs into my UI independent of it's design. (When myBtn is clicked, it fires MyCode::MyBtn() in your code).

* Inperative: here is my main.c. In my main(), I call a function createWindow and then createButton with various parameters (size, text caption, styling, etc) that returns a handle to the widget/window. I give a callback to my widgets. When that button is clicked, the callback is fired. I can call a function called destroyWidget with that handle and erase it.

Or, to simplify solely to definitions: in declarative UI, I create (or declare) the UI ahead of time and hook it into my logic. In imperative UI, the UI is rendered as requested (an imperative). The definitions are directly orthogonal to imperative vs declarative programming, in general.

As to "reactive", this is an independent descriptor that simply means that the UI adjusts to it's environment. It's usually used in the context of Web or mobile devices, since an Android app that appeared the same on Phones and Tablets would get a subpar experience for users on one or the other.

Re:The Worst API Ever Made by lelanthran on Tuesday August 01, 2023 @03:24AM (#36953331)
Which approach is "better" varies, though.

Given an imperative UI and a small amount of time (depending on the surface area of the API) I can create a declarative interface to it.

I cannot do the reverse given a declarative UI.

My observation of declarative UIs is that, sooner or later, due to necessity, they tend towards the inclusion of imperative elements ("If we are running as Super-User, then $FOO must be a button, else it must be a link to a page requesting Super-User privileges").

At the end the "declarative" UI is declarative for only the most trivial usages. Any non-trivial usage includes hacks or workarounds to implement conditional elements, loops (for collections of elements) and subcomponent specialisation (for element reuse).

Re:The Worst API Ever Made by deaddodo on Tuesday August 01, 2023 @05:20AM (#36954042)
Sure, which is why it's most popular among software with minimal UI (gamedev being a prime example).
Re:The Worst API Ever Made by zogrodea on Tuesday August 01, 2023 @08:42AM (#36955242)
I don't think the statement about declarative UIs needing hacks is true. In Flutter or Elm for example, you can write something like:

if condition then ConditionalWidget1 else ConditionalWidget2

Where this if-statement is embedded in a declared UI/widget tree. That's hardly a hack in my opinion.

There are similar ways of building a dynamic list of widgets declaratively which don't feel hacky at all. For example, look at ListView.builder[0] in Flutter. You provide an array and a template function of how each element in the array should look and then you have your dynamic list of widgets. (Of course more complicated use cases require more complicated code, but it's still not hacky and fits well with the larger sstem.)

[0] https://docs.flutter.dev/cookbook/lists/long-lists

I might be misunderstanding your definition of declarative vs imperative but I don't think this way of building UIs is hacky in any sense.

Re:The Worst API Ever Made by lelanthran on Tuesday August 01, 2023 @08:54AM (#36955345)
Could simply be that my understanding of declarative I a wrong.

AIUI, declarative is listing what you want, while imperative is listing the steps to get what you want. Naturally, I feel that extending a declaration with conditionals or looping constructs make that not-declarative anymore.

That's because, I feel, a conditional is a sequence of steps, not a declaration.

Hence I regard (perhaps incorrectly) that declarative syntax with support for conditionals is "hacky".

Re:The Worst API Ever Made by zogrodea on Tuesday August 01, 2023 @09:10AM (#36955492)
I can understand that point of view. It seems likely that UI-as-code variants (like Flutter and Elm) are more imperative (even if they have a declarative API) than separate markup languages like HTML and XAML since you have the ful power of a programming language to express what you want.

(The XAML way of expressing conditionals and loops does feel hacky to me since you need the code and markup to communicate with each other instead of expressing directly in code.)

Edit:

Here is a well-considered blog post from one of the Uno Platform contributors about UI-as-code vs markup if any are interested. https://platform.uno/blog/markup-vs-code-for-ui-angled-brack...

Re:The Worst API Ever Made by fiddlerwoaroof on Tuesday August 01, 2023 @12:32AM (#36952328)
I have the opposite experience: I learned to program with Delphi, and all the React libraries feel like hard, slow ways to make stuff I'd make in five minutes in Delphi.
Re:The Worst API Ever Made by whstl on Tuesday August 01, 2023 @12:28PM (#36958265)
Were you wiring up the UI by yourself with imperative code, or were you using Delphi's form editor (or whatever it was called)?

Because GP is criticizing Win32-style imperative UI code... and this is exactly what Delphi saves you from.

Re:The Worst API Ever Made by fiddlerwoaroof on Tuesday August 01, 2023 @05:08PM (#36962966)
Describing GUIs in text should have been left in the 90s but I haven’t seen a better code paradigm for GUI behavior specification than VCL-style OOP.
Re:The Worst API Ever Made by datavirtue on Tuesday August 01, 2023 @02:31PM (#36960313)
Yeah,we had this all figured out decades ago and then the web through in a monkey wrench that we never recovered from.

From a webdev point of view I love Vue...but it is a slow hard way to build UIs compared to Visual Basic, Delphi, or Swing.

Re:The Worst API Ever Made by fomine3 on Tuesday August 01, 2023 @12:17AM (#36952233)
To be fair, making an app in 2008 (when WPF released) with JS is a completely mess. WPF was usable and they introduced data binding/MVVM. In 2018 (React/Redux), it's fair that JS seems to be advanced vs WPF. Though its productivity isn't so bad (unless you want to fully customize everything).
Re:The Worst API Ever Made by ufmace on Tuesday August 01, 2023 @11:27AM (#36957246)
Also on "to be fair", JS libs have a nasty habit of either completely redoing the API, or dropping maintenance entirely and encouraging everyone to switch to the new hotness which also has a completely different API, every 6 months or so. It's a lot easier to have a nice API if you get to rewrite it on a whim and tell anyone who doesn't like it to fork off. WPF may be weird and messy, but your app will still work unchanged even now (well I think, haven't used it in a while).
Re:The Worst API Ever Made by deaddodo on Tuesday August 01, 2023 @02:22AM (#36952950)
I don't even get this arduousness argument. A barebones WinMain is extremely long-winded (what causes most people to "nope out"), certainly, but once you get passed that it's fairly consistent and the API calls reasonably formed. I don't think it's an example of a perfect API, but the concepts and functionality of it mean once you learn the basics of it (handles, resources, parentage, text encoding, type annotation, etc) they apply to any other widget you'll implement, from legacy ones all the way back in 1993 to modern ones introduced in Windows 7+.
Re:The Worst API Ever Made by paulryanrogers on Monday July 31, 2023 @11:21PM (#36951918)
MFC felt pretty awkward to me, though I was introduced to it after Swing and C. I suppose it's all matter of perspectives and preferences.
Re:The Worst API Ever Made by GuB-42 on Tuesday August 01, 2023 @08:00AM (#36954912)
For me it was the opposite. Raw Win32 is low level: you manipulate the event loop directly, and you have to deal with the layout yourself, but otherwise rather simple.

MFC had a mix of generated code and handwritten code. Writing MFC code by hand was hell, and using a graphical IDE was nowhere as convenient as Visual Basic or anything by Borland.

Re:The Worst API Ever Made by marmakoide on Monday July 31, 2023 @11:48PM (#36952051)
In the late 90's, my Dad bought Visual Studio 6 to learn C++. I knew my way around Turbo Pascal, i386 assembler and C/DJGPP on DOS, so I figured I could try to code for Windows, "I am Big Boy now".

The Visual Studio 6 box had an introduction book to win32 and MFC ... Nothing made sense to me, a lot of boiler plate code was there without much explanation about why it was there. I just said "nope, life is too short to suffer this", and went back to DOS. Learned Unix system programming at the university, it felt sane and consistent.

This introduction to win32 API was so traumatizing, even now, I would not touch it with a barge pole, POSIX or GTFO.

Re:The Worst API Ever Made by physicles on Tuesday August 01, 2023 @01:58AM (#36952826)
I had a similar experience. I'd been doing C++ for DOS with some x86 assembly for a couple years when I somehow got access to Visual C++ (probably version 5) with MFC. Just getting to Hello World took me a solid week. Eventually I wrapped my head around it, but moved to C#/WinForms as soon as that came out.
Re:The Worst API Ever Made by bergen on Tuesday August 01, 2023 @04:09AM (#36953606)
Boggled my mind in university that c# was so smooth to get an application running, and the same ideas could not be applied to C++, in basically the same Coding environment. Tried for 4 separate times, always threw the towel.
Re:The Worst API Ever Made by rob74 on Tuesday August 01, 2023 @02:14AM (#36952901)
I tried to switch from Delphi to Visual C++ around the same time, which made me appreciate even more how easy it was to build a GUI app with Delphi as opposed to the way VC++ did it (having a barebones visual designer and other than that forcing you to use all the gnarly APIs directly), how straightforward Object Pascal was compared to C++, and how much faster the compiler was, and decided to just stick with Delphi for the time being. The later .NET IDEs improved the usability quite a bit (thanks Anders Hejlsberg!), but those were for .NET, they didn't generate native code.
Re:The Worst API Ever Made by pjmlp on Tuesday August 01, 2023 @02:24AM (#36952964)
They do generate native code at installation time via the NGEN tool, and Managed C++ (later C++/CLI) can created mixed mode Assemblies, where native code is embedded on the file, which is the reason why mixed mode Assemblies can't be considered safe from CLR point of view.
Re:The Worst API Ever Made by pjmlp on Tuesday August 01, 2023 @02:22AM (#36952953)
Then let me tell you that programming X Windows is even worse, from the point of view of someone that knows Windows since Windows 3.0, and learned it via Turbo Pascal for Windows and Turbo C++ manuals.
Re:The Worst API Ever Made by jamesfmilne on Tuesday August 01, 2023 @03:48AM (#36953486)
X Windows at least has the "advantage" that you can download the code for Xlib or the Xorg server itself to see what's going on under the hood.

Although, you're going to have to be fairly proficient to get your head around that stuff too.

Agree that X11 has a dreadful API.

Re:The Worst API Ever Made by pjmlp on Tuesday August 01, 2023 @04:18AM (#36953658)
Which wasn't necessarly how X Windows worked in commercial UNIX, so having the source code wasn't of much help.

And that O'reilly X Windows book series, The Definitive Guides to the X Window System, a "tiny" set of 8 books, only for the UI stack.

Re:The Worst API Ever Made by arethuza on Tuesday August 01, 2023 @07:21AM (#36954691)
Its a been a while since I did any X development but as far as I recall as an application (client) developer you generally only needed to know about the client library you were using together with some lower level details from Xlib?
Re:The Worst API Ever Made by pjmlp on Tuesday August 01, 2023 @08:08AM (#36954976)
Only if using something like Gtk+, which is mostly a cross-platform kind of approach anyway.

X Windows with the X Athena Widgets, or Motif, you better have all those books.

Re:The Worst API Ever Made by tragomaskhalos on Tuesday August 01, 2023 @04:24AM (#36953691)
There was a period of time when Microsoft were very enamoured of the document-view model of desktop applications; you could choose to build MDI (multiple document interface) or SDI (single ...) applications, complete with menu management, so if you want to do a Word clone, knock yourself out. however if you just wanted a simple doohickey with a few buttons and whatnot - like the vast majority of cases - you were out of luck. There was of course a way to do this (and it became easier in later releases of Visual C++), but you had to fight the stupid M/SDI model the whole way.
Re:The Worst API Ever Made by mschaef on Tuesday August 01, 2023 @07:10AM (#36954636)
> The Visual Studio 6 box had an introduction book to win32 and MFC ... Nothing made sense to me, a lot of boiler plate code was there without much explanation about why it was there.

Some of this is a symptom of the fact that Microsoft was still fumbling in the darkness regarding its Windows developer experience.

First generation windows programming was a complicated affair involving a number of command line tools, textual languages, and switching back and forth from the GUI to DOS. The first Visual BASIC product fixed all of that, and made it possible to achieve good results with just point and click and (more or less) scripting code.

My read on Visual C++ (predecessor to Visual Studio) was that Microsoft was pushing hard to graft the Visual BASIC style of point and click development onto its old school Windows development tools. The result was an IDE with a form editor that could superficially work a lot like Visual BASIC. You could drag a button, double click it, and be dropped into a blank C++ (rather than BASIC) function to handle the click event at runtime.

They did this with specific features in MFC, but also with a huge amount of default code generation. Double clicking that button in the form designer would update message maps, write a function, and make a number of other changes in the source text of what was already a large body of generated code.

The trouble is that while this worked, it didn't actually teach people what was going on. The development environment wound up being very brittle and hard to understand, particularly if you did anything that confused the IDE integration.

Re:The Worst API Ever Made by physicles on Tuesday August 01, 2023 @11:29PM (#36966632)
Do you think they took this approach because it wasn’t yet common wisdom in the industry that tons of generated code is a terrible idea, or because they didn’t want to fragment the developer ecosystem by adding a more comprehensive framework above Win32?

I suppose it could’ve been a bit of both.

Re:The Worst API Ever Made by mschaef on Wednesday August 02, 2023 @08:35AM (#36970012)
They introduced this system with Visual C++ v1, which is also known as Microsoft C v8. (There are nuances, but that captures the gist.)

The preceding version, MSC v7, was the first version of the Microsoft C compiler to support C++. It's also where Microsoft introduced the first version of Microsoft Foundation Classes.

My understanding of the history of MFC is that MFC is Microsoft's second attempt at a C++ class library for C7. Prior to MFC, they had developed a significantly more object oriented framework, but found it in testing to be confusing to developers of the time. (Who had just ascended the Win16 learning curve itself.) Micsoroft retrenched, and the MFC 1.0 they shipped with C7 was a much thinner layer over the Win16 API than what they had initially planed. (The earlier framework was AFX, which is why there are AFX prefixes in the MFC codebase.)

My presumption with respect to Visual C++ 1 is that Microsoft found themselves short on time and facing dual mandates of maintaining MFC 1.0 source compatibility and producing a C++ development experience a little like Visual BASIC. So a bunch of IDE trickery and codegen logic was the logical path forward. (IIRC, the Visual BASIC compatibility mandate extended as far as enabling VB custom controls to work in Visual C++ projects.)

I haven't used it, but Borland Delphi post dates all of this, and gets it better. Borland was able to specifically build a class library and extend the programming language itself in a way that supported visual design tools. My understanding is that this can give some of the Visual BASIC style point-and-click, but also makes it easier to delve into the underlying framework code and make your own components. (Also important to note that Delphi was Borland's second attempt at a Pascal based windows development tool.... the earlier Turbo Pascal for Windows was a lot closer to the Win16/MFC-like experience)

Re:The Worst API Ever Made by whizzter on Tuesday August 01, 2023 @10:21AM (#36956277)
Win32 programming was more akin to the X-windows protocol/API and boy.. let me tell you that Win32 was kids play in comparison to the fragmented mess that is raw X-windows (It's not for nothing that KDE is/was built on QT and Gnome on GTK).

Yes, the auto-generated boilerplates was stupid (and obscured so much) but it was their way of trying to get people ahead in an "easier" way.

Re:The Worst API Ever Made by jandrese on Tuesday August 01, 2023 @11:24AM (#36957199)
When I messed around with X programming I thought the base layer was primitive, but straightforward for the most part. You had to do damn near everything my hand, but it was clean and orthogonal.

Where the nightmare started is the X toolkit. It slathered on three extra layers of complexity before providing any benefit for the programmer and was so damn confusing even when you did get it working. And what did you get out of it? Athena widgets.

GTK is a dream in comparison.

Re:The Worst API Ever Made by dan-robertson on Tuesday August 01, 2023 @01:32PM (#36959360)
It’s funny how different this was ~10 years later. Visual studio was basically best-in-class as an ide (I think) and you could throw together a simple app pretty easily just using the mouse to design the form and writing functions in C# with a bit of google or just looking through the autocomplete list. But maybe that’s a bit rosy and if one wants something more complicated, it all drops back into win32 api stuff.
Re:The Worst API Ever Made by classified on Wednesday August 02, 2023 @01:00PM (#36973585)
And then there are people who tell you with a straight face that Windows is a great development environment.
Re:The Worst API Ever Made by iamwil on Monday July 31, 2023 @11:53PM (#36952080)
I've always wondered who were the people that were responsible for such terrible Windows APIs. They must have had an axe to grind or followed some ideology.

As a kid, I wanted to make games, and just found the win32 API inscrutable. I too lost a couple years.

Re:The Worst API Ever Made by cratermoon on Tuesday August 01, 2023 @12:41AM (#36952402)
> I've always wondered who were the people that were responsible for such terrible Windows APIs.

Charles Simonyi comes to mind.

Re:The Worst API Ever Made by indy on Tuesday August 01, 2023 @02:36AM (#36953037)
Truly terrible APIs never originate from one mind.

Instead they're the result of a whole bureaucracy of people each of whom have to inject their own particular requirements, coding preferences and "what if in the future..." guesses.

Re:The Worst API Ever Made by cratermoon on Tuesday August 01, 2023 @01:18PM (#36959104)
I dunno. Simonyi invented what became known as Hungarian notation.
Re:The Worst API Ever Made by return_to_monke on Wednesday August 02, 2023 @01:11PM (#36973733)
A very good article on why Simonyi probably wasn't the one: https://www.joelonsoftware.com/2005/05/11/making-wrong-code-...

my verdict is that Simonyi didn't communicate the idea - good otherwise - well enough

Re:The Worst API Ever Made by cratermoon on Monday August 07, 2023 @08:44PM (#37043009)
Oh, yes, I remember reading that while back. As Joel says, "if you write convoluted, dense academic prose nobody will understand it and your ideas will be misinterpreted", which doesn't let Simonyi off the hook completely.

As for Apps Hungarian, I was just discussing this the other day on a forum devoted to John Ousterhout's A Philosophy of Software Design. In Chapter 14, "Choosing Names" Ousterhout discusses a case where a variable named 'block' was used in a place where there were both physical and logical blocks, both integer types. His suggestion, which isn't wrong, was to use different variable names for different kinds of blocks, making it possible for a programmer to tell if a logical block variable was being used in some physical block handling code. This is similar to Joel's example of using 'rw' and 'col' prefixes for variables that are both integer types.

When I see a convention like this, I ask, "why can't they be different types?". In modern languages you can define new types easily, and define different interfaces or APIs to operate on the types. With 'physicalBlock' and 'logicalBlock' types, or 'row' and 'col' types, programmers can lean on the compiler or interpreter to prevent many errors. Beyond looking wrong to the programmer, the code is wrong, and won't compile or interpret correctly, provided there is a reasonable type system for the language.

The obvious concern is a proliferation of types, and yes that can happen when taken to extremes. One area where Joel's example makes a very strong case for types is 'us' and 's'. Strings are handy, but also the wrong abstraction. A 'SafeString' type would very clearly communicate the abstraction at the proper level: the thing in question is not a string, it's a representation of encoded user input. An attempt to assign a SafeString to a plain old string would be an error. Passing a string to a function that declares a SafeString would be an error.

There's even a name for using ints and strings when different types would be better: Primitive Obsession. A sign of this obsession would be passing around a user ID and password as strings, and a corrective would be a Credential type that encapsulates both ID and password types, and includes the necessary parsing and validation on creation. This eliminates an entire class of errors much more strongly than a convention where every string that contains a password has a 'pw' prefix, and userID strings are prefixed with 'userid' or just 'id'.

Of course, if the language doesn't provide useful typing, then naming conventions are essential. In languages with good type systems, always be asking, "does the language's primitive type really represent the abstraction in use here?"

Re:The Worst API Ever Made by narrator on Tuesday August 01, 2023 @02:05AM (#36952859)
The MS of the 90s, being the monopolists that the were, probably wanted Win32 to be as radically and annoyingly different from Unix and MacOS as possible just to make it hard to port software.
Re:The Worst API Ever Made by pjmlp on Tuesday August 01, 2023 @02:26AM (#36952979)
In the 90s, there were other options besides Windows and POSIX.

The Mac OS from the 90's had zero POSIX, and was less capable than Windows, hence Copland, which by the way also had zero compatibility with UNIX and was going to be a microkernel OS with C++ userspace.

Re:The Worst API Ever Made by mananaysiempre on Tuesday August 01, 2023 @05:57AM (#36954224)
I’ve read that MFC was a very close copy of MacApp, so not sure how true that is.

Also of course that’s Microsoft of the late nineties: e.g. COM/OLE2 originally had a Macintosh port and an obscure commercial-Unix one, VC++ 4 shipped with a Macintosh cross environment complete with an MFC port, etc. Don’t know if anybody ever seriously used those except the Mac ports of Microsoft software (Office, IE).

Re:The Worst API Ever Made by pjmlp on Tuesday August 01, 2023 @08:31AM (#36955147)
Excel was actually born on Mac OS. :)
Re:The Worst API Ever Made by mike_hearn on Tuesday August 01, 2023 @12:27PM (#36958250)
Although fun to speculate that it must have been deliberate, it's more that Win32 originates in a time when APIs were uniformly terrible by today's standards. UNIX and classic MacOS have many of the same problems, they're just smaller APIs and people have now forgotten classic MacOS. The industry has got better at API design over time, mostly by abandoning C.

Some of the key problems that makes Win32 unpleasant to use:

1. Preferring to be consistent with past mistakes rather than fix them. Core Win32 isn't namespaced in any way, and is full of generic function names like "StartTrace" that can easily conflict with user code. 30 years later they are still adding new Win32 APIs that also aren't namespaced in any way. They still use the "Ex" convention and so on.

2. A pervasive assumption that the APIs shouldn't have any opinion about memory allocators or heaps. You get this in old UNIX APIs as well. Why does the ETW API mocked in this article require so much pointer arithmetic and memory munging, well, because Microsoft don't want to have an opinion on where memory should be held. They see malloc as a utility convenience, so nothing in the API will malloc memory for you, or if it does, then it's done using its own API specific wrappers around malloc/free. By implication Win32 generally doesn't have functions that construct objects for you, instead it's always up to you to allocate the memory and pass it in. That means the API might be called with allocations of various different sizes depending on when the app was compiled, so, then the caller is typically expected to place the structure size in the structure itself as a crude form of versioning. It's all a lot of tedious boilerplate that's easy to get wrong.

3. An inconsistent and ad-hoc (API specific) approach to versioning and backwards compatibility. There just doesn't seem to have ever been much planning ahead. Win32 is full of places where they left room to extend the API yet never used them, and places where they didn't and then needed to introduce an Ex or 2/3 call. Again COM introduced better ways to manage this problem, but they didn't use that consistently either.

4. Frequent use of random GUIDs to namespace things. The article has examples of this. Nowadays we take for granted internet based namespaces, like how Java/macOS use reverse DNS names to identify code. Win32 originates in a pre-internet era, more or less, so a lot of APIs are built on the assumption that nobody can communicate with anyone else and there are no central naming registries that work. Giant random numbers are a reasonable solution to this, but again, Microsoft stuck with it for way too long after the concept became obsolete.

COM fixes some of these things but is used inconsistently and it was never retrofitted onto the core API properly until WinRT. For example, if you want to work with Direct3D you need to use COM and instantiate some COM objects, but if you want to then connect that Direct3D surface to a window, there's no COM object to represent a window, that's all done with legacy C APIs. Why did they never switch entirely to COM? Probably internal politics - developer experience became seen as some other department's job (VC++), and Bill Gates became obsessed with Big Chunky Features he could easily understand without doing Windows programming as his day job (like WinFS).

Re:The Worst API Ever Made by userbinator on Tuesday August 01, 2023 @12:35AM (#36952347)
I have the exact opposite experience --- I've been programming in win32 for about as long as it existed, and did win16 before that. There's no better way to make super-efficient single-EXE applications that can run on every version of Windows since Win95 (and if you try a little harder, you can get to Win3.11 with Win32s.) Everything newer has felt far more bloated and complex.

That said, some parts of Windows API are horrible; everything COM-related comes to mind.

Re:The Worst API Ever Made by pyeri on Tuesday August 01, 2023 @01:38AM (#36952728)
Instead of dabbling with the windows API directly, a better option is to use the .NET WinForms API. You can use any CIL language like C# or VB.NET. Granted that it is a framework or toolkit like many others but one of the most efficient and relatively easiest to use that I've found so far. I've tried hello worlds with many other frameworks like Java Swing/AWT/SWT, Python Tkinter/PySide, Electron.js framework, etc. and none came close to WinForms API, especially when it's powered using the super efficient Visual Studio Community Edition.
Re:The Worst API Ever Made by namdnay on Tuesday August 01, 2023 @03:54AM (#36953520)
Wasnt there an issue with your apps then needing the user to install the “.NET runtime” or something? I remember it being the main reason why people stayed on win32 for so long
Re:The Worst API Ever Made by pyeri on Tuesday August 01, 2023 @04:36AM (#36953763)
The .NET runtime usually comes pre-installed on all machines above Windows 7. It's just that if your app needs some advanced feature, you need to upgrade runtime version in those cases, this is pretty much how other runtime based systems like Java and Python also work.

Most people who stayed with win32 for long were C programmers who preferred the "purist way". But those who wanted developer productivity soon switched to the frameworks of .NET, Java, Python, etc.

Re:The Worst API Ever Made by pjmlp on Tuesday August 01, 2023 @08:29AM (#36955133)
.NET runtime comes pre-installed since Windows XP.

Also many of us already in the 16 bit days would rather use C++ frameworks than raw C.

One really needs to be quite masochist to use pure C in Windows.

Re:The Worst API Ever Made by namdnay on Wednesday August 02, 2023 @07:09AM (#36969320)
nah, windows 7 maybe, but I definitely have memories of people having to install ".NET 3.5 runtime" all the time on XP
Re:The Worst API Ever Made by pjmlp on Wednesday August 02, 2023 @08:45AM (#36970133)
Moving goalposts?

So no longer .NET, rather .NET version XYZ.

https://en.wikipedia.org/wiki/.NET_Framework_version_history

=> NET Framework 1.0 is an integral component of Windows XP Media Center Edition and Windows XP Tablet PC Edition. Installation CDs for the Home edition and the Professional edition of Windows XP SP1, SP2 or SP3 come with .NET Framework 1.0 installation packages.

Re:The Worst API Ever Made by namdnay on Wednesday August 02, 2023 @09:19AM (#36970500)
I'm not really trying to prove anything, I jsut remember that at the time, doing something with windows forms was a guarantee of getting people saying "ah it tells me i have to download .NET"
Re:The Worst API Ever Made by veave on Tuesday August 01, 2023 @05:22AM (#36954053)
+1, to me the Win32 API makes a lot of sense. It may be too low level, but that's a consequence of the time when it was created.
Re:The Worst API Ever Made by pjmlp on Tuesday August 01, 2023 @08:28AM (#36955125)
COM is a very good idea, very badly executed, ignoring VB 6, .NET Native and C++/CX attempts at improving it.

Unfortunely WinDev seems blind to how it is perceived from outside Redmond, is keen in sabotaging DevDiv efforts to make it usable, and keeps pushing it everywhere, moreso after Longhorn.

Re:The Worst API Ever Made by suzzer99 on Tuesday August 01, 2023 @02:48AM (#36953101)
I had a similar experience with BASIC on the C64 in high school, which set me back about 10 years from becoming a programmer.

But on the upside I got a lot out of my system in my 20s, and have never gotten burnt out on programming.

Re:The Worst API Ever Made by nvy on Tuesday August 01, 2023 @03:15AM (#36953285)
Once, I tried to write a GUI program in pure win32, that would have a custom window shape like demoscene intros/warez cracktros.

Once.

Re:The Worst API Ever Made by sph on Tuesday August 01, 2023 @03:33AM (#36953394)
Oh God you just stirred a long forgotten memory of my youth. Trying to make custom-shaped windows.

I also felt it was unreasonably hard in MFC/Visual C++ to just have a button in a different colour. The RAD system was so barebones compared to what I was used to previously with Visual Basic, and the people in Delphi could make vibrant, colourful GUIs which were a pain in the butt to do in C++.

I will always remember Delphi as the cool RAD system that could create beautiful GUIs but the language is a bit ass, so I never took the time to learn it. (I have never liked the feel of Pascal for some reason)

Re:The Worst API Ever Made by 3dbrows on Tuesday August 01, 2023 @03:30AM (#36953364)
I’m sure you managed to get the MIDI background music working easily though.
Re:The Worst API Ever Made by notduncansmith on Tuesday August 01, 2023 @03:19AM (#36953306)
Maybe ironic but I wouldn’t be where I am without Windows APIs.

I was 19, and I was a member of some forums where folks shared knowledge on how to (ab)use various technologies for profit; many of these technologies were Web-based. I didn’t know any Web programming, but I knew VB.NET from some community college courses (with some fundamentals from high school) and I figured out how to drive this browser and interact with pages.

This allowed me to automate various Web interactions and make a few bucks writing code, which eventually led to my current career as a professional software developer.

I was getting paid (not much lol) to build apps before I knew either of brands like “port” but I hope that, no matter how much money is in the table, y’all feel good about every deal! Respect

Re:The Worst API Ever Made by arc-in-space on Tuesday August 01, 2023 @04:14AM (#36953633)
Same here. Trying to write something using win32 as a ~14yo made me feel like an absolute worthless idiot and I just didn't touch code for 2-3 years.
Re:The Worst API Ever Made by kalleboo on Tuesday August 01, 2023 @05:05AM (#36953953)
I'm convinced that the only reason I got into programming is because my first exposure to it was via HyperCard, which is still just the most friendly and enticing introduction to programming I've even seen.
Re:The Worst API Ever Made by robertlagrant on Tuesday August 01, 2023 @05:55AM (#36954216)
I remember trying some Win32 stuff in the early 2000s and being gently ribbed in a chat room for not knowing what a message pump was. At the time I was thinking I was so junior, I didn't even know what something so commonplace was. Now... not so much.
Re:The Worst API Ever Made by mschaef on Tuesday August 01, 2023 @07:02AM (#36954577)
> When I was a kid I tried to build a windows app. Getting a notepad clone even kind of close was a triumph for me,

I remember having similar struggles. Windows programming was a huge lift. Not only were there new API's to learn, it was really an entirely different and novel architectural style.

Kerry Nietz writes about the experience of porting FoxPro from DOS to Windows... his description is apt: "Turn the program inside-out". For me, that was hard to do at a time when I was still working through how to make a normal program.

Re:The Worst API Ever Made by blarg1 on Tuesday August 01, 2023 @07:17AM (#36954669)
I still remember thinking how weird all the windows stuff was when I was a kid. Not just the windows api, but weird stuff like mfc.
Re:The Worst API Ever Made by analog31 on Tuesday August 01, 2023 @10:59AM (#36956835)
HyperCard, visual basic, and Python have saved me from ever needing to understand OS innards.
Re:The Worst API Ever Made by datavirtue on Tuesday August 01, 2023 @11:09AM (#36956977)
Constantly reminded of this every time I see any Win32 API code. Horrid names kept me away from native windows development as a kid. They didn't make any sense to me, which I found very aggravating. Having 30yrs under my belt has only convinced me more of how horrible that shit is.
Re:The Worst API Ever Made by phantom784 on Tuesday August 01, 2023 @11:28AM (#36957272)
When teaching myself as a kid, I quickly realized that win32 was way over my head. However, web stuff seemed easy enough, so I started teaching myself web development instead. This was in the early 2000s, before everything started moving to web applications. It certainly managed to pay off!

I never did learn win32...

Re:The Worst API Ever Made by cmg on Tuesday August 01, 2023 @11:44AM (#36957549)
This was also me as a kid with the Mac - we got our first home computer in 1993. Pascal? WindowPtr? Compilers? Yikes - I'm only 9 years old! I'd done some QBasic and Logo at school but couldn't wrap my head around the 'abstract' GUI stuff: If I tell the turtle to go Forward, it goes forward...

Then I discovered HTML - much easier to wrap my head around at the time.