Categories
Uncategorized

Good JavaScript Reading, Part 1: Eloquent JavaScript

eloquent javascript

If you decide to purchase only one JavaScript book, that book should be Marijn Haverbeke’s Eloquent JavaScript. There’s no greater recommendation than JavaScript creator Brendan Eich’s unsolicited review on Amazon:

A concise and balanced mix of principles and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript!

An equally important recommendation comes from Shopify’s JavaScript guru, Nick Small, who points anyone who wants to get good at JavaScript to Eloquent JavaScript. Nick’s working on a very interesting JavaScript project (which I’ll write about in a future article) and he’s forgotten more about JavaScript than I’m likely to learn, so I give his JavaScript-related suggestions a lot of credence.

We’ve got a number of dead-tree copies of Eloquent JavaScript floating around Shopify, so I thumbed through one a couple of evenings ago and bought my own shortly afterwards. It’s that well written; my reading that night sold me on the book. I was initially rolling my eyes when I saw the title of the first chapter – Values, Variables and Control Flow – but Haverbeke’s got a gift for presenting things that you’ve seen before, shining a new light on them from an odd angle and giving you a new way of looking at stuff that is so familiar that you hadn’t given it much thought until now. And he does so in an informative, entertaining way, as evidenced by this passage on how to think of variables:

You should imagine variables as tentacles, rather than boxes. They do not contain values; they grasp them – two variables can refer to the same value. Only the values that the program still has a hold on can be accessed by it. When you need to remember something, you grow a tentacle to hold on to it, or you reattach one of your existing tentacles to a new value.

Haverbeke introduces the right stuff at the right time. After the basics, he presents functions, data structures and then error handling, providing a solid base of knowledge for the reader. With those out of the way, he goes on to cover functional programming, then object-oriented programming (most people would do it the other way around, but if you’re not getting into functional programming with JavaScript as soon as possible, you’re missing out on a lot of the power), then modules. After that, there’s a solid chapter on regular expressions and the book closes with four chapters on the most likely application of JavaScript: web development, from the DOM to browser events to what we once used to refer to as “Ajax”. At a svelte 200-ish pages, Eloquent JavaScript covers a lot of ground in less space than many other, lesser books you’ll find cluttering the shelves at your local store.

The only way to truly learn a programming language is to take it for a spin and as Seth Godin likes to put it, “poke the box”. Haverbeke made learning JavaScript from Eloquent JavaScript easier by providing an interactive JavaScript environment. There, you can run any of the examples from the book, make changes to them and see what the results are, and you can even experiment with your own original code.

Eloquent JavaScript is that rare sort of book that works for the person who’s just started programming, the experienced programmer who’s getting started with JavaScript and even the experienced JavaScript programmer who wants to get it right. If you code in JavaScript, this should be on your bookshelf (or in your e-reader).

How to Get Eloquent JavaScript

From the publisher, No Starch Press: It’s available in a couple of forms…

  • “Dead-tree” (a.k.a. paper) plus free ebook version: US$29.95
  • Ebook version (includes PDF, mobi, and ePub): US$23.95

From Amazon: Available in these forms…

The old version (free!): The version of Eloquent JavaScript that I’m talking about in this article is the 2011 edition, which is published in paper book and ebook formats. The previous version of the book is available online in the following forms:

This article also appears in the Shopify Technology Blog.

Categories
Uncategorized

Salmagundi for May 31, 2011

salmagundi

A salmagundi (sometimes shortened to salmi) is a 17th-century English dish made of a mashup of ingredients. Every salmagundi I’ve ever seen has always included slices of hard-boiled egg, but beyond that, I’ve seen all manner of ingredients thrown in: roasted and smoked meat, fish and seafood, fruits and vegetables, nuts and flowers, and wildly different kinds of dressings and sauces. Nobody’s sure of the origin of the word, but it’s gotten around, from the French salmigondis, meaning “hodgepodge” and the Jamaican “Solomon Gundy”, a savoury spread made of herring.

