Tuesday, May 3, 2016

Amazon: The Next (Next Microsoft)?

Tech has this weird, generational semi-imperialism, where a particular company seizes control of the platform everybody else needs and becomes "king" for a while, before fading into relative irrelevance when a new platform emerges. IBM and Microsoft both fit this pattern perfectly. Google and Facebook have arguably been contenders in more recent decades, except neither was really ever essential to developers.

Google search rankings have been crucial to businesses, and Facebook's got a somewhat frightening control over social interactions — and the business of implications of that were enough to terrify Google executives into acts of pitiful desperation — but neither Google nor Facebook was ever actually essential to developers. They have both been arguably essential to businesses, but attempts to paint Google or Facebook as hegemonic tyrants in the 1980s/1990s Microsoft style don't really work, in my opinion, because while businesses do have an equivalent level of dependence on these platforms, developers don't.

So look at Amazon in that light. How many startups run on AWS? In 2015, AWS made Amazon almost as much as Amazon's retail operation did, and in 2016, Jeff Bezos expects it to hit $10B (about three times as much as Amazon retail).

Right now, being able to run all your infrastructure on Amazon is kind of awesome, although not without challenges. But if the last decade or two have disproved (or at least provided a counterexample to) this idea that tech's history consists mostly of cycles of platform domination, the 2020s might be a strong example in favor of the theory, with Amazon in control.

Tuesday, April 19, 2016

Rails, RSpec, Poems, And Synthesizers

I've been re-watching Gary Bernhardt's classic series of screencasts Destroy All Software, in part because I'm eagerly anticipating the new edition, Destroy All Software: Civil War. In this edition, David Heinemeier Hansson will face down Bruce Wayne, and everybody will have to pick a side. I'm really looking forward to it. I think, also, that Luke turns out to be his own cousin, or something, but a) I think that's just a rumor, and b) if you know, don't tell me, because spoilers.

Anyway, there's a screencast which covers conflicts between the existing "rules" of object-oriented programming, specifically, inherent conflict between Tell Don't Ask and the Single Responsibility Principle. I'm into this topic, because my book Rails As She Is Spoke is mostly about similar conflicts.

One interesting thing that comes up in this screencast, mostly in passing, is that Rails enthusiastically embraces and encourages Law of Demeter violations. In fact, if you build Rails apps, you've probably seen a line of code like this now and then:

@user.friends.logged_in.where(:last_login < 4.days.ago)

This code subordinates the Law of Demeter to the Rule Of Thumb That Rails Code Should Look Like Cool Sentences. Lots of other things in Rails reveal this same prioritization, if you look at them closely. In fact, when Mr. Hansson wrote a blog post about concerns, he explicitly stated it:
It’s true that [avoiding additional query objects in complex model interactions] will lead to a proliferation of methods on some objects, but that has never bothered me. I care about how I interact with my code base through the source.
It's extremely tempting to laugh this off. "Wow, this guy prefers pretty sentences to considering the Law of Demeter, what a n00b." And I am definitely not going to endorse that blog post, or the idea of concerns, across the board. But I also think laughing off DHH's priorities here would be a mistake.

Consider RSpec, for the sake of comparison. RSpec prioritizes a sentence-y style of code, which tries hard to look like English, over just about any other consideration, as far as I can tell. And RSpec has an Uncanny Valley problem. This code has both an Uncanny Valley problem, and a Law of Demeter problem:

@user.should_receive(:foo).with(:bar).and_return(:baz).once

By contrast, it's very interesting that Rails only has Law of Demeter problems, when it does the same kind of thing. The Rails valley is not uncanny at all. When it tries to make Ruby look like English, it stops a little earlier than RSpec does, acknowledging the fakeness and the Ruby-ness of the "English," and in so doing, you end up with code which is English-like enough to be incredibly convenient and easy to read, but not so overly-trying-to-be-English that you can't reason about its API and are forced to memorize everything instead.

