Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Comments by a developer inside the Windows Media Player source code (pastebin.com)
319 points by saranshk on Sept 26, 2020 | hide | past | favorite | 127 comments


Ten years ago I found a comment in Excel's code base preceding a function over 1000 lines long that seemed to be parsing dates:

  // I just cleaned up the code. I have no idea what this fn does. Here is
  // what the comment said earlier for your reference!
  // --> BUG!! - this code is a crime against nature and has absolutely no
  // --> redeeming value (other than the amazing fact that it works)


Lecturing on keyboard shortcuts when windows media player is the only video player in the world not using the space bar as a shortcut for play/pause.


Amazon Prime web player uses it but does not force keyboard focus on the place where it can detect it, so many times you have to click first before it will pause on space bar.

Focus handling is generally terrible in web apps, but few instances infuriate me like this one.


Space bar handling in media players is a particularly hard problem because space bar is also the key that users expect to trigger the currently focused button. Some users rely entirely on keyboard focus.

So it starts to intersect with some non-obvious accessibility issues.


This is true as an explanation why it happens. I would expect the focused control to be visible and obviously marked (highlight, rectangle, etc). When all that's visible on the screen is the movie, or when the last thing you did was hit something to play the movie, the app should switch focus to whatever control needs to have it for space to play/pause. This is already a solved problem, many console video players do this, Netflix does it, etc. It drives me nuts that something so trivial in an area of an app that is (comparatively) so simple, remains broken for so long. It is not really important, but it destroys the potential for the app to feel natural and (in Apple parlance) beautiful to use.


Disney Plus doesn't either, most annoying thing ever. Has me wondering why there's no open source 'streaming website' the only value add is the content.


Have you used Kodi?

Roughly equivalent: why do people shop at Whole Foods when they can get the same food cheaper at a farmer’s market? The produce is washed, curated for imperfections, and marked up.

These streaming platforms are not perfect as no product since Unix has been, but to think altruistic programmers working for free can do an equivalent job is hubris. These interfaces take years of iteration and optimization in subtle ways like Netflix A/B testing thousands of generated cover photos.


WinAmp doesnt


Fortunately Audacious does, and you can use WinAmp skins with Audacious.

Doesn't at all discount your point, just wanted to help out anyone who's still using WinAmp because of the skins (I was up to last year).


Really? What key does it use instead?


ctr P


neither does twitter. and it pauses when you maximize


Neither does YouTube, likely the most popular video playing entity today, respect the spacebar on iOS.


I think you’re mistaken, YouTube (in all the forms I use it with a keyboard at least) supports spacebar as a pause key.

Your browser might try to pop you down half a page if the thing that is selected or highlighted on the page is not the video player itself though. But it works 100% of the time in fullscreen.


YouTube's keyboard handling is Insanely Intuitive™, I must absolutely agree.

Usefully, the up/down keys don't change the volume unless the player is also focused.

What's incredibly sad is that j/k/l were agreed upon to rewind/pause/forward the video, and these generally work unless you're in a textbox... but dedicated keys were not similarly approved to control the volume.

--

My current winner for Absolutely Favorite Piece Of YouTube-Related Keyboard Functionality©®℠ is...