little brother

In Cory Doctorow’s young adult novel Little Brother, the protagonist Marcus has a computer made up of a mishmash of parts that he calls “The Salmagundi”. I liked the name so much that I’ve decided to use it for posts that are a mishmash of stories, like this one.

Maple Butter / 5 Unconventional Ways to Entrepreneurship

Maple Butter is a new blog for entrepreneurs, and it’s worth checking out. Created by Dan Martell (creator of Flowtown), it describes itself as “a gut-spilling, F-bomb dropping, Woody-Allen-on-a-therapist’s-couch experience” where entrepreneurs and “wantrepreneurs” can get “useful advice that helps you turn traction into triumph”. I can get into that.

The latest article in Maple Butter is 5 Unconventional Ways to Entrepreneurship, a summary of Dan’s recent presentation at Big Omaha. He talks about about his presentation in the video above (taken from Beyond the Pedway), and those 5 unconventional ways are summarized below:

  1. Don’t listen to your parents (at least when it comes to entrepreneurship). Unless your parents are successful entrepreneurs, their advice is more than likely to be biased against entrepreneurship and favour erring on the side of risk avoidance.
  2. Embrace your (enlightened) laziness. Once again, this comes with a qualification: this means using your laziness to come up with an idea that saves people effort or makes their lives easier. It’s laziness as a virtue in the Larry Wall sense.
  3. Choose your friends carefully. Strangely enough, this sounds like advice from your parents, and in this case, you should listen to them. As the saying goes, you’re the average of the 5 people you spend the most time with, and if they’re not pushing, inspiring and challenging you, you’re not going to go far. (This is an observation I’ve made when looking at some over-educated, under-employed, ambition-lacking acquaintances. They are good music recommenders, though.)
  4. Hustle to help. You’ve probably heard this advice, whether you’ve heard the Beatles lyrics “The love you take is equal to the love you make” or read the book How to Make Luck (an underappreciated gem, in my opinion). I have personally experienced this: if you are known for helping others, others will come to your aid.
  5. Failure is part of the process. You learn best from mistakes, so make excellent ones! Make mistakes borne of effort and ambition, not laziness and fear.

Dan explains more in his article, so be sure to read it. And keep an eye on Maple Butter; it’s got a lot of promise.

Smashing Magazine’s Ten Oddities and Secrets About JavaScript

javascript

Ten Oddities and Secrets About JavaScript is a list of curiosities contained within the world’s most simultaneously misunderstood and useful programming languages. Read it and find out how null is an object but not an instance of one, the usefulness of the === operator, the power of regular expressions in JavaScript, fooling your functions into thinking that they’re running in a different scope and how undefined can be defined.

Jacques Matthiej’s Productivity Tips for the Easily Distracted

productivity tip 1

Jacques Matthiej is easily distracted, so he went all-out in his quest to become less so. He rearranged his work desk, created a new home office out of a trailer and got a new clock. What he did may be more extreme than what you want to do, but it works.

TechCrunch: Users Say They’re More Likely to Buy if a Business Answers Their Questions on Twitter

more likely to buy

The Twitter Q&A search engine service InboxQ conducted a survey of over 2000 young Twitter users and discovered that just shy of two-thirds of the respondents were more likely to buy from a business that answered their questions using Twitter. They’re also almost as likely to follow a business that answers their questions.

The moral of the story? If you’re serious about using social media to promote your company or be in better touch with your customers, make sure you answer your users’ questions!

The Matt Cutts Debunking Flowchart

matt cutts debunking flowchart

If you run a public-facing online business – say, a Shopify store – sooner or later, you’re going to have to deal with people saying crazy things about you. Matt Cutts, head of Google’s web spam team as well as its unofficial spokesmodel, does a lot of debunking of the many crazy things and accusations aimed at Google. The graph above, courtesy of Search Engine Land, shows how Matt handles them.

