Supersonic Man

March 12, 2015


Filed under: Hobbyism and Nerdry — Supersonic Man @ 8:16 pm

Well I guess there’s one category of post I can still put here: nerd notes that none of my friends care about.  These may end up being little more than notes to myself.

I’ve been looking at the Javascript property window.devicePixelRatio.  It’s a way to compensate for the way that browsers more and more often separate the definition of a CSS “px” from a physical device pixel.  It started with Apple’s “retina” iPhones, which had twice the pixel density but didn’t want to display web pages half as big because of it.  So they set up the browser so that one “px” would be two physical pixels.  As phone displays got denser, a bunch of other manufacturers followed suit: on my HTC One, for instance, it’s three physical pixels per “px”.  And this value is reflected in the Javascript API with the property window.devicePixelRatio.

So far, no problem — everybody gets a display that works pretty well on their mobile device regardless of its density.  Where things get awkward is when this comes back to the desktop browser.  Chrome and Firefox now support devicePixelRatio in Javascript.  But unlike the mobile browsers, the value is changeable: it varies depending on the zoom selected by the user, whereas on a phone, zooming means just changing your area of view over a layout that mostly remains fixed.  In Chrome, it starts as 1.0, but if you hit ctrl-plus, it becomes 1.1, then 1.25, then 1.5, then 1.75, and so on.  In Firefox, it goes from 1.0 to 1.25 to 1.5 to 1.76470589 (don’t ask me to explain that last one).

What bugs me is that Firefox does not start out at 1.0.  Since a year or two ago, they take the initial ratio from the host operating system’s monitor pixel density setting, which in Windows is controlled by the desktop text size setting.  When you pick “smaller”, the ratio is 1.0, for “medium” it’s 1.25, and for “larger” it’s 1.5… and like a lot of people, I use “medium”.  So Firefox starts out at 125% zoom on every website, unless you install an add-on to change that behavior.

And mostly, this larger zoom is a good thing.  It makes the website look about the size it was intended to look.  But there’s one situation where this zoom ratio is bad, and that’s when viewing images at full size.  See, the browser has to resize the image in much the same way that you’d do in a program like Photoshop, and if you’ve messed around with resizing in such programs, you’ve likely noticed that the results are worst when the amount of change in size is small.  Cut a picture to half size or blow it up triple, and the results are no worse than you’d expect, but magnify or shrink it just a little and you get a ton of extra blurriness.  (Or pixelated graininess, depending on the type of size-changing you select.)  This is because changing sizes by a small ratio, such as 1.25, combines the imprecision of both formats.  Each image’s pixelization process involves a roundoff error in where a given picture detail is located, and resizing adds together the roundoff error of both scales.  When you change by a large ratio, the amount of detail in the picture is nearly identical to what you could see in the smaller of the two sizes, but with a small fractional ratio, the result is not much better than half as sharp as it would be if it were created originally in either of the two sizes.

So, when my website hosts large images and I don’t want them fuzzified, I’d like to find a way to fool browsers into showing the image at exactly a 1.0 pixel ratio, if it’s attempting to use an awkward ratio like 1.25.  If the ratio gets to 1.5 or higher, fine, resize it, but if you’re trying to resize it a little bit, I’d much rather have 1.0.  That’s why I’m investigating window.devicePixelRatio: so I can make a Javascript hack that will change the sizing of images so that, should I so desire, they look their best and sharpest rather than looking correctly proportioned to the text and stuff around them.  Sometimes the proportion doesn’t matter.

Unfortunately, IE 10 also looks at the Windows desktop size setting, and starts out with an initial zoom of 125%… but it does not support the devicePixelRatio property.  So for now, if I make such a fix, it’ll basically be for Firefox only.

…Unless, that is, I make a separate CSS media query for each individual pixel ratio.  There probably aren’t that many to be found out in the wild: 1.1, 1.25, and 1.33 are probably about it for common cases.  But on the other hand, I don’t want these rules to snap in and out of action as the user zooms through the different ratios. JavaScript would be better because it could change the picture’s size once, and then any zooming done after that has no unexpected effect.

February 19, 2015

reactionless drives

Filed under: Hobbyism and Nerdry — Supersonic Man @ 8:37 am

