ES6, the bad parts: When a constant is not constant

tl;dr – I like const, but recommend you use it like old-school programmers, and only on primitive values.


ES6 adds the const keyword to javascript. It does pretty much what is says on the tin: creates a constant.

Constants are a feature of many languages. The keyword has its origin in compiled languages. If you tell a compiler that something is constant, the compiler can optimize that code.

But guess what? It’s the second decade of the 21st century. Time for compilers to man-up! Compilers need to optimize without hand-holding from human programmers. Lots of good ones do.

There is a second value to constants, though – the constant (or const) keyword signals intent to future programmers who read the code. In that service, it is very effective. It waves a big flag in front of future readers: “Beware! This is constant!” That’s why I am broadly in favor of the const keyword. Still, in ES6-terms, I have a couple of bones to pick:

First, javascript is a wiggly language. It has a series of types (objects, arrays, collections, and functions) that are treated as objects. And objects, in javascript, can only be assigned by reference, not by value. As a result, a const of any of the types listed above is really just a reference to the actual object. Which remains non-constant.


const OBJ = {foo:'bar'}; // is this really contstant? = 'alpha'; // Nope = 'beta'; // Really nope

So what, exactly, am I asserting to future programmers when I declare OBJ is a constant? How does that prevent errors? Isn’t it just really confusing?

The easy answer would be to follow the spirit of Douglas Crockford – DON’T DO THAT! It’s a bad part. Pretend that you are not even allowed to use const on objects. But that brings me to the second issue…

Nicholas Zakas says:

However, as more developers migrated to ECMAScript 6, an alternate approach gained popularity: use const by default and only use let when you know a variable’s value needs to change. The rationale is that most variables should not change their value after initialization because unexpected value changes are a source of bugs. This idea has a significant amount of traction and is worth exploring in your code as you adopt ECMAScript 6.

He’s right about one thing: that idea has traction. I see it in lots of ES6 code examples. No doubt, zillions of naive  programmers will stick const in front of everything, because it is a so-called “best practice.” And they won’t even be aware that the value is still super-duper mutable.

But I fear it is even worse than that! Making const the default way to declare variables sucks the signalling mechanism from it. In earlier languages, constant declarations are used sparingly, in uppper-case even (as if to shout at you). They want you to know something important: “Yes, I really intend for this to be immutable.” The convention Zakas recommends says “I guess this probably won’t change. But if it does, I have to remember to change the declaration. Unless it’s really just an object reference.”


I am fighting a losing battle, but I will confine my personal use of const to primitive values, and only those that I want to make a big deal about. I hope you’ll do the same.


Paying for software in the age of Open Source

Fair to say that no one wants to pay for software. Or beer. And yet… beer sales are robust. Software maybe less so.

Unlike beer, many software programs have excellent, free substitutes. But sometimes the commercial stuff is just better. Worth paying for, even.

For example, a couple of years ago I switched from Netbeans (free!) to Webstorm ($$$). Netbeans is really good. Webstorm is much better. At least for javascript development.

Once upon a time, a long time ago, I was laid off from a web development job. My employer used an expensive development system that I had grown quite fond of. So when I left, the worst part was that I was cut off from my favorite (at that moment) system. At that point, I resolved that I would only work with tools that I could fund on my own.

These days, I pay an annual license for Webstorm. And a monthly fee for hosting. And I pay for domain names. And video games. And I’m not opposed to paying small amounts for other software, if it is unique, or better than free alternatives.

But I do scrutinize each purchase. And anything over $75 probably isn’t happening.


Review – Disrupted

Disrupted: My Misadventure in the Start-Up Bubble

Disrupted is Dan Lyons’ account of his not-quite two years at a tech startup called HubSpot.

Lyons is a long-time tech journalist, with stops at PC Week, Forbes, and Newsweek. He is also the author of the Fake Steve Jobs blog, so you know he is an acerbic wit.


The book is a fun, quick read. You’ll gain insights into startup culture, and the open ageism that prevails in the tech industry.

However, there’s not enough material to fill a book, even a short one. Lyons fills pages by beating issues into the ground, and pausing to stitch together little essays on the state of the tech industry.

Things that bugged me