This flowchart is similar to the US Air Force’s rules of engagement flowchart, which I wrote about in Global Nerdy a couple of years back:

usaf blog rules of engagement

This article also appears in the Shopify Technology Blog.

Categories
Uncategorized

Ruby Foo

ruby foo

After three years away from all but the most trivial of noodling with the Ruby programming language, I have become a Ruby Foo (as in Mr. T’s catchphrase, “I pity the foo’!”). I am severely out of practice with Ruby, and with two versions having appeared since I last made a living with Rails, even the act of creating a new project is completely different. Since Ruby is the preferred back-end programming language at Shopify and I am the Platform Evangelist, it’s time for me to “sharpen the saw”.

obie

Luckily for me, I ran into Obie Fernandez at the South by Southwest Interactive conference back in March. We sat down for a coffee and he told me about what was happening with Hashrocket and I told him that I was a hair’s breadth away from joining Shopify.

“I’ve been away from Ruby long enough that I’m probably back at newbie level again,” I told Obie between sips of latte made with overcooked beans. “I did it for a bit at the beginning using IronRuby, but between doing all the C# and PHP and the open source ‘Iron’ languages dying of neglect at Microsoft, I’m severely out of practice. I thinking of joining Shopify, and let’s face it: I don’t want to look like an ignoramus in the presence of rock stars like Tobi, Cody and Edward.”

“Give me your email,” said Obie, “and I can do something to help.” Of course he could – he’s the series editor of Addison-Wesley’s Professional Ruby series of books.

Shortly after South by Southwest, a couple of links to PDF editions appeared in my inbox. Thanks, Obie!

eloquent ruby

The first link was to Eloquent Ruby, Russ Olsen’s guide to speaking idiomatic Ruby and getting the most out of the Ruby programming language. It’s a breezy read, written in the same conversational tone that Olsen used in Design Patterns in Ruby, and the book is broken down into 31 bite-size chapters about a dozen pages in length. Each chapter’s title is some principle for programming eloquent Ruby – the first few are “Write Code That Looks Like Ruby”, “Choose the Right Control Structure” and “Take Advantage of Ruby’s Smart Collections” – and each explains that principle, provides code, shows you where you can find the principles used in actual, working projects. The book straddles the line between tutorial and reference; it’s written in tutorial style, but it’s organized so well that it might as well be a reference for those parts of Ruby that you might not use often (but should) as well as for those parts you keep forgetting (in my case, I always end up having to look up metaprogramming). I’ve been going through it at about a chapter an evening, and I’ve been getting smarter each time. Whether you’re coming back to Ruby after a hiatus like I am or if you just simply want to get better at Ruby, you should have this book in your library.

If you’d like to know more about Eloquent Ruby and its author, Russ Olsen, check out this interview with him at InfoQ.

ruby on rails 3 tutorial

I have yet to properly sink my teeth into Ruby on Rails 3 Tutorial but a quick scan of the book has shown that it’s quite promising, and the Amazon reviews are bolstering my belief.

I’ll be writing from time to time about my return to Ruby and Rails in this “Ruby Foo” series of posts, and I hope that whether you’re new to the language, returning after a break like me or aiming for “guru” status, that you’ll check out this blog regularly for notes on my explorations and what I’ve learned.

This article also appears in the Shopify Technology blog.

Categories
Uncategorized

R2-Tea-2

R2 tea 2

As geeks, we never miss an opportunity to Star Wars-ify stuff at Shopify. Meet our kettle, R2-Tea-2.

This article also appears in the Shopify Technology blog.

Categories
Uncategorized

Notes from "How to Run a Startup Like Genghis Khan"

Genghis khan statue