This post has been promoted to a permanent location on my website, here.

June 19, 2014

the Swift programming language(s)

Filed under: Hobbyism and Nerdry,thoughtful handwaving — Supersonic Man @ 9:52 pm

So Apple is regretting the corner they painted themselves into by having their core development language be Objective-C.  This language is a horrid mashup made half of Smalltalk and half of traditional unreconstructed C.  Compared to C++, the modern half is more modern, but the primitive half is more primitive.  Steve Jobs used it for NeXT during his time away from Apple, and brought it back with him.  But what looked cool and exciting in 1986 is looking awfully outdated today.

The trend in the industry is clearly moving away from these half-and-half languages, toward stuff that doesn’t inherit primitive baggage from the previous century.  Microsoft has had great success by stripping all the old C-isms out of C++ to make C#, and Java — the oldest and crudest of this new generation of programming languages — may still be the world’s most widely used language, even though most people probably now see it as something that’s had its day and is not the place to invest future effort.

Now Apple has announced a nu-school language of their own, to replace Objectionable-C.  They’re calling it Swift.  It’s even more hep and now and with-it than C#. There’s just one problem: there’s already another computer language using the name.  It’s a scripting language for parallel computing.  Its purpose is to make it easy to spread work over many computers at once.  And this, to me, is far more interesting than Apple’s new me-too language.  (Or any of the other new contenders coming up, like Google’s Go or the Mozilla foundation’s Rust.)

See, massive parallelism is where the future of computing lies.  If you haven’t noticed, desktop CPUs aren’t improving by leaps and bounds anymore like they used to.  Speeds and capacities are showing a much flatter growth curve than they did five years ago.  You can’t keep making the same old CPUs faster and smaller… you run into physical limits.

And this means that if we want tomorrow’s computers to be capable of feats qualitatively beyond what today’s can do — stuff like understanding natural language, or running a realistic VR simulation, or making robots capable of general-purpose labor — the only way to get there is through massive parallelism.  I think that in a decade or two, we’ll mainly compare computer performance specs not with gigahertz or teraflops, but with kilocores or megacores.  That is, by the degree of parallelism.

One problem is that 95% of programming is still done in a single-tasking form.  Most programmers have little idea of how to really organize computing tasks in parallel rather than in series. There’s very little teaching and training being directed toward unlearning that traditional approach, which soon is going to be far too limiting.  Promulgating a new language built around the idea — especially one that makes it as simple and easy as possible — strikes me as a very positive and helpful step to take.  I’m really disappointed that Apple has chosen to dump on that helpful effort by trying to steal its name.

May 13, 2014

cosmic inflation

Filed under: Hobbyism and Nerdry,thoughtful handwaving — Supersonic Man @ 10:24 am

This post has been promoted to a permanent page on my website, here.

April 1, 2014

the theory of funniness

Filed under: Hobbyism and Nerdry,thoughtful handwaving — Supersonic Man @ 11:41 am

This post has been promoted to a permanent page on my website, here.

September 21, 2013

Java is doomed?

Filed under: Hobbyism and Nerdry — Supersonic Man @ 9:25 am

I was talking earlier about Windows now having a somewhat bleak future despite still being firmly dominant today, and now I have to recognize something else that’s gotten itself into a similar position: the Java language. Over much of the last decade it’s probably been the most widely used programming language… though it’s hard to be sure, and it certainly was never in any position of majority dominance.  But now nobody sees any kind of growth in its future, and other languages like C# are making it look outdated.  Combine that with the well-publicized security troubles which, among other things, nailed shut the coffin for applets in the browser (the one place where the average computer user came into direct contact with the Java brand), and nobody’s seeing it as the right horse to bet on anymore.

Which is a shame, because it’s still one of the most widely supported and most available languages, and it’s probably still the best teaching language in the C-derived family.  It’s going to have to be fairly widely used in schools, even if it drops slowly out of use in industry.  There isn’t a suitable replacement for that role yet, as far as I can see.

Even as it gets into a state where people scoff at it for real work, it might still be unavoidable for a long time as something you have to know.

. . . . .

Another sad observation of decline: I think MS Office is now better at supporting Open Office than is at supporting MS Office.

September 10, 2013

strict doctypes and old markup