1) For sure, the industry is riddled with ageism. Lyons catalogs the attitudes, statements, and off-the-cuff remarks of his much younger colleagues. But… he really doesn’t help the cause.

  • He mistakes his manager for an intern, and proudly explains that he barely paid attention to interns at Newsweek.
  • He makes close to zero efforts to fit in. He won’t attend an evening hack-a-thon, or hang out at a cocktail mixer after a conference. He keeps telling everyone he has kids. As if that makes him a special entitled person who can opt out of all evening work. It’s not even that often. If he misses one evening a week, I don’t think that robs him or his children of fatherhood. And it wasn’t even that often.
  • When it comes to jetting around the country to attend conferences or write for HBO, he stops having kids.
  • He makes a special effort to befriend every other worker over the age of 35. Admittedly, a small group. But he fails to befriend anyone under 30, except for the receptionist.

At some point, you start to realize that the ageism river runs both ways with this guy. He is no more at ease with young people than they are with him.

Near the end of the book he starts referring to himself as an anthropologist, studying this cult of young startup workers.  That book needs to be written. But not by Dan Lyons.

2) Possibly to fill pages, or possibly because he is just that spiteful, Lyons viciously attacks every little thing. He makes mountains of molehills. There is plenty of material worth mocking: the Newspeak, the brainwashing techniques, the actual ageism, the product itself. But he goes over the moon to attack little things like the company logo (not great, but no Airbnb), the company color (orange),  Mollie the Teddy Bear, free candy, food and drinks, and parties.

3) Lyons is a bubbler. That is to say, he is convinced that there is a valuation bubble going on right now. Startups are over-valued, and surely a day of reckoning will come. But… so what? Points for being clever enough to spot it, but what can any one of us do about it? More to the point, should we do anything about it? Maybe exploit it, like he tried to do?

4) Lyons argues that Silicon Valley is inventing a new social contract with workers: work is a tour of duty – it is finite – when it ends, you go find a new gig.

Is this stressful for workers? Yes. Maybe. For some subset of people. And also, it’s not universally true.

First, the lifetime-employment-as-social-contract thing has been eroding rapidly for 30 years. Silicon Valley did not invent it. Perhaps they are embracing the end state, and talking about it openly. Honesty is not a bad thing.

Second, 20% of the workforce is employed by government agencies. These people mostly do have lifetime employment. If stability is important to you, perhaps you should seek a life of public service.

Third, gig-work is not aweful for at least some part of the workforce. For example, programmers are in chronic demand, command high salaries, and honestly find it advantageous to switch jobs every 2-3 years.

Fourth, Lyons at one point takes a lunch with a founder of another local startup. This founder is pursing a sort of anti-HubSpot strategy – grow organically, hire experienced pros, pay well. Seems to be working out for him. As Qui Gon said, “there’s always a bigger fish.”

But granted – marketers, writers, inside sales people on marginal salaries are not going to thrive in a “tour-of-duty” system.

5) Final dislike – Lyons is just completely disingenuous. He would have us believe that his motives were at all times pure. He is proud to be an experienced, cynical journalist. But he ignores every obvious sign that he is not a good fit at the company. He tells us that he was totally committed, but then catalogs all the lunches he had with outside sources he cultivated. He says the book is a light-hearted reflection on a fish-out-of-water experience, when it is clearly a frontal assault on HubSpot.

Things I liked 

1) There is a brief, but complete catalog of ageist things his co-workers naively said to him. Silicon Valley dearly needs a modern version of The Jungle, exposing its cruel ageism. Sadly, Lyons is not our Upton Sinclair. But he shines more light on the subject than anyone else to date.

2) Lyons does a great job of exposing the secret of modern startups – cheap labor! Outside of programmers, there is a glut of under-employed recent college grads. For less than 2x minimum wage, you can hire these kids – and retain them with free candy, beer, and a playful-looking environment.

The kids will find better jobs in 2-3 years, and that’s okay!

Lyons thinks this is aweful. But really, what other options do all these kids have? Yes, the candy and the Newspeak and the parties brainwash the kids into a state of happiness, despite their below-living wage. Would it be better if they somehow worked in dreary offices with no perks and nothing to distract them from their low wages?

The startup jobs are not great. Later in life, they will ruefully admit it. But right now, they are out of their parents’ house in the daytime, gain experience, and fill up with self-esteem.

(Lyons rightly calls HubSpot out for lack of ethnic diversity. But I wonder now if that is really a side-effect of their overall system? Liberal-arts grads who live with their parents are the target market for inside sales and marketing jobs.)