YouTube Music (https://music.youtube.com/)... which uses a different set of fundamental keyboard shortcuts to YouTube. [;]=pause, [j]=next, [k]=prev, [l]=forward, [h]=rewind.

There are two disasters here.

The first is that <YouTube/pause> == <YouTube Music/rewind to beginning>. "Nooooo! I was 2 hours?? and how many seconds??? into this video... >.<". Naturally, in this situation, I ReWoUnD ThE ViDeO To ThE BeGiNnInG MySeLf, so YouTube's "last play position" indicator can't help me here. YAYYY.

The second disaster is that it's obvious a Vim user clearly argued successfully for Music to use Vi-style hjkl, but both the key choices and how they are presented in the UI could not be less intuitive, regardless of whether the user also uses Vim or not.

I copied above exactly how the UI (in the [?] popup) lists the sequence. Specifically, the whole thing is shifted left by 1 position, wrapping [h] around to the right. Fixing that to show the sequence how a Vim user would expect, it looks like: [h]=rewind, [j]=next, [k]=prev, [l]=forward.

But then, any Vim user is going to be utterly confused by this sequence, not only because of the mild readjustment of assigning up/down to prev/next and left/right to seeking - but because Vim "up" [j] is assigned to "next", and Vim "down" [k] is assigned to "prev".

Upside down playlist much?!?!

I no longer use YouTube Music, solely because of the number of long videos I have rewound and lost my position in.

I'm also incidentally trying to passively commit hjkl to memory (you know, the whole spaced repetition thing), and all the above was just too confusing.


Not sure if whether it is intended, or a weird combination of my browser and extensions, but right now, if I click on the play/pause button on Youtube video page, it becomes focused (with a visual clue of a blue box), and then pressing space bar starts and stops (or stops and starts) the video in rapid succession because it is considered a keyboard command and a button activation at the same time.

Actually, not quite at the same time, and that returns us to the old question of viability of reinventing GUIs in Javascript. I guess that even around 1990 window messages of some kind appearing with such a delay from a single action would mean the GUI is based on wrong principles, or the programmer doesn't know how to use it.

It's even funnier to imagine what happens when you press and hold space. The button icon is mostly in in-between animation state from all the repeated presses, but the video starts or stops only on first press and on release. Guess how much fun people have programming window system inside a virtual machine inside a browser using window system inside real machine.


> Vim "up" [j] is assigned to "next", and Vim "down" [k] is assigned to "prev".

j is down and k is up in vim


Originally derived from https://en.wikipedia.org/wiki/ADM-3A#ADM-3A, which I only learned (maybe from HN) long after becoming a vi user.

Edit: I've wondered whether the Dance Dance Revolution on-screen arrow order https://en.wikipedia.org/wiki/Dance_Dance_Revolution#/media/..., which I also have deep in my muscle memory, is somehow also related to the hjkl arrows (as it also goes ← ↓ ↑ → horizontally).


Wait, a mouse driven application is using the right hand keys for shortcuts? Yes, that sounds very handy for a left hand mouse user.

I prefer to be able to set my keys myself. I use the left hand WASD keys together with ctrl+shift for most things so I can control the music in any application (with winamp). No need to find buttons, the hand is already there even if I'm using the mouse with the right hand.


> (...) but dedicated keys were not similarly approved to control the volume.

Arrow-up and arrow-down?


Youtube itself changed the space bar behavior from context specific (pause if player in focus, scroll of comment in focus) but they rolled that back so space is always pause.

I like the context sensitive behavior and wrote a grease mo key script to restore it.


Run into a strange behavior though. When I pause the video with the mouse (and consequently, leave the pointer above the play button), and later try to continue the play with space, it will double-press the play button and pause the video again.


The play button is focused, and pressing Space activates a button. So it resumes playback. Then the key handler kicks in, and recognises that Space should pause playback, so it does that.

(I don’t know which order the two things happen in, but clearly they should make sure both don’t happen.)


Thank you for pointing that out since it seems to explain why the space bar behaves erratically. I far prefer the space bar to hunting down the k-key when trying to relax.


My problem with Youtube is when you're not watching a video the spacebar doesn't respond to its default behavior in the browser of doing a page down.


Unless your tab focus is on the other controls like volume :)


OT: There's an thread on SO with a collection of awesome comments in code. Well worth a read. If not for the insight, than for the chuckle:

https://stackoverflow.com/questions/184618/what-is-the-best-...


Ahh, stack overflow. Hugely popular thread with a lot of engagement? Lets lock it. Wouldn’t want to encourage behavior that doesn’t match our narrow minded “vision” for the site. Still though, an improvement over the early years where they just outright deleted countless pages with countless contributions. In the end it’s their site and they can run it however they want, but it’s sad to see such massive potential squandered through a policy promoting deletionism. Hindsight is 20/20 though and it’s not like I’ve gone and coded a better one, so I should probably just delete this comment and move on.


I do like that they are focused on being a collaborative Q&A site, nothing more and nothing less. Some sites care so much about "engagement" that they try to be all things to all people and end up simply becoming yet another generic forum.