Rails encourages specific Demeter violations as a set of special, privileged pathways through unrelated objects and/or objects which exist only to serve as those pathways in the first place. And it works. I'm not saying Rails is perfect — if you've read my book, or indeed ever read anything I've written about Rails since about 2011, then you know I don't think that — but I don't think its cavalier attitude towards the Law of Demeter would even make it onto a top ten list of things I want to change about Rails.

Of course, the whole point of that screencast I mentioned, which points out that the "rules" of OOP conflict with each other from time to time, is that these rules are not rules at all, but merely guidelines. So it's no surprise that they involve tradeoffs. What is surprising is that I don't think there's any real name for what Rails chooses to prioritize over Demeter, except perhaps "readability."

Frankly, it's moments like this when I feel privileged to have studied the liberal arts in college, and where I feel sorry for programmers who studied computer science instead, because there's no terminology for this in the world of computer science at all. Any vocabulary we could bring to bear on this topic would be from the worlds of literature, poetry, and/or language. I know there's a widespread prejudice against the liberal arts in many corners of the tech industry, where things like literature and poetry are viewed as imprecisely defined, arbitrary, or "made up," but every one of those criticisms applies to the Law of Demeter. It's not really a law. It's just some shit that somebody made up. Give credit to the poets for this much: nobody ever pretended that the formal constraints for haikus or sonnets are anything but arbitrary.

Let's look again at our two lines of example code:

@user.should_receive(:foo).with(:bar).and_return(:baz).once # no
@user.friends.logged_in.where(:last_login < 4.days.ago) # ok


If you were to write one of these lines of code, it would feel like you were writing in English. The other line could function as an English sentence if you changed the punctuation. But what's interesting is that these two statements don't apply to the same line.

This one feels harder to write, yet it functions almost perfectly as English:

@user.should_receive(:foo).with(:bar).and_return(:baz).once
# "user should receive foo, with bar, and return baz, once"

Writing this one feels as natural as writing in English, but falls apart when treated as English:

@user.friends.logged_in.where(:last_login < 4.days.ago)
# "user friends logged in where last login less than four days ago"

These are extremely subjective judgements, and you might not agree with them. Maybe the RSpec code isn't such a good example. What I find difficult about RSpec is remembering fiddly differences like should_receive vs. should have_selector. I'm never sure when RSpec's should wants a space and when it wants an underscore. Why is it should have_selector, and not should_have_selector? Why is it should_receive, and not should receive? RSpec has two ways to connect should to a verb, and there doesn't seem to be any consistent reason for choosing one or the other.

In actual English grammar, there are consistent connections between words, whereas with RSpec, you kind of just have to remember which of several possible linkage principles the API chose to use at any given moment. To be fair, English is a notoriously idiosyncratic language full of inconsistencies and corner cases, so writing RSpec might actually feel like writing English if English isn't your first language. But English is my first language, so for me, writing RSpec brings forth a disoriented sensation that writing English does not.