3) The book is laugh-out-loud funny at times. Also, a page-turner. Lyons gets a bit neurotic, but you feed off that, and keep reading to see what happens next.

Lyons has a gift for acerbic comedy. That’s what made Fake Steve Jobs great. It’s why he is on the writing staff for HBO’s Silicon Valley. When he relates his inner monologue while dealing the millennial cultists, he’s brilliant. But when he is obsessing (over Mollie the Teddy Bear, for example) it’s forced.

Frontend Engineers need to know HTTP

A long time ago, during an interview, I was asked “How do forms work?” I thought it was a silly question, coming from the VP of Engineering. But I answered in as much detail as I could. Including the HTTP layer between the browser and the server. I’m convinced that my answer got me the job.

I still use this question in interviews today. It is sad how often candidates do not know the HTTP layer.

HTTP is an acronym that expands to Hypertext Transfer Protocol. It describes the way messages are passed on the web. It is, in fact “the web.”

The web (ie, HTTP), in turn, sits on top of other protocols: IP, TCP, DNS. A frontend engineer should skim the wikipedia articles and have a vague understanding of those protocols. But absolute mastery of HTTP is required. Why? To dispute with backend engineers.

Here’s what happens:

  • something funky happens in the ui
  • frontenders are called on to banish the funkiness
  • the funkiness is fundamentally spawned on the backend – frontenders may, or may not, be able to clean up on their end

If the problem is fundamentally coming from the backend, it helps, a lot, to be able to prove that to the backend programmers, and your boss. And to do that, you need to inspect the HTTP payloads. Fortunately, Chrome dev tools makes this easy. But dev tools is little help if you don’t really get what is happening in the first place.



Javascript: state of practice vs state of the art

Last year, at the day job, we were hiring javascript developers. During our long search, I probably interviewed over 60 developers. What did I learn?

  • About half of the people calling themselves javascript developers do not know any fundamental javascript. They know angular, or jquery. They can only discuss javascript in terms of their preferred high-level library.
  • Maybe 10% of those I interviewed had a really good grasp of ES5. No one had a grasp of ES6.
  • Few did any significant independent study or side projects. There was little awareness of the wide world of libraries, tools, and frameworks.
  • No one was a “rockstar” with deep simultaneous understanding of javascript, html, css, and http.

There is a huge gap between the state-of-practice, and the state-of-the-art!

I’m sure there are a handful of name-brand companies in the valley that are able to attract and retain javascript developers who are state-of-the-art. Developers with the “rockstar” skills above, plus understanding of nodejs, packaging tools, TDD, functional programming, and ES6. I know they exist, because I read their blog posts and watch their conference talks.

However, maybe it’s time to admit that those people are unicorns?

Maybe it’s time to stop feeling guilty about not being up to speed on the flavor-of-the-moment packaging system, or MV* framework, or TDD framework, or tool ecosystem, or (dare I say it?) ES6?

Maybe it is perfectly okay to keep on developing on our state-of-2013 tech stack. The people we hire have to be trained up anyway. Does it really matter if I am training them to use backbone, requirejs, less and not react, webpack, stylus?

I am pragmatic. I want to ship software. I am going to keep a sharp eye on the state-of-practice from now on, and not race too far ahead.

Review – Two-Bit Culture

Two-But Culture: the Paperbacking of America
Two-But Culture: the Paperbacking of America

Two-Bit Culture: The Paperbacking of America is a history of paperback publishing, written by Kenneth Davis in 1984. I enjoyed it, but I wouldn’t recommend it to the modern reader.

I picked this up in a used bookstore while on vacation this summer. Cultural history is my secret pleasure.

Davis opens with an introduction that announces his intent: he means to show that Americans will read “good” books, if they are nearby and cheap. Also, that mass-market books influence culture. Mission (sort of) accomplished. Davis proceeds to go through 45 years of paperbacks, in great detail. He highlights many “good” books, and calls out their impressive sales numbers. He makes a number of attempts to tie these big-selling”good” books to the wider culture.

But, at the end of the book, as he discusses the 1970s, he all but concedes that the mission of elevating the culture has given way. The book ends on a note of despair.

He also struggles to justify the sales of Mickey Spillane and Erle Stanley Gardner, who became rich and famous with their pulp fiction crime novels. In fairness, he gives it the ol’ college try, using many pages to attempt to link their work to the zeitgeist of the times.