I have other issues with SO but having a USP and sticking with it isn't their problem, IMHO.


I adblock Hot Network Questions because it always distracts me when I'm looking for programming help.


I do that too! I try to block all kinds of Related/Hot/Recommended stuff on websites. Those can be more distracting than real ads if you ask me. Most useful has been to block the end card recommendations after YouTube videos.


Pleae be nice to the 2374568234th user that could not manage to read any manual or just google for his error message before opening a new question!


It's not always that simple. Half of the time when I run into errors, there's no one solution that either works or 100% applies to my case so it's a lot of trial and error. I'm also not the most skilled developer and manuals are often way too verbose and difficult to parse if they don't contain very clear examples.

Sometimes, we just need someone to help translate our needs into a different wording and everything clicks into place. I'm sure that this causes a lot of repeated questions, but that's why when someone links a relevant question, it might be enough to solve the issue.


I think a lot of people's frustration comes from questions where it's abundantly clear that the asker searched neither SO nor the web first.

It only takes a few dozens of "why is [insert programming language]'s {addition, multiplication, subtraction, division} broken?!?!" questions that are all pointed to What Every Programmer Should Know About Floating Point Numbers before you lose all faith in humanity and get cranky. It's quite understandable.

If you can take the time to make an SO account and write a title and question body, why not Google that title first?

Another class of almost offensive questions is exemplified by this question on the front page for me right now: https://stackoverflow.com/questions/64087844/programming-tiv... . The user states what he wants, then completely useless debugging information, then a wall of code that in no way complies with the SO guidelines of reducing your code to a minimal working example, and finally an all-caps expression of personal feelings. Come on – nobody would feel sorry for someone acting like this in the real world. There are a few basic rules for social interactions.


Or, even more annoyingly, when you Google something and the first result is the exact problem you have, with the answer being someone pointing out that the solution can easily be found by googling...

People like you seem to forget that not only the question-asker profits from an answer, but future people as wel...


Did you consider looking at the other 1000s of results returned by Google?


[flagged]


No it doesn't if you make well reasoned arguments.


Your argument here is not well reasoned.


It doesn't have to be because it's not controversial.


> so we need to add yet more ugliness in the form of assembler to an app which is already hardly a paragon of pulchritude

Throwing some serious vocab shade in these comments, love it.


It's for the alliterativeness.


YouTuber Barnacules, use to work for Microsoft and he did tell a story on his live stream about ridiculous comments MS developers use to put in their code, I am sure they still do


Pulchritude!? Boy, I had to look that one up!


I know the word but never use it myself, even among people that I know know it, because it sounds ugly. It’s the first syllable that does it.


Looking it up, I still have no idea what it means. The best I can gather is its beautifully wholesome. Other sources say beauty, but it seems like such a specific word for a form of beauty.


Yes, it comes directly from the latin pulchritudo which my dictionary gives as "beauty, excellence" and which is quite common in Latin texts.

To me, pulchritude is such an ugly sounding word I can always remember the meaning as being the opposite of how it sounds.

(Funny enough, I was just looking up to see if there is a name for words that sound opposite to their meaning and found this [0] discussion on the English stack exchange, which gives pulchritude as its example!)

[0] https://english.stackexchange.com/questions/103741/name-for-...


"Pulcritud" and "pulcro" are not everyday words in Spanish, but pretty frequent. Mostly used to describe something that has been cared for and set up in a deliberately clean and orderly way.

A guy with an unshaven face, wild hair, casual or wrinkled clothes, etc would never be described as "pulcro", even if they otherwise look very handsome, beautiful, or attractive.


It means physical beauty, like an attractive appearance.


Weird, I'd've guessed the opposite - the word looks as though it could've been related to "putrid".


Understandable. The meaning is easy to grasp intuitively if you've studied Latin for a semester or two and happen to know the word "pulchra." If not, I'm having trouble thinking of any cognates in English that are in any kind of common parlance.


Have never come across the word before either. Makes you think - did the person say the word to convey some kind of meaning? Or to sound super-smart to their peers?