Filed under: Hobbyism and Nerdry — Supersonic Man @ 9:49 am

I thought strict doctypes, like XMTML Strict, were just for eliminating all the deprecated HTML tags that were used for stuff that now uses CSS, such as <font> and <center>.  But there are a couple of gotchas with it.  For instance, strict [X]HTML does not allow you to put a target= attribute on a link.  Apparently this is considered a matter of presentation and styling, though only cutting-edge implementations of CSS support setting it in a stylesheet.  But the one that really makes me scratch my head is that <blockquote> is only allowed to contain block-level elements.  What?  The obvious semantics of a block quote are that it should contain text.  But no, now it’s only supposed to contain paragraphs and divs, not act as a paragraph in itself.

(I’m posting this partly just as a sort of note to myself.)

I do try to use modern standards, but my website has content dating back as far as 1996, so no way am I going to clean out all the old <font> tags.

Maybe I should at least validate, since the content there is all fairly new, and generated from a single master page that I can easily modernize.

[update] I did: is now fully XHTML Strict compliant, though still has tons of content that’s stuck at a Netscape 4 level of markup, using no CSS at all.  The front landing page is the only part that uses any modern browser technology, and even that dates mainly from about 2005.

[update 2] I made a spreadsheet of all the HTML pages on assessing their state of modernity in terms of styling.  The current status is:

  • root level: almost everything is archaic except the index page and the one page that draws the most search traffic.
  • the old film-era photo gallery folder (which frankly, has been an embarrassment for some time, and really needs updating, or even just some severe culling) is also completely archaic.
  • the Enron & Friends material is 90% bad, with a light sprinkling of modern style tweaks, but the current events movie reviews in the same folder are 90% good.
  • the B movie folder is good, and the boids folder, plus bits in the Amiga folder and the Reagan folder.
  • two of the biggest folders are good, but they’re both unfinished projects which are not yet exposed to the public.

The question is, which of these archaic areas is even worth updating?  The answer would be, almost none.  They’re all dated, essentially of historical interest only, except for the gallery, where markup is the least of its problems.

April 3, 2013

is Microsoft now the underdog? (WordPress is annoying)

Filed under: Hobbyism and Nerdry,Rantation and Politicizing — Supersonic Man @ 7:15 pm

I think I’ve about had it with Wordpiss.  Their comment approval process is fine for rejecting dozens of spam comments, but it’s terrible for approving a valid comment where you have to actually READ it before you’re sure it’s good.  The only way to read the whole comment to the end, as far as I could see, was to edit it!  I could not find any option for viewing the comment as it would appear if approved.  And then, when I try to follow any links to the post it’s a comment to, they’re links for editing it, not reading it.  This is stupid.

I have a sneaking feeling that Blogger is much easier to work with.  But I don’t want to move yet more of my life on to Google’s servers.  I think they’ve now officially crossed the line into being the new Microsoft — the big dominant choice that anyone who doesn’t like monopolies ought to look for alternatives to.  Since Windows 8 came out, Microsoft might actually now qualify as an underdog.  If not now, then they will soon.

IBM has been an underdog for a while now.  If they achieve the ability to answer natural-language questions before Google does, as they well might, I’ll be rooting for them, even though they were once the bad guy.  But I won’t go so far as to root for Microsoft… the memories of their ways when they were on top are a bit too fresh.

As for blogging platforms… what I really miss is Livejournal.  Why are today’s social networking sites so good for connecting people but so terrible for longer-form writing?  LJ was the one and only time that I saw thoughtful blogging combined with strong social networking in a way where both were able to work to their fullest.

February 21, 2013

pictures on top

Filed under: Hobbyism and Nerdry — Supersonic Man @ 5:01 pm

It was bugging me that the text along the right hand side of this blog would be rendered on top of my lovely pictures. So I experimented, and it turns out that WordPress is perfectly happy to let you add this little adjustment to your <img> tags:


January 23, 2013

Artificial Intelligence — what’s coming

Filed under: Hobbyism and Nerdry,the future!,thoughtful handwaving — Supersonic Man @ 8:08 pm

This long post has been promoted to become a page on my personal website, here.

Next Page »

The Rubric Theme. Create a free website or blog at


Get every new post delivered to your Inbox.