Davis makes a curious choice at the outset: he picks June, 1939 as the the start of the “paperback revolution.” This struck me as odd, because there clearly were books with paper covers long before then. Indeed, Davis touches briefly on the history of paperbacks – going back to the early 19th century. Since he didn’t explicitly say it, I will: Davis is interested specifically in paperbound books of literary significance. Edgar Rice Burroughs may have been the first rich-and-famous “paperback writer” (as the Beatles put it), but his books are not part of the literary canon.

Starting in 1939 is fair enough, on Davis’ terms. But he does struggle to explain the success of authors like Spillane, Gardner, Harold Robbins and others.

Another tip-off that Davis is a “lit” fan is in his coverage of literary periodicals. Apparently, there was a recurring series of attempts to use the paperback format to publish the equivalent of a literary magazine.  The longest effort lasted a decade, though it had to hop among 3 publishers to last so long. Davis lavishes inordinate attention on these (mostly short-lived) journals.

With his history beginning in 1939, a book published in 1984 is either brief, or heavy on small details. Davis went for the latter. The comings and goings of executives, publishers, and editors is recounted in great detail. For all its impact and sales, paperback publishing was a small world, with a cast of players that numbers in the low dozens. At some point, my eyes glazed over, and I just skimmed the names as they were recounted, as if I were reading the “begat” sections of The Bible.

But after all, this is cultural history. Just as the order of battle is recounted tediously in a WWII history, it is important to put all those names and places on the record.

The fun parts of the book come in two parts: where Davis highlights an individual author, and when he covers the noble free-speech fight taken up by the paperbackers.

The 20th century can fairly be called the high-water mark for novelists. In addition to the enduring names (Joyce, Hemingway, et al), there were a bunch of big-selling, and therefore culturally-important, authors that we have forgotten. Davis reminds us.

The other lesson I took from this book is the key place paperback publishers played in the on-going battle for free speech. Many novels of the early-and-mid-20th-century had explicit sex scenes. Which, obviously, was not well-aligned with the overt tenor of the times. But then again, the books sold well. Davis points out that hardcovers had limited distribution, exposure, and sales. A hardcover with sex scenes might fly right under the Puritan radar. Not so with paperbacks.

Paperback publishers fought a running legal battle with a collection of local and state governments. There was even a nasty Congressional inquiry, though little came of it. In the end, publishers staked more than a prudent amount on legal expenses that blazed new precedent in the courts. And, to Davis’ point, the (prurient) paperbacks surely had an influence on mass culture.

Maybe, ten years from now, someone will produce a companion edition that details the second 40 years of paperbacks. A lot has happened since the book ended in 1984. We witnessed the rise-and-fall of the big-box bookstores, along with the rise (so far) of ebooks.

For a skimmable recap of readable 20th-century authors, highly recommended. But for the modern reader, it leaves too soon.


Women in tech, Pony Express riders, and me

Back in 1999, Steve McConnell wrote After the Gold Rush which explained that tech companies want to hire “Pony Express Riders” – young, single men who like to work hard and play hard.

Sadly, I entered the profession after my Pony Express years. I was married, with a child. Sleeping under my desk was not an option. I was jealous of colleagues who could spend nights and weekends heads-down in code.

I did okay. Don’t cry for me, Argentina.

But now, many years later, we have the women-in-tech crisis.

Keep in mind, writing about women in tech is officially dangerous for a white man like me. Be gentle. As Charles Barkley says, we can’t have a conversation if one side is automatically wrong.

A (female) colleague recently pointed me to this article. Good read.

There is a famous (though I cannot find it on google at this moment) post from a male programmer who felt dis-enfranchised due to his tea-totaling.

My add:

Males in their 20s, including programmers, like to engage in what Festivus refers to as “feats of strength.” For programmers, this includes staying up all night, drinking recklessly with colleagues, and fixing more bugs than anyone could reasonably expect in a 24-hour period.

I’m guessing that some of these feats are not appealing to female programmers.

And yet, they are mostly appealing to management.

Programmers who stay up all night, intermittently working? Awesome! Heroic bug closure rate? Awesome! Alcoholism? Collateral damage.

I imagine that many female programmers do not want to be Pony Express riders. Neither do i! I want to work hard, and professionally, for my scheduled hours. And then I want to go home. Where I will sometimes do more work. And sometimes work on a side project. And sometimes chill with my family.

