Monday, January 13, 2014

on frameworkless javascript

An article that appeals to my personal stances about Javascript toolkits; I'm always a little hesitant to go too much into my views, because I don't want a potential future employer to think I can't be a team player in terms of adopting a toolkit they're using, or that I'm mired in a "Not Invented Here" (NIH) outlook. Also, my outlook isn't entirely well-researched at this point, I haven't used every one of the major toolkits.

Whenever you add a technology that increases the distance between what you are looking at in the debugger window and what code you wrote yourself, you might be making life more difficult even as it seems "easier" to do other tasks. It's one thing for a toolkit to offer lots of power and save you lots of coding, but if you can't model how it's doing what it's doing, you're not being a good programmer. (Down to a certain level, of course, it's not like I think in assembly language and circuit gates-- but it has to be down to a point of solidity and robustness) The nadir of this style of coding was with Microsoft in the aughts; legions of coders who were writing lots of powerful stuff but had no idea what to do when it went wrong.

For me the way to best leverage what other coders have done is to prefer "do one thing well" tools over frameworks, keeping the core code in as "pure" a language as possible, like raw JavaScript, but then farming out annoying things (like templating or animation/transitions) to a self-contained tool, like jQuery or handlebars.

Thursday, January 9, 2014

on smartwatches and doing a few things well