Among the sessions that took place during the first time slot of BarCamp Portland was Kevin Hale’s How to Run a Startup Like Genghis Khan. As one of the guys behind the online form startup Wufoo (who were recently acquired by the online survey startup SurveyMonkey), Kevin’s been applying the principles inspired by one of history’s greatest — and feared — military commanders to great effect.

As is my habit, I took copious notes, after which I expanded and annotated them and which I now present below. Enjoy!

How To Run a Startup Like Genghis Khan

  • Genghis Khan made arrangements so that his death would be a mystery
  • He was buried in an unmarked grave
  • In order to preserve the mystery of his death, he had a squad kill the people who buried him when they had completed their task
  • And in order to be very thorough, he had another squad kill that first squad

  • Most of you are aware of Khan’s reputation: a ruthless killer and sire of many children across Asia
  • His story is a little more complex than that. What many people don’t know is that he was captured and made a slave when he was young, broke free and rose to unite the various confederations of mainland Asia and is considered to be one of history’s most charismatic and dynamic leaders
  • He is responsible for many developments in his part of the world, including opening trade routes, developing a system of writing and promoting religious tolerance across his empire
  • In the span of 25 years, his Mongol Empire conquered more land than the Roman Empire did in 400. He conquered more territory than anyone in history
  • With his forces comprising only 70,000 warriors, he took on and defeated armies that outnumbered him 3 to 1

  • Strangely enough, the things Khan did in order to achieve success are quite applicable to the startup world:
    • He did big things with small teams
    • He used combinations of technologies from different places
    • He was an excellent word-of-mouth marketer

  • Khan was a Mongol
  • "Mongol" was often used as a catch-all term for eastern people such as the Huns, Scythians and so on
  • These people were nomadic badasses
  • Their home was the Asian steppe: an unforgiving land with few trees and sparse resources
  • The Gobi Desert is immediately south, and huge mountainous regions to the north and west
  • The capital city, Ulan Bator, has the lowest average temperatures of any world capital
  • Being nomadic was a survival tactic in such climes

  • Consider the way they lived versus people who lived in cities, towns or villages:
Mongols "Townies"
Lifestyle Mobile Settled
Structures Tents Buildings
Tactics Offensive Defensive
Resource Management Resourceful Wasteful
Who Provided Food? Hunters Gatherers
What They Ate Protein Carbs

 

nomad vs sedentary

  • If you’re in a startup, you’re in a situation similar to the Mongols
  • You should borrow from their bag of tricks
  • It’s all about less, namely:
    • Less money
    • Fewer employees
    • A small office (or sometimes, no office at all)
    • Less hardware
    • Fewer features
    • Less code
  • Y Combinator-funded startups use a "less" philosophy: they fund small teams, give them just enough money to operate, and encourage them to be "ramen profitable".
  • Like Khan, startups should try to take advantage of efficiencies

Mongolian army

  • Khan had a relatively small force and did not like to sacrifice the lives of his men needlessly
  • He tried to beat his enemies before battle even begun — he gave top priority to defeating the will of the enemy
  • The goal was to get villages to surrender before his army set foot in them
  • Khan’s forces:
    • Devoted a lot of time to building word-of-mouth and spreading rumours of Khan’s impending attacks
    • Sent scouts to reconnoiter cities in order to find potential targets and make maps
    • Captured local scribes and put them to work writing propaganda: "Genghis Khan is coming!"
    • Would build a pile of skulls outside a city they were planning to attack
    • Would never attack a main stronghold first; instead he would first destroy their outposts
    • Captured the bright people from the outposts and let the others go free; those set free would run to another town or outpost, spreading word of Khan’ attacks and taxing their resources
    • Built fortifications around cities they were going to attack, followed by siege machines
    • Even participated in biowarfare, catapulting human heads and plague victims over city walls
  • On the day of battle, Khan’s forces would put on a big production prior to their attack:
    • They would gather outside the place they were attacking
    • Soldiers would carry multiple torches, making their numbers appear far greater
    • They would be accompanied by chanting priests, war drummers and Tuvan throat singers, who would create a lot of noise outside the target city for a long time to scare the citizens
    • After a long while, the priests, drummers and singers would stop suddenly and simultaneously
    • Shortly after the period of silence, which would be terrifying to the enemy, they would attack
  • Khan’s armies would use tactics suited to their numbers:
    • They would engage in heavy combat, and then retreat
    • The opposing army would follow them, not realizing them that he was luring them into being boxed in by the retreating force and another force lying in wait in a "kill zone"