So… for the last 20 years, I have worked hard to carve out work environments that are convivial to me. Selfishly. The way Capitalism is supposed to work. And… they just so happen to be convivial to female programmers.


Pony Express riders exist. The get hired. You can’t wish them away. If 2 or more of them team up, you’ve got a culture. Or, at least, a clique.

Management will always love love them. But the Pony Express is not sustainable. The historical Pony Express collapsed after 2 years.

If you are not a Pony Express employee, seek companies that have been alive for more than 2 years, that have well-renowned word/life balance policies.

Above all, take advantage of the market inefficiencies. There are too-few programmers for the current marketplace. Make your choice count.


So we bought an electic car…

To be precise, a 2013 Nissan LEAF SV. Well-appointed. Fun to drive. Woot!


I am very happy with the purchase. But I’d hesitate to recommend it to anyone else.

“The Space” – LEAF and Volt

We are not talking hybrids here. The LEAF is fully-electric. No gas. Ever.

The electronic vehicle (EV) space is small. BMW makes one, but it sells in really small quantities. Tesla makes some, and sells them as fast as they can build them, but they are really expensive. Smart Cars are silly looking. That leaves the Chevy Volt and Nissan LEAF as the EVs that normal people might buy. For the sake of this post, assume I am talking about a LEAF or Volt.


There are two inconvenient truths about EVs. Range is the first. Early LEAFs had a range of 50 miles. Later models, including mine, can range up to 80 miles. Of course, I’d allow a 20% reserve to account for hills, air-conditioning, and turbo boost. If you can live within that range envelope, EVs are a great buy. More on that below.


The second inconvenient truth. It takes 12 hours to fully recharge my LEAF. That is using a standard home electrical outlet. I could charge 4X faster with a higher voltage/wattage outlet. It will cost not less than $2000 to install such an outlet.

Related – there are surprisingly few public charge stations in america. If you travel to the suburbs (or worse) the pickings are slim. And, no matter where, you will be fighting for charge-station access with other EV owners.

Truth be told, there are just enough EVs out there to saturate the public charge stations, and make life crummy if you need a charge.


This is a good news, bad news story. Resale value is terrible. How terrible? My 2-year-old, well-appointed EV, with 13K miles, cost me just under $13,000. Original sticker price? $35k.

So, if you buy slightly used, you get a great looking/feeling/driving car for super-cheap. Just don’t expect to flip it later for anywhere near what you paid. This is a buy-and-hold car.

Look – you cannot routinely expect to buy recent, lightly-used cars for 1/3 the sticker price. We are living in crazy times. Over the next 18 months, Nissan and Chevy will reduce the supply, maybe the charging-station network will build out a bit, and re-sale values will float up. If you want a great, new-ish, cheap car – buy an EV right now!

Our Situation

We had 2 cars and 3 drivers. We needed one more car, to drive around town for shopping, errands, kids, etc. The two gas-powered cars are fine for longer-range journeys. We did not want to take on car payments, or break the bank for a 3rd car. Price was super-important.

My job is 10 miles away. So I could, in theory, commute in an electric car.

Ergo, I believe that we are the perfect target market for an EV.

The EV Market

My guesses:

  • Chevy and Nissan built too-many EVs, expecting to ride Tesla’s coattails. But Tesla’s range is 3X LEAF and VOLT.
  • Lots of people who would otherwise be happy with an affordable EV discover that they cannot live within the current range envelope.
  • Resale value: explained.
  • The next-gen of EVs, rumored to appear in 2017, will have a range of 150 miles.
  • 150 is the original range of the Tesla. and not by accident! That range gives most drivers the freedom they want.
  • Most people. I think, routinely tolerate car trips of up to 90 minutes. Allowing for traffic that equates to 60 miles. Well within 150 miles roundtrip. I think 150 is the sweet spot for EVs.



I joked with the family that, at these prices, I should buy 2 more and stash them in the side yard for later. Alas, the batteries are an expiring asset. 🙂


Z-index does not work like you think it does

When you start out in front-end development, you quickly discover z-index. Your intuitive understanding of it will be something like this:

  1. All elements have a default z-index of zero.
  2. Therefore, if I assign a higher number to a specific element, my element can “float” above the others.

This is true surprisingly often – like Newtonian physics. But it’s not the whole story.

The whole story involves stacking context. A woolly subject that you can dive into here.

Or, you can wait until you have z-index problems, then dive in. 😉

Just remember, z-index is more complex than it looks.