Context switch logging with the Windows Event Tracing API (2014)
mollyrocket.com
mollyrocket.com
(I'm not saying "poor Microsoft" - it's definitely not poor - and I'm not saying "you should thank people for whatever API they give you" - a lot of programs/features do more harm than good - and I'm not saying someone shouldn't vent having had a lot of time burnt by some ugly API. I'm saying specifically that this here is a dark corner of the OS that the API in question sheds at least some light on and I have a hunch, perhaps an entirely mistaken one, that it was someone's pet initiative and they thought it was definitely better than nothing. "Little did they know." To take a simple example of the other kind of API: sprintf, the version that doesn't take a buffer size, is a really bad API because that's something everyone's gonna use a lot and you just shouldn't give this kind of thing to people (give them snprintf at the very least) and you certainly can't be excused by "one should know what they're doing" in this case because it's between hard and uneconomical to use safely while passing the buffer size is the obvious thing to do, also one seems entitled to care-free string formatting, definitely 100x more so than care-free kernel status monitoring on the grounds of it being something many more people do much more often.)
I can't speak to the conspiracy-theoryish idea that Microsoft wrote bad APIs on purpose to make it easier to compete with other software companies at the application level, I suspect the issues were more subtle than that (an overly bike-sheddy code review culture, maybe?), but I did find them nearly universally bad to use as a programmer for a Windows "ISV" at the time.
Having said that, most modern Microsoft/Windows APIs I've used have been quite sane. Not bashing Microsoft in general here, just their APIs from about the mid 90s to the mid 2000s.
I think it's generally hard to make an easy-to-use API in C, unless the memory management involved is really trivial. (Let's ignore C++ for the moment including Microsoft's attempts like MFC and ATL, on the theory that binary compatibility issues make C that much more practical than C++ for this kind of thing.) IMO say poll or select (and the rest of the socket API, actually) aren't a picnic, either, and the only way to have a nice experience with these is by using a higher-level wrapper, and that's because everything involving variable-sized data structures, or any sort of data structure nesting, or literal initialization of this sort of thing, or lifecycles and memory management, or callbacks with private state, etc. etc. is just gnarly in C. (In C++ everything of course is just ducky and hence we never tire of articles discussing why smart pointers should really be passed by reference and shared_ptr is as good as gc except it's slower if used throughout and it doesn't work with circular references and don't use it unless you really have to etc. etc.) I haven't used the standard X C API but I glanced at it and it didn't looked very appetizing; that Microsoft's C API for GUI and OO looks worse than most of the standard Unix APIs kinda results from MS's APIs doing more, IMO, and X in particular, or Motif, which do more of what Win32 does, do not seem superior to Win32 in terms of usability, though if someone with experience in both strongly disagrees I'd take their word for it.
Now if you're saying that their C APIs of today are better than my argument is off. If you're saying that say writing a Windows program in C# is better than a C/C++/VB COM-infested program, then I think it's more of a testament to the strength of .NET/similar runtimes than anything else.
To me it's obvious that no one within the AirWatch organization ever used the API. They couldn't without running into the egregious bugs I have. My suspicion is that someone said "we should have an API", wrote a spec and shipped it offshore, then never checked the work that came back.
When you want to correlate events from your own code and OS events you use a tool like XPerf which knows the OS events and can read your application manifest to get strong typing on the events your application fires. This also lets you take traces on deployed software on customer machines.
If you want to roll your own event consumers you can do that too. But XPerf probably already does what you want.
This all existed back in like 2010 when I was using ETW. I'm sure the tooling has only gotten better since then. So yeah you can go write your own bad incomplete version of XPerf and not leverage your existing build process and MS tooling. But then is the API really bad? Or are you just not googling correctly?
As for collecting logs, WPR is currently the best tool.
There's a great .NET library for both logging and reading recorded events. http://www.nuget.org/packages/Microsoft.Diagnostics.Tracing....
If you want to correlate OS events, SQL server events, and application events, etc, you can get this working simply,correctly, fast and maintainable.
An api having a point of view about how it should be used doesn't make it a bad api.
I think it's probably embedded in MS developer culture, leftover from the old days when the ulterior motive was to make Windows "easy to develop for, difficult to port away from".
This is how technology works in general. The deeper you go, the more abstractions you remove, the more difficult the job becomes.
... at which point you should run screaming.
<myevent> <int/> <timestamp/> <string/> </myevent>
Will codegen to a function like myevent_fire(int,timestamp,string).
Why is this bad? You separate the definition of event classes from their use sites and have correctness by default.
I also thought it was perhaps a tad strange to equate CSS, DirectShow, and the Android SDK as examples of tough "APIs" to master. I get his point, but those are three pretty wildly different levels of abstraction there.
Back in the mid 90s I was learning how to program and understanding a Win32 "Hello world" was a royal pain compared to everything else I was doing. Functions with more than 8 parameters were the norm, structs with tens of members had to be manually initialised before calling them. And don't get me started on the WPARAM/LPARAM idiocy.
http://braid-game.com/news/2009/01/the-jeff-and-casey-show-o...
http://www.thejaywalker.net/2010/12/system-v-semaphores-how-...
They should simply make a new one.
However reading this, it seems the author simply wanted to collect trace information. It's probably a documentation issue, but typically you would just use tools like xperf or logman to collect and analyze traces based on in built Windows providers. There's no need in this use case to utilise the API directly at all.
https://stackoverflow.com/questions/1969442/whats-wrong-with...
As it is, it's a JavaScript laden blog about a Microsoft Win32 API and is virtually unreadable, so there's not much point in following the OP link.
I agree that the site shouldn't need JavaScript to function, but I don't think comments like these help the goal of helping the content creators achieve progressive enhancement.
This is actually quite usable, but on about 3% of websites, it doesn't work. These site are usually those horrible abomination of bloat-pages that, for no good reason whatsoever, need javascript files from 20 different domains in order to display a static page (I'm looking at you, Wired.com). In these cases, it becomes too tedious to pick the domains that should be whitelisted.
Most times, I simply close the offending website. In the rare case that I actually want to visit the site, I temporarily switch to Chrome.
I still go through the hassle of using NoScript, because it un-breaks pages that would otherwise for no good reason whatsoever decide it's OK to intercept common key combinations (CTRL+t), disable right-clicks, serve pop-ups, pop-overs, or pop-unders, start playing videos or sound without me asking for that thank you very much, or generally try to hijack my browser, my data, or my computer.
Yeah, it is — but it's better to have to enable JavaScript on a one-by-one basis when desired that to travel across the Internet executing random code and impairing one's privacy.
Some websites require JavaScript to display images nowadays. What's wrong with <img>? Others require JavaScript to use the correct font. What's wrong with CSS? Still others require JavaScript to show text. What's wrong with HTML? Still others require JavaScript to build links. What's wrong with <a>?
JavaScript is destroying the Web. What was a powerful technology for disseminating formatted text across the world has become a cobbled-together GUI held together with baling wire and twine.
Lazy loading. By default, browsers will load all images as soon as the page loads. If you have a long article with potentially megabytes of images, this behaviour will seriously slow down the initial load, and many readers who jump early will still download a bunch of images that they never see. That's why many sites only load images as they are about to appear, but to do that, you can't use regular <img> tags.
You're right in that JavaScript shouldn't be a requirement though. A good implementation will provide a regular <img> inside a <noscript> tag.
> Others require JavaScript to use the correct font. What's wrong with CSS?
Avoiding "flashes of invisible text"[1] when using web fonts. Unfortunately, different browsers have very different strategies for loading web fonts. Some of them will wait for the web font to load at any cost rather than showing a fallback font in the meantime. This means that you can be stuck for ages with everything in place except for the text, which is seriously irritating.
I've never implemented FOIT mitigation myself, but I assume that you could (and should) again provide a fallback in a <noscript> tag. Even without it, the text will at least still display without JavaScript, just in the second font in the font stack.
Because trifecta of retina (hi-dpi) displays, responsive design (use the same code for both mobile and desktop) and miserly bandwidth caps, (especially on mobile networks), means that traditional <img> tags won't do it any more.
<picture> is designed to help with this - and I'm pleasantly surprised to find that it has landed in a surprising number of browsers http://caniuse.com/#feat= picture - but you'll still need a polyfill, which is if course JavaScript.
Pages with a lot of images also use lazy loading to reduce bandwidth usage even further.
Of course a <noscript> should be included, but it's getting harder and harder to make the claim that it is economical to support people without JS.
Most of us are likely not outright disabling, we're white-listing, it's a big difference and IMHO the best way to browse.
It's an approach that basically considers the user experience on all websites to be hostile until you decide to grant them some trust. Given that many websites do implement hostile user experiences, it works out perfect.
A blog is a collection of documents and there's no reason to require JavaScript just to view them, the web was specifically designed for displaying documents.
Most of the time you enable only the domain of the url. If you really need to and you trust the page, you enable everything, including the trackers, which are blocked by other means anyway.
Bad design as expected when trying to format HTML as if it was PDF. The designer has to adapt to unpredictable user agent settings, not the other way around.