mongolian army 2

  • Lessons to learn from Khan:
    • Build your audience and make them part of the extravaganza
    • 37signals built their audience with the Signal vs. Noise blog, which was founded in 2001
    • It wouldn’t be until 2004 that they released their product, BaseCamp
    • Gmail built their audience and demand by making the initial version a limited-invitation beta
    • Thanks to the scarcity, early GMail users became mini-celebrities
    • Wufoo did this by going with an unusual contest: "Win a friggin’ battle axe!"

Win a battle axe

  • In medieval warfare, armies were arranges like so:
    • Infantry in the front
    • Mounted calvalry in the middle
    • Archers in the back

    Voltron

  • This approach is an example of what I call the "Voltron Inefficiency", where every Voltron episode seems to follow the same pattern:
    • First, the five members of the Voltron team would try to take on the enemy in their individual lion ships, and lose
    • Then, they’d merge the lions ships together to form Voltron and still lose
    • Finally, they’d use the winning tactic: with Voltron formed, they’d pull out  the best weapon, the blazing sword and defeat the enemy
    • The inefficiency: why not just use the best of everything –  Voltron and the blazing sword — at the very beginning?
  • Khan’s forces didn’t fall victim to the Voltron inefficiency: they put the archers on horses, combining mounted cavalry and bowmen
  • Their horses were smaller and faster, and they wore lighter leather armor (less weight) and only on the front (less weight, and discourages retreat)
  • Compared to the English longbow, a large, cumbersome and simple bow, the Mongolian composite bow could be folded for travel, was light enough for even the smallest of women to use and had greater range

mongolian composite bow

  • The startup equivalent of this is to have everyone, regardless of title or position, take on customer-facing roles such as customer support, marketing and sales
  • They do this at Kayak.com, which brings up the question: "Why pay an engineer $150K to answer phones?"
  • The answer: if you do this, engineers will fix their code so that they don’t have to answer phones
    • If they hear the same complaint from many customers, they’ll fix that problem rather than have to hear that complaint again
  • This approach makes for developers and designers who become more responsible for the product
  • At Kayak, the average response time on business days is about 7 – 12 minutes
  • By putting developers on support, they end up building tools to help the support team scale

Genghis khan museum poster

  • Khan had his generals or sons marry people from the places he conquered
  • He did this to forge alliances and maintain long-term relationships with the nations under his rule
  • At Wufoo, we’re fanatical about creating and maintaining long-term relationships with our customers
  • Consider the work of John Gottman, who could look at couples fighting and predict with uncanny accuracy who would stick together and who would break up
  • Our relationship approach depends on the type of user:
    • With new users, it’s like dating
    • With longer-time users, it’s like marriage
  • There are fights in every relationship, whether within a couple or a relationship with a customer; the types of fights have analogues in both types of relationships:
Reason for fight
in a marriage
Customer analogue
Money Cost and billing
Kids Customer’s customers
Sex Performance
Time Performance

 

  • Customer relationships are important at Wufoo
  • We make every one of our employees say "Thank you" to our customers, with hand-written cards
  • Our users stay loyal, with a deep emotional connection to us

Mongolian bridge

  • The Mongols, being nomads, didn’t leave behind literature, art, buildings or cities
  • What they did leave behind were bridges, which were useful to them as a travelling people
  • These bridges benefited everyone else too: they even made the Silk Road possible
  • Wufoo also builds bridges by participating with the community around it