Alliteration. They wrote "paragon of pulchritude", which to me sounds like smart, dry humor. It works.


Precisely. The phrase is pretty popular in prose, particularly when prefixed with 'perfect'.


It could just be that the developer’s native language happens to be English, reads books, and he/she used a familiar word without thinking twice about it. Because this is, in fact, a fairly common word.


I’ve read at least several hundred books in English, and probably hundreds of thousands of news stories and blog posts, and don’t recall encountering it before. It seems to appear mostly in searches for its definition and gre prep...


Try, say, Google ngram. Would you say that, for example, “disharmonious” is a rare word? Graph them together. Pulchritude is not even moderately rare.


I’m not sure what you’re trying to say here; pulchritude twice as rare as disharmonious, which is relatively rare. It’s an order of magnitude rarer than effervescent, as an example, which is a word I would consider uncommon but in most people’s vocabularies. And given how much more common pulchritude is - surely physical beauty is one of the most common subjects in any language - while disharmony and effervescence are more complex and rarer in practice, I think it speaks to how little the word is used. Its synonym, beauty, is used 2000x as often.


Except that pulchritude beats disharmonious for over a hundred years. And even now, it’s half as common as disharmonious, which is a commonplace word. But if you think that a word like “disharmonious” is in any sense rare, then I don’t think I can convince you with data.


When compared to "harmony" usage of the other words is basically zero. Harmony is a common word, and it is the root which makes "disharmonious" easy to understand despite its extreme rarity.

Even "disharmony" is far more common than "disharmonious."


Disharmonious just seems common because it sounds similar to a word we're familiar with. Most times I can recall, a writer would craft a sentence using the word 'disharmony' instead, which is many times more common than either. What led you to pick disharmonious as a comparison point, anyway?


I agree. I think if you're going to use "disharmonious" as your benchmark, you should be comparing it with "pulchritudinous" instead.


Probably learned it while prepping for their SATs


If you search for the exact phrase you'd see it is fairly commonplace in literature.


It is a pretty rare word to come across in modern writing.

"And a sea of pulchritudinous models would have served as a lesson on how not to choose words: the ugly pulchritude sounds like the opposite of what it means, and it is one of those words that no one ever uses unless they are trying to show off.” https://www.goodreads.com/work/quotes/40167209-the-sense-of-...


A Redditer notes that a similar word is common in Spanish. For speakers of Latin-derived languages (French, Spanish, and of course Italian), English vocabulary quizzes are generally a bit more easy because English took its literary words from old French and Latin. Thanks William The Conqueror for that.

That said, as a french speaker I would have had no idea what this word means if I did not took Latin in high-school.


It's not common at all.


[flagged]


Your comment says more about you than the author.

It was a rarely-used but well-known word in use in school in the 80s and 90s.


It's used in the Paul McCartney song "Famous Groupies" (on the 1978 Wings album "London Town").


Same here... who would have thought reading random ancient source code comments could expand your vocabulary?


I learned this word (actually, it was pulchritudinous) from the DOS game Hyperspeed last year when I streamed a blind playthrough of it. To date, this is only the second usage I have ever seen of it.


Gonna take a gander and guess the developer might have an Indian origin! Or at least studied for the GRE!


"pulcher" is a fairly elementary piece of Latin vocab. It's in Book I of the Cambridge Latin Course, for example. This is much the same in other courses. So anyone, Indian or not, who has done basic Latin in school is likely to have encountered it and hence be aware of "pulchritude".

* https://www.dl.cambridgescp.com/dl_course/book-i

A random other example: https://www.ocr.org.uk/Images/221512-gcse-latin-j282-defined...


Or anyone fluent on a romance language [1]

[1] https://en.wikipedia.org/wiki/Romance_languages


One of the ugly hacks you do in SAP to make it work is reading/changing variables and structures inside the SAP standard code because there is no API exposing them.

It is blessed officially as doing a "dirty" assign.


> there is no API exposing them.

If there's no API exposing them but there's a way to make use of the internals with a dirty assign then sounds like the internals are now part of the API.


Correct. Same reason I learned a bunch of German words writing against supposedly English-dev'd and platform agnostic abstractions.