(Tangent: because I'm a first-generation American, and England is "the old country" for me, English is not only my first language, but my second language as well.)

Anyway, the question of why Rails feels more natural to me than RSpec — and I really think it's not just me, but quite a few people — remains unanswered.

There is another way to approach this. This is an analog synthesizer:



These machines have a type of thing called envelopes.



Briefly, an envelope is way to control an aspect of the synthesizer. This synth has one envelope for controlling its filter, and another for controlling its amp (or volume). It doesn't matter right now what filters and amps are, just that there are two dedicated banks of sliders for controlling them. Likewise, it doesn't matter how envelopes work, but you should understand that there are four controls: Attack, Decay, Sustain, and Release.

Now look at this synthesizer:



The envelope controls are much more compact:



This synthesizer again has one envelope for its filter, and another for its amp. But this synthesizer wants you to use the same single knob not only for each envelope, but even for each of the four parameters on each envelope. Where the other machine had eight sliders, this machine has one knob. You press the Attack button in the Filter row to make the knob control the filter attack. You press the Release button in the Volume row (as pictured) to make the knob control the amp release. (And so on.)

Do hardware engineers have a word for this? If they do, my bad, because I don't know what it would be. User experience designers have a related word — affordances, which is what all these controls are — but I don't know if they have a word for when you dedicate affordances on a per-function basis, vs. when you decide to double up (or octuple up). It is, again, a tradeoff, and as far as I can tell, it's a tradeoff without a name.

But it's the same basic tradeoff that Rails and RSpec make when they pretend to be the English language, and somehow, Rails gets this tradeoff right, while RSpec gets it wrong. When I need to recall a Rails API which mimics English, it's easy; when I need to recall an RSpec API which mimics English, there's a greater risk of stumbling. With should_receive vs. should have_selector, the relationship between the API's affordances and its actions is out of balance. RSpec here has the opposite problem from the synthesizer with one knob for every envelope parameter. Here, RSpec's got an extra affordance — using an underscore vs. using a space — which has no semantic significance, but still takes up developer attention. It's a control that does nothing, but which you have to set correctly in order for the other controls to not suddenly break. Rails, by contrast, has a nice balance between affordances and actions in its APIs.

Sunday, April 10, 2016

The Fallacies Of Distributed Coding

If you only ever write code which runs on one machine, and only ever use apps which have no networked features, then computers are deterministic things. It used to be a given, for all programmers, that computers were fundamentally deterministic, and thanks to the internet, that just isn't true any more. But it's not just the rise of the internet, which its implicit mandate that all software must become networked software, which has killed the idea that programming is inherently deterministic. Because everybody's code became a distributed system in a second way.

If you write Ruby, your code is only secure if RubyGems.org is secure. If you write Node.js, your code is only secure if npmjs.com is secure. And for the vast majority of new projects today, your code is only secure if git and GitHub are secure.

Today "your" code is a web of libraries and frameworks. All of them change on their own schedules. They have different authors, different philosophies, different background assumptions. And all the fallacies of distributed computing prove equally false when you're building applications out of extremely modular components.
  1. The network is reliable. This is obviously a fallacy with actual networks of computers, but "social coding," as GitHub calls it, requires a social network, with people co-operating with each other and getting stuff done. This network mostly exists, but is prone to random outages.
  2. Latency is zero. The analogy here is with the latency between the time you submit a patch and the moment it gets accepted or rejected. If you've ever worked against a custom, in-house fork of a BDD library whose name.should(remain :unmentioned), because version 1.11 had a bug, which version 1.12 fixed, but version 1.12 simultaneously introduced a new bug, and your patches to fix that new bug were on hold until version 1.13, then you've seen this latency in action, and paid the price.
  3. Bandwidth is infinite.
  4. The network is secure. Say you're a law enforcement agency with a paradoxical but consistent history of criminality and espionage against your own citizens. Say you try to get a backdoor installed on a popular open source package through legal means. Say you fail. What's to stop you from obtaining leverage over a well-respected open source programmer by discovering their extramarital affairs? I've already given you simpler examples of the network being insecure, a few paragraphs above. I'm hoping this more speculative one is purely hypothetical, but you never know.
  5. Topology doesn't change.
  6. There is one administrator.
  7. Transport cost is zero. Receiving new code updates, and integrating them, requires developer time.
  8. The network is homogeneous.
Open source has scaled in ways which its advocates did not foresee. I was a minor open source fan in the late 1990s, when the term first took hold. I used Apache and CPAN. I even tried to publish some Perl code, but I was a newbie, unsure of my own code, and the barriers to entry were much higher at the time. Publishing open source in the late 1990s was a sign of an expert. Today, all you have to do is click a button.

The effect of this was to transform what it meant to write code. It used to be about structuring logic. Today it's about building an abstract distributed system of loosely affiliated libraries, frameworks, and/or modules in order to create a concrete distributed system out of computers sending messages to each other. The concrete distributed system is the easy part, and people get it wrong all the time. The abstract distributed system is an unforeseen consequence of the incredible proliferation of open source, combined with the fact that scaling is fundamentally transformative.

Friday, March 25, 2016

DJ Arx: Elemental

More drum and bass from my alter ego. Like with Ghost Rockets, this one has a full-length video, and is a bit soundtrack-y and abstract.

Wednesday, March 23, 2016

Reddit & Hacker News: Be A Non-User User

When Ellen Pao was forced out of Reddit by a horde of angry misogynists, I deleted all my Reddit accounts. But I ended up going back to Reddit for its /r/synthesizers subreddit. I've been making music with synths my whole life, but last summer, I taught a class on it, so I wanted to do some extra research.

Soon after, I discovered /r/relationships, where so many people spend so much of their time talking young women out of relationships with older abusive men that the subreddit might as well be called /r/abusepreventionvolunteerstargetingaveryspecificageprofile (except for all I know that might exist too). They help abused men get out of danger, too, and you do see the occasional abusive relationship where both parties are roughly the same age, but for some reason, 9 times out of ten, it's a naive 23-year-old woman dating an abusive 37-year-old man. There's a colossal irony in this: a site which is famously overrun with misogynists also hosts a fantastic resource for abused women.

At first I read this subreddit as a guilty pleasure, thinking that nothing could be more hilarious than the type of idiot who looks to Reddit for relationship advice. But when I discovered this theme, I realized this subreddit was doing a good thing. It's a force for good in the world, or whatever.

So I read these subreddits occasionally, and others, without ever logging in. I can't log in, because I deleted my accounts, but I'm glad I did, because reading Reddit without logging in is much, much more pleasant than being a "user" of the site in the official sense. The same is true of Hacker News; I don't get a lot out of logging in and "participating" in the way that is officially expected and encouraged. Like most people who use Hacker News, I prefer to glance at the list of stories without logging in, briefly view one or two links, and then snark about it on Twitter.

Let's actually compare these use cases from the perspective of behavioral economics. The upvote/downvote dynamic is one which incentivizes groupthink and long conversations. So if you go on Reddit or Hacker News, you see groupthink and long conversations. Twitter's prone to hate mobs and abuse, but if you're just doing a brief bit of snark on there about some random link from Hacker News, you're probably experiencing Twitter's happy path, which encourages snippets of decontextualized wit. The decontextualization turns out to be incredibly important. Decontextualization is why snarking about Hacker News on Twitter is a better user experience for discussing Hacker News stories than logging into Hacker News.

On Hacker News, if you say something people hate, they can downvote it, and if you say something they like, they'll upvote it. When you see your own post, it's ranked in a hierarchy next to other stuff people said, which is also ranked in that same hierarchy. On Twitter, you can get retweeted or starred/heart-ed, but tweets kind of just float randomly through time. You can find out if people love your tweet or hate it, but you don't get direct comparison to other remarks on the same topic, which is great. That direct comparison is a terrible feature. On a site which incentivizes groupthink, if you're the top post, you're almost guaranteed not to have the best insight. Good insights don't survive groupthink.

If you do have the best insight, you can calculate the stupidity of the group as a whole by measuring how far your post is from the top. But it's rarely so linear. Usually, a Hacker News thread will have a ton of bullshit, plus some good insights here and there. The best insights are usually about midway through the hierarchy, or near the bottom half of the middle section, which says to me that the audience as a whole is more stupid than smart, but also often contains smart people.

Everything I'm saying about Hacker News is true for Reddit in theory as well. You can definitely see it on programming subreddits all the time. In fact, programming subreddits are even worse than Hacker News. But Reddit serves a much larger and more diverse audience, and some subreddits (as I mentioned above) do remarkably good things with it, despite its fundamental design flaws. The audience is an important factor; Lobsters gets a lot of mileage out of being nothing but an HN clone with less idiots.

Long story short, the best way to use these sites is to never log in. And if you're building social software, you should really think about this.

First, your sites don't exist in isolation. In the prehistoric epoch when Hacker News was created, there was this idea that sites were self-contained universes. Today we know that a lot of the people who talk to each other on Hacker News are talking to each other on Twitter as well. So you have to keep in mind that even when people want to talk about the stuff they find on your site, it's unrealistic to assume that your site would be the only place they'd go to talk about it. If they have to create a login, but they already have logins on several social networks, a person with a login is not just a "user," they are a user who, in addition to finding reasons to use the site, also and subsequently found a reason to log in.

Second, neither of these sites seems to acknowledge that using the sites without being a "user" is a use case which exists. In the terms of both sites, a "user" seems to be somebody who has a username and has logged in. But in my opinion, both of these sites are more useful if you're not a "user." So the use case where you're not a "user" is the optimal use case. Conceptual blind spots often birth silly paradoxes.

Tuesday, March 22, 2016

An Unsolvable Math Problem Inherent To Space Vinyl

One thing science fiction authors often fail to consider is metabolic differences in perception of time. There are a subset of human musical creations which are very similar to the music of birds, just much slower. That same subset is also very similar to the music of whales, just much faster. Birds are tiny creatures with extremely rapid heart rates and their songs are incredibly fast; whales are giants with slower heart rates and their songs are incredibly slow.

When you look at three different types of animals — ourselves, whales, and birds — that all discovered melody, you can see a universality there, but it's actually easier to see it than to hear it. If you transcribe whalesong or birdsong into Western musical notation, its similarity to various forms of human music becomes easier to discern.

The most obvious science fiction consideration here came and went, without anybody handling it reasonably, fifty years ago. We sent a metal record, like a vinyl record but made out of metal, out into space, in the hopes that any creature which found it one day might be able to learn of human music. We included an instruction manual, but even so, what did we know about how an alien who found the record would perceive music which was optimized for our physical size, our heart rate? If an alien similar to a whale finds this music, they will think it incomprehensibly fast; if an alien similar to a bird finds it, they will experience it as bizarrely slow.

Or to be even more obvious, consider that human music is necessarily optimized for the range of audio frequencies that human ears can perceive. Even age differences among humans are enough to cause different perception capacities here. There are frequencies which teenagers can hear, but adults can't, and convenience stores sometimes use this fact against teenagers. They'll play loud sounds in those frequencies to annoy the teenagers without adults even being aware of it, to stop the teenagers from treating their stores as places to hang out. Obviously, if aliens one day discover this metal record floating in space, and they figure out how to build the record player from our oddly IKEA-like diagrams, there's no guarantee that their ears will be able to perceive the same range of frequencies, or indeed that they will even have ears in the first place.

There's a type of extremely complex and multi-dimensional ratio here which we have no way to estimate ahead of time; the ratio of the speed at which sound changes over time in a given piece of music, vs. the speed at which sound normally changes over time, in the perception of listeners of a particular species.

So my big hope for that space record is that, thousands of years ago, aliens abducted a small number of us and transplanted us to a new planet just to see what would happen; that those human beings thrived on this other planet, with no knowledge of our own planet except a few half-forgotten legends; and that these "alien" humans will be the ones to discover that record. Not only is it the most likely way to expect that the music on there will ever be truly heard, it would also be a very weird and exciting experience for the people who found it.

Thursday, March 10, 2016

DJ Arx: Ghost Rockets

Here's the latest video from my DJ Arx project. This is drum and bass pulling a lot of its inspiration from classic British dubstep (i.e., the original sound, before Skrillex, which sounded a lot different).

Saturday, February 27, 2016

DJ Arx: Hail Up Jah (Vocal Version)

More music from DJ Arx, the Batman to my Bruce Wayne.

Sunday, February 21, 2016

How Computers Feel Different Now

I learned how to program a computer on a TRS-80, in BASIC. I was six years old. At the time, "computers" meant things like the TRS-80. Today, your phone is a computer, your TV's a computer, your car's made of computers, and, if you want, your frying pan can be a computer.

But it's not just that everything's a computer now; it's also that everything's on a network. Software isn't just eating the world because of Moore's Law, but also because of Metcalfe's Law. In practice, "software is eating the world" means software is transforming the world. It might make sense to assume that software, as it transforms the world, must be making the world more organized in the process.

But if Moore's Law is Athena, a pure force of reason, Metcalfe's Law is Eris, a pure force of chaos. Firstly, consider the fallacies of distributed computing:
  • The network is reliable
  • Latency is zero.
  • Bandwidth is infinite.
  • The network is secure.
  • Topology doesn't change.
  • There is one administrator.
  • Transport cost is zero.
  • The network is homogeneous.
The first and the last — "The network is reliable" and "The network is homogenous" — are basically equivalent to saying "chaos reigns supreme." No area is ever the same, because the network is not homogenous (and the topology is ever-changing), and things don't always happen the same way they happened before, because the network isn't always there. So chaos reigns over both space (the non-homogenous network) and time (the ever-changing network which is only sometimes there).

Chaos also reigns in a social sense: the network isn't secure, and there are many administrators. So if Moore's Law makes everything it touches more automatic and organized, Metcalfe's Law makes everything it touches less reliable and more unpredictable. An unspoken assumption you can see everywhere is that "software is eating the world" means that the world is becoming more organized along the way. But since networking is an implicit fundamental in the definition of software today, everytime software makes the world more organized, it brings networking along with it, and networking makes everything more chaotic.

Everything that software eats becomes newly organized and newly chaotic. Because you have a new form of organization replacing an old form of organization, while a new form of chaos replaces an old form of chaos, it's impossible to really determine whether or not software, when it eats the world, makes it more organized or more chaotic. The net effect is impossible to measure. You might as well assume that they balance perfectly, and Moore's Law and Metcalfe's Law are yin and yang.

But the thing is, when personal computers were a new idea, they emanated order. You typed explicit commands; if you got the command perfectly right, you got what you wanted, and it was the same thing, every time. They didn't have the delays that you get when you communicate with a database, let alone another computer on an unreliable and sometimes absent network. They didn't even have the conceptual ambiguity that comes with exploring a GUI for the first time.

Even the video games back then were mostly deterministic. It's why big design up front looks so insane to developers today, but made sense to smart people at the time. During WWII, the cryptographers who developed computing itself were mathematicians who based everything about computing on rock-solid, Newtonian certainties. You did big design up front because everything was made of logic, and logic is eternal.

This is no longer the case, and this will never be the case again. And this is what feels different about computers in 2016. A few decades ago, "non-deterministic computer" was a contradiction in terms. Today, "non-deterministic computer" is a perfect definition for your iPhone. Everything it does depends on the network — which may or may not exist, at any given time — and you can only use it by figuring out a graphical, haptic interface which might be completely different tomorrow.

Every Netflix client I have operates like a non-deterministic computer. Here's a very "old man yells at cloud" rant. This happened. I go on Netflix, and I start watching a show. There's some weird network glitch or something, and my Apple TV restarts. I go on Netflix a second time, and I go to "previously watched," but the Apple TV didn't tell the network in time, so Netflix doesn't know I was watching this show. So I go manually search for it, and when I hit the button to watch it, Netflix offers me the option of resuming playback where I was before. So it knows I was watching it, now.

Basically, whatever computer cached the list of previously watched shows didn't know the same thing that the computer which cached the playback times did know.

A few decades ago, it was impossible for a computer to have this problem, where the right hand doesn't know what the left hand is doing. Today, it's inherent to computers. And this has long-term consequences which are subtle but deep. Kids who see chaos as an intrinsic element of computing from the moment they're old enough to watch cartoons on Netflix are not going to build the same utopian fantasies that you get from Baby Boomers like Ray Kurzweil. My opinion of transhumanists is that they formed an unbreakable association between order and computers back when networks weren't part of the picture, and they never updated their worldview to integrate the fundamental anarchy of networks.

I don't want to old man yells at cloud too much here. That's where you get these annoying rants where people think the iPad is going to prevent kids from ever discovering programming, as if Minecraft were not programming. And I'm already telling you that the kids see the world a different way, like I'm Morley Winograd, millennial expert. But there's a deep and fundamental generation gap here. Software used to mean order, and now it just means a specific blend of order and chaos.

Monday, February 15, 2016

DJ Arx: Hail Up Jah (Piano Version)

My latest drum and bass track, a very melodic piece.