Live data from Hacker News

If you're just going to sit there doing nothing, at least do nothing correctly

devblogs.microsoft.com

251–260 of 356 posts

Re: If you're just going to sit there doing nothing, at least do nothing correctly

#251

Earlier quoted context omitted.

This is something that Elixir nailed. The typical idioms for return types are `{:ok, ok_value} | {:error, error_value}`, for which callers can pattern match against and handle appropriately. If fail-fast is desired, many functions will also have a variant signaled by a postfix exclamation mark (e.g., some_function!(...)), that returns `ok_value` or raises an exception.

> This is something that Elixir nailed. The typical idioms for return types are `{:ok, ok_value} | {:error, error_value}`, for which callers can pattern match against and handle appropriately. Agree this is a good pattern. Im not categorically against throwing errors but I like returning errors or the result and then having to check at the caller. Do this in typescript a lot.

Any typed language could use this pattern, though with Elixir specifically it was idiomized from the very beginning and all libraries use it, which makes error handling very consistent even when piping operations. The common option to fail fast is also handy when crashing the process is preferred and no matching is required to unwrap the value

Re: If you're just going to sit there doing nothing, at least do nothing correctly

#253
post #66

Earlier quoted context omitted.

>With Word you can't even guarantee that reopening the file on the same computer & version won't change its formatting. Source? This seems utterly bizarre.

Before the new '.docx`, '.xslx', etc. formats, when it was still just .doc, .xsl, etc., the document format was (as I've heard it told) essentially just a memory dump of Word/Excel's state for that document at the time you saved. And since it's easy to imagine that serializing/deserializing such a complex thing might not be always 100% perfectly idempotent, it would indeed happen that just the act of opening a file w…

Worse than subtle formatting changes was some kind of corruption that could slowly swallow bits of your document without you noticing. Sometimes going back before the corruption had visible effects was not good enough to stop it from manifesting again.

I remember back in school religiously saving new versions of Word documents so that if the newest version went bad I could start a fresh doc, then copy and paste sections from old versions via Notepad to cleanse the corruption. (Direct Word-to-Word could bring it across — I guess that tells us something about how they implemented copy+paste between documents, too!)

Re: If you're just going to sit there doing nothing, at least do nothing correctly

#254

I've learned this as "swallowing errors" and IMO it's a poor practice. Not only does it not solve the issue at hand (you cannot print on an xbox), but it actively hides how broken the software is, which makes bug discovery and testing much harder. This is one thing I like about Go's panic. You're mostly not supposed to use it or recover from it at run time. It serves as a great vehicle to blare loud sirens at testing…

>You're mostly not supposed to use it or recover from it at run time

Are you serious? I thought a key principle of Go was to handle panics in a layered way at runtime

Re: If you're just going to sit there doing nothing, at least do nothing correctly

#255
post #10

People are reacting negatively as expected, but stuff like this is exactly why you can click on a file that was written in Word '97 or a game that was compiled for MS-DOS three decades ago and it opens on your computer exactly as expected. Backwards compatibility is always messy. You either do it imperfectly or don't do it at all.

I think the reason this is getting a negative reaction is because he doesn't really clearly state the problem he's actually trying to solve until the end (and describes it as "bonus chatter" when it's actually just a much better explanation than he gives at the top of the article).

> To clear up some confusion: The idea here is that the printing API has always existed on desktop, where printing is supported, and the “get me the list of printers” function is documented not to throw an exception. If you want to port the printing API to Xbox, how do you do it in a way that allows existing desktop apps to continue to run on Xbox? The inert behavior is completely truthful: There are no printers on an Xbox. Nobody expects the answer to the question, “How many printers are there?” to be “How dare you ask me such a thing!”

If he just used the words "existing desktop apps" in the second paragraph of the article instead of the second to last, I don't think people would be reacting so negatively. Instead, when he talks about avoiding "gaslighting" by returning an invalid pointer by just gaslighting in a different way by lying about the error that occurred, it almost sounds unhinged.

Re: If you're just going to sit there doing nothing, at least do nothing correctly

#256

Good: average apps continue to work as expected. Bad: good apps can't know what's supported or not. What's missing from the article is adding a way for apps to detect and handle this behavior. (Using the printer example) There should also be some API that tells me "printing is not supported on this platform" somehow. If I want to be a good software developer I should hide the print button in the UI in a very predicta…

From the article: > Now, you probably also want to add a function to check whether printing even works at all. Apps can use this function to hide the Print button from their UI if they are running on a system that doesn’t support printing at all.

Somehow I missed that. Thanks!

Re: If you're just going to sit there doing nothing, at least do nothing correctly

#257

Earlier quoted context omitted.

Good luck uploading your CV in PDF. I tried that a few times and got moaned at a load that my CV must be in Word format. In the end I converted the PDF into images, and created a Word document in OpenOffice (this was a while ago) with one page image per page. Got moaned at for that too.

I haven't had that experience for a single job that I ever applied to. Always sent in PDFs without any issues.

Recruiters and large firms tend to ask for a Word file. I sent the plaintext file (minimal markdown) I used to generate the pdf to a recruiter recently. They directly asked for a docx instead.

Re: If you're just going to sit there doing nothing, at least do nothing correctly

#258

Earlier quoted context omitted.

To me, a better solution would be for the system to pop up a notification informing the user that printing is not supported on this platform, and then whatever other solution is OK.

Yes exactly, but Microsoft isnt the one who can implement that.

This was about the Xbox printing subsystem, right? Of course they can implement that.

Re: If you're just going to sit there doing nothing, at least do nothing correctly

#259
post #75

Earlier quoted context omitted.

> No, no, absolutely no - what the author is describing is a hack to support a shitty client. If you were on the Windows team and I was your manager, I might fire you for that. This is Windows. You do not break applications that users depend on. Ever, ever, ever. If you have a "shitty" or misbehaving client application, you use whatever workarounds, shims, and compatibility hacks it takes to make the application work…

I also took issue with the Xbox example, and I think it's a context issue. When I read it, I interpreted it as an API for new apps/games to use. In that case, they should be testing on an actual Xbox before shipping! And why would the app be trying to print in the first place if it's designed to run on an Xbox? But I suspect the situation this is being designed for is existing PC apps being ported to an Xbox. OK, in…

Just to add further context; this isn't apps being ported to an Xbox, they notionally need no porting; the Xbox is a "Windows" system. The only actor in this scenario is the platform developer figuring out how an existing API should behave if called in a context the authors very much didn't expect (who expects their Windows app to be run on an Xbox?)

Re: If you're just going to sit there doing nothing, at least do nothing correctly

#260

Earlier quoted context omitted.

That every single behavior that attempts to guess the users's intent becomes a relied upon part of the software, and this over time grows to an impossible amount of cruft. See this, hilariously hosted also by microsoft: https://techcommunity.microsoft.com/t5/discussions/funny-sto... > And then Google built Chrome, and Chrome used Webkit, and it was like Safari, and wanted pages built for Safari, and so pretended to b…

In 2024, so we still have websites that are served differently depending on the User Agent? Could we possibly do away with the User-Agent header, or reset it to a simple “Chrome 150.01”?

Try google.com, last month: https://support.google.com/websearch/thread/252500737/google...
Post reply on HN