It's a fucking mess, but boy do they print money.


It is a feature of their language but you are on your own as a customer when an upgrade breaks the internals.


At a web startup I worked at years ago, I spent all night tracking down a nasty bug related to user signups.

I eventually traced it to one specific line of original founder code, and lo and behold, on that line was the comment: "this is probably buggy".


The bug here is in media player to listen on key-up events. Mouse-button-up makes sense because the user can move the mouse to cancel the click. But key events should be on key-down and that's how it is done most of the time. So if you use key-up you run into these problems.


> But key events should be on key-down

Why?

I like how keyup is less ambiguous: it avoids the question “what do I do if the user is holding the key down?”

I also like being able to hold the key down to cue up a command and then at the right time, pull my hand away to execute crisply. For video editing mainly.

I’m not saying keyup is the only answer. Just that there isn’t one obvious answer.


> Why?

Because of the reported bug in this example (which I also encountered quite often):

- user hits ESCAPE

- my window gets key-down/ESCAPE and closes itself

- your window (which happens to be the next in the focus-order) gets key-up/ESCAPE and closes itself

> I also like being able to hold the key down to cue up a command and then at the right time, pull my hand away to execute crisply

Ok, but if your window wants to support this behavior (which is not very common) you have to watch for key-up AND key-down like the bug-report suggests.


What if the OS only sent key-up events to a window if it also received the corresponding key-down event?


Then you'd lose useful functionality like dragging a file from your file manager to an application window to open it there.


That's your mouse button, not a keyboard key. Although modifier keys occasionally are used, what's important here is the state of those keys (ctrl for copy, shift/alt or whatever for shortcut); nothing happens when you release them.


You can do it with arrow keys, too. I remember doing this all the time back on Windows 3.1 and I'm sure it's still used now especially by people with disabilities.

Anyway, there's a way to fix this: send a reference to the key-down event when you send the key-up event. Then the receiving window can determine if it cares about it or not. If this is a security hole, send a reference to the window where the key-up event was sent instead.


Then we wouldn't have this conversation.


Keydowns have the physical button analogue: when you press a physical button, it immediately closes the contact, it doesn't wait until you lift your finger again.

Not saying key down is better than key up, there are certainly arguments for both.


Your experience of physical buttons is limited. There are many sorts. To pick an apposite example: The "Pause" button on old tape players used to be press-and-release to change state. Because it was a direct mechanical linkage and not motorized on some players/recorders, this made it possible to perform quite accurate editing with very basic kit: pressing and releasing pause to pause, pressing it again and keeping it held down, and releasing exactly when one desires to un-pause.


Now THERE's a rabbit-hole if ever I saw one. Here's an 8-part (!) article [0] on why a physical button is in reality... nowhere near that simple.

[0]: https://www.eejournal.com/article/ultimate-guide-to-switch-d...


Can’t physical buttons work either way, depending whether you want to break a normally closed circuit or close a normally open circuit.


Imagine a physical button on a car stereo. It activates when you press it, not when you press and release it.


“But key events should be on key-down”

Should they, in general? If you want to press a key combination, you never press the two keys at exactly the same time. So, if key events were on key-down, you would have to press modifiers before letters to type capital letters, use keyboard shortcuts, etc. I think that would be annoying and slow typists down.

It also rules out using bare modifier key presses as input methods, but that is less of an impact.


I've never seen a system where you can press modifiers _after_ letters, what are you using? Letters are definitely inserted on key down on all windows/linux/macos I've used


Ligatures pretty much work this way.


I would argue keydown is generally right, for the sake of latency and immediacy of action.

Do people who want a capital 'A' ever intentionally type A-Shift instead of Shift-A? I've never heard of it before.


Where on Earth have you been typing capital letters? One does have to press the modifier first on conventional home and personal computer keyboards.


There is the case of a sustained key press, where holding down the key might be part of navigation and only on key-up is the navigation finished, is it possible on platforms like Windows to distinguish between the sustained key up vs a normal key up?


That's the good side of working on proprietary closed source codebase - one has so much freedom of expression, be it in the code or in the comments.