For Christmas I received a Pebble smart watch. I think it works well because it doesn't try and do to much: it's pretty happy just being a watch (with options for different watchfaces, and even an ability to roll your own (and I'm very tempted to try and port Timish, a "watch for literate time" I prototyped in Javascript a while back)) and showing you notifications.

Of course, the makers of the watch would be mad at this description: it can do more than that! There's a whole app store! It can control music! There's an accelerometer! It can... well, I dunno. The physical interface is a bit limited. I'm sure there's a bunch of stuff it could do, but it raises the question: why?

But I find the notifications feature worth the price of admission. It's great not to have to dig out my phone to see if a message is important, and the watch's vibration on my wrist is much easier to notice than one from an iPhone that's jammed in a pocket. It's also reduced the amount of "phantom vibrations" and I check my pocket for imagined alerts less often.

This is in contrast to what the Galaxy Gear offers in this creepy, creepy ad:


That's a lot of features! But the ad has to bundle up its people in ski gear or load them down with wine glasses to make their point... otherwise all of those functions are going to be easier to do on the companion phone itself, with its fullsize screen. (One exception might be the camera... but then that gets into the whole realm of surreptitious photography aka creepshots.)

I was trying to quantify the boundary of "useful" to "just nice to have, maybe" and realize the Pebble's sweetspot maps 1:1 with the information on my phone's lockscreen: the time, and notifications that may have occurred. Everything else I'd have to swipe to get to anyway. The watch saves me from having to dig out the phone, and makes glancing at at least the sender if not the subject or some of the content of a message very discrete.

(So, reviews of the Galaxy tend to be pretty mixed: the camera feature is solid, and the "talk like Dick Tracy" seems kind of fun. There are still some fundamental issues, mostly concerning battery life.)

It's an exciting space. The Pebble is meeting my needs well right now, though I might jump on the bandwagon once Apple gets its act together. I think the Gear might be a little underrated, but who knows.

For at least the medium term if not longer, I think connected watches will be much more useful and fun than, say, Google Glass. I got to play with one during the holidays, and man, it was so not ready for prime time... an ugly little screen floating in my vision, looking like an Atari 2600 screenshot from ten feet away, having to reach up and stroke the side of the ugly frames, feeling like I was looking like a freak to people who didn't know what I had on, and a potential creepshot taking perv to those who do... decades from now, it might be useful to have information bounced off some lenses, but right now I'm pretty skeptical about this flavor of ubiquitous computing. (Or maybe I'm just turning into an old codger.)


Friday, January 3, 2014

improving encapsulation with a singleton pattern in js

A while back I blogged about a simple javascript singleton pattern. Recently at work I got called on the fact that it was doing a bad job at encapsulation, specifically there was nothing like public/private functions in it, even though I was implementing an API with functions that might as well have been private, for clarity purposes.

The core pattern was something like
var someObject = new function(){
    this.someVariable = undefined;

    this.init = function(){
        alert("started up");
        someObject.someVariable = true;
    };
}
The slight variant goes like this
var someObject = new function(){
    var somePrivateVariable = null;
    var somePrivateFunction = function(){
        alert('shh');
    }
    this.somePublicVariable = null;
    this.somePublicFunction = function(){
        alert(somePrivateVariable); //still has access because of function level scoping
        somePrivateFunction();
    }
}

Now the outside world has access to the public things but not the private ones.


Friday, December 13, 2013

from information superhighway to web to stream to THE GREAT BEYOND

An Atlantic article, The Year 'the Stream' Crested, wonders if people are getting burnt out the endless wall style of running into information, and will withdraw from the sense of being "permanently unfinished". (The subheadline of the piece asks "The Stream is fun and fast, but don't you miss the sense of an ending?", and is therefore subject to Betteridge's Law of Headlines)

The Internet of the mid-90s had a much different vibe than the place today. Authors could make books, physical dead-tree books, full of interesting links on the "information superhighway". Yahoo made its mark by providing a searchable set of links that were submitted and vetted by humans-- nowadays, we'd call that "curated"-- and then Google came along and made a new, searchable world where the reputation of a site mattered more than its ability to stuff the keyword you were searching for 100,000 time in its hidden content. This is when the Web really came into its own, because Google made the interconnectedness really matter.

The early-2000s were an interesting time. People were empowered to carve out their own niche on the web and the era was marked by the Rise of the Blogs.  Word-of-mouth and Google would let these sites gain regular audiences. Some of the more popular blogs, like BoingBoing or to a lesser extent Slashdot, had multiple editors to select the content, and a link from a popular site could send hitcounts skyrocketing.

And then came Facebook. Its News Feed was a powerful idea: by showing what people were posting on their Walls, you had a single age that was an aggregation of content by somewhat-like minded people. This was more egalitarian than the old blog model. (Those democratic notions were pushed even further on sites like Reddit, allowing popular links to be voted into attention in more global ways, not just among overlapping groups of Friends) They weren't the first to offer this "one stop shopping" view (I think of LiveJournal's Friends page (among other examples)) and they certainly aren't the only: Tumbler and especially Twitter are centered on that very concept. However, Facebook combined this type of Stream with the ability to connect with people you know in the real world, and started doing so at a time when most other sites were still letting people pick their own identities, ala AOL back in the day.

I think Facebook really changed the nature of the Web. For many years my personal website was the center of the online world for me and several friends, and had a vibrant comments section (as crappy and homebrew and prone to occasional spammer attacks as it was) -- in the late part of the last decade, that went away. Similarly my romance poetry site Love Blender went from having 400 submissions of poems a month in 2004 to 20 or so now. Now, this might just mean I'm a bad web marketer, and that's true, but I've heard of other similar experience people have had, and I really think Facebook is the harbinger of that change. It's simply more compelling to have a bunch of your friends finding interesting stuff than one friend, or a group of strangers.

So what now? This Wired article from earlier this year sees the future as all-stream, all-the-time. An article on medium.com (I find its reticence to label itself with a date irksome) rejects this and sees the traditional web of information at fixed retrievable locations reigning supreme. The answer, as always, is somewhere in between. The Stream taps into the deep "fear of missing out", as well as promising all-too-easy distractions from the workaday world. But the fixing of these infonuggets at reliable locations in cyberspace (man, remember that word?) is critical as well, both for sharing and for the benefit of our future selves, making sure that retrieval tomorrow is possible.

Wednesday, December 4, 2013

upon the nature of Java Swing vs HTML5

Taking over some Java Swing UI code... compared to HTML5/js, it feels SO WEIRD to try and build your nouns via a series of verbs...

Talking about this idea with a coworker, he pointed out I might be feeling the lack of "MVC"-- in a way HTML has the page as the view and the javascript as the controller, and I miss that when I have to build everything via commands in Java Swing.

Tuesday, December 3, 2013

the power of cdns

One of the people behind 4chan (NSFW site, in general) writes about small advantages adding up in use of a CDN.

A CDN is a "content delivery network", often a place to put "write once, read many" static content. We had found similar advantages to switching to a CDN at Alleyoop-- the way the cookies don't get sent is very helpful in reducing bandwidth. (And converting the embedded image references in the html to the new location was an awesome Perl task for me...)