This article also appears in the Shopify Blog.

Categories
Uncategorized

X-Muppets

X muppets

A Muppet adaptation of the X-Men? I could get behind that. I can just imagine Miss Piggy as Emma Frost.

Kudos to Razzah for creating this (click the image to see the original).

This article also appears in The Adventures of Accordion Guy in the 21st Century.

Categories
Uncategorized

Going to Toronto for Ruby Job Fair and Portland for BarCamp

Airplane wing

Some of the Shopifolks are travelling this weekend to some interesting events.

rspec::table, a.k.a. The Ruby Job Fair (Friday, May 20th)

Rspectable employment

If you’re in the Toronto area and looking for a job, you might want to drop by rspec::table employment, otherwise known as the Ruby Job Fair. Our friends at Unspace are holding this event, where Rubyists seeking employment can meet with potential employers.

It’s the third such event put together by Unspace, and it’s specifically aimed at those programmers who’ve eschewed more mainstream programming languages and frameworks for the Ruby, Rails and other Ruby-related goodies because, let’s face it, they’re fun. And hey, we believe that if you’re going to spend your working life — half your waking existence — doing something, it had better be fun, don’t you think?

Have you considered developing for Shopify? Think of it: we’re growing start-up that’s actually profitable, and that was before we secured that Series A funding. We’re in the business of helping people sell stuff online, a field whose growth is strong and steady. We’ve got some killer coders in the shop; I feel like the dumbest guy in the room when I’m around them (I’m okay with that — it has its advantages). The perks of working here are great, from the people to the gear and welcome swag to the location — not some soul-draining industrial park, but in Ottawa’s ByWard Market: central, and the liveliest part of town.

If you’d like to get a job with us and in on some of this action, come on down to the Ruby Job Fair this Friday, May 20th at Unspace’s office (342 Queen Street West, Toronto, east of Spadina, above LuluLemon) from 5:30 p.m. to 7:00 p.m. and say hello to the Shopifolk who’ll be there: Brittany, Edward and Julie!

To find out more about the Ruby Job Fair and the after-party, visit the Ruby Job Fair site.

BarCamp Oregon (Friday, May 20th – Saturday, May 21st)

BarCamp Portland logo

Shopify is one of five startups that makes up the BarCamp Tour, a group helping sponsor BarCamps all over North America. Thus far, we’ve been to BarCamp Boston and MinneBar (a Minneapolis-based BarCamp serving all of the state of Minnesota). This weekend, we’ll be at the third BarCamp on the tour: Portland, Oregon, affectionately known to some as Portlandia:

BarCamp Portland is an unconference: a conference whose topics, sessions and schedules are determined by the attendees. On the start of the unconference day, people will propose session topics and set up a schedule, after which the unconferencing will begin. We’re expecting geeks of every sort to show up: not just the hackers, but artists, engineers, hobbyists, writers and poets, jokers and journalists, entrepreneurs, cooks and bakers, people who till the land or help neighbourhoods take shape, and anyone else who likes create.

Shopify, along with our partners on the BarCamp Tour — BatchBlueGrasshopperMailchimp and Wufoo — isn’t your typical event sponsor. Yes, we’re each throwing in money to help BarCamp organizers hold their events, but we’re also there at the conference, actively participating, joining in the discussions, providing food and drinks, and even helping carry stuff or clean up. We’re also there to promote our companies, but not in a hard-sell way — we’re there to meet people who want to use our software and services, have questions and get to know the creative, inventive, ambitious people who attend BarCamps!

I’ll be there, helping out, facilitating sessions, answering questions about Shopify and playing accordion (of course). If you see me, please say hi!

To find out more about BarCamp Portland, visit the BarCamp Portland site.

If you’re interested in finding out more about BarCamps, watch this video, taken at one of the first BarCamps in San Francisco:

This article also appears in the Shopify Blog.