What is the best library to use these days for developing in Visual C++? I had to write some VCpp code a few days ago using the Winhttp api and it was a nightmare. I'm not sure if its because I've been spoiled rotten by python where you can do a get/post request with a few lines of code, and that this is just how CPP is, but most of the complications are to do with calling and using the (not very well) documented API itself. Is there usually a easier way to do this? I'm just doing simple post and get requests, and I couldn't even do a file upload post properly by passing the binary data in, had to convert to base64 text in the end for it to work.


vcpkg has lots of libraries and is well integrated with CMake or Visual Studio.


For http? Embed libcurl.


Pretty much what I am expecting from Windows based software considering the mess windows always was and is to this day.


Eh, I've seen similar stuff in the Linux/UNIX world. Whenever different software components interact there's a chance you need some stupid stuff to get them to play nice. As some issues get fixed over time, new ones arrive since something gets swapped out for the next big thing. The interaction of X, the display manager, logind and dbus on session start comes to mind. There's been stupid stuff in Xsession.d et al over the years while these evolved.

xscreensaver also comes to mind; Jamie likes to keep all the legacy crap in the source code for operating systems and X extensions long gone, including rants about how they're broken under certain conditions, even if the bug is long fixed, just in case someone wants to compile the current version on their 1996 HPUX workstation.


Well, if anyone is still using screensavers in 2020, there is a good chance they’re running a 90’s system too :)


Those things are distracting a hell, so it's no surprise many workplaces mandate them.

But it's never xscreensaver, of course.


Yeah let's rewrite the entire system from scratch every 2 years with the langue-du-jour and deprecate everything. That 'll show them


"Windows bad something else (linux?) good"


Yes Windows is a mess but it's a beautiful mess and that is because of their mantra of being backwards compatible.


Microsoft internal shade. Juicy!


My favorite part is

> If you add some obscure code such as below, to this or any other app, even if it has only the teeniest chance of being less blindingly obvious to someone else than it is to you at the time of writing, please please please add a fing comment.

This rings as true now as it did then and its my favorite comment so far out of this whole leak. I've reached a point where my comments are there to remind myself why I did a thing, because more often than not I'm the poor bastard who's stuck fixing what past me did, and past me was either a sadistic asshole or a blithering idiot.


I watched Adam13531 on Twitch a lot, and the way he comments is very extensive, but complete. Ever since I started doing the same. Quite helpful to yourself.


This is why I love open source. In LibreOffice, cruft like this is often removed due to the embarrassment factor.


It was removed from Microsoft code too. This is an old snapshot of the code, almost two decades old.

Since the 2002 TWC initiative, anything from easter eggs to things like that are all very strongly banned, and actively get removed as they're discovered.


Afaik easter eggs got banned because MS wanted to gain certification for government/military use, and in order to get that, all functions/features must be documented and previously specified..

But a bit of googling shows it was part of TWC: https://docs.microsoft.com/en-us/archive/blogs/larryosterman...


Not surprising. No fun is allowed anywhere anymore. just dull flat interfaces with grey and black colors. people can say what they want about windows xp and vista but they had soul. todays OSes are souless. Looking at you windows 10..


I dunno. I certainly keep my comments family-friendly and clear, but these comments resemble my own in their dry wit. I also use emojis as icons in internal tools, since they don't require finding images, but this had the side effect of people reporting "sad cat" errors and the like.


Looking at you Reddit...


You can configure the colours in Windows 10 to make it look fun and childish.


I assume in the modern day of git and code review on commit diffs, its harder to slip things in than it was in the 90's.


I wasn't aware of this.


What is TWC?


TrustWorthy Computing.

In this context it refers to the early 2000s memo/paradigm shift at Microsoft as well as the now-defunct centralized infosec group.


Indeed. One of the first things I did after adopting a package was remove a well understood and unnecessary exploitive. One person noticed and gave it the looking eyes emoji.


> well understood and unnecessary exploitive

Probably not what you intended to say. "Expletive" or "exploit"?


Expletive.


lol LibreOffice codebase is cruft on top of cruft.


Indeed, it is an ancient codebase. It is being constantly refactored.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: