Why Ruby is a good language for DSLs

I’ve heard people say that Ruby is an excellent language to use for creating DSLs (domain specific languages, little custom languages written for a specific problem domain) but I never understood why. I don’t know Ruby, so it was hard for me to imagine. But I heard John Lam give a very clear explanation on the ALT.NET podcast. He said that since Ruby doesn’t require parentheses around function call arguments, you can make function names look like keywords. For example, you could write functions “skin” and “this” and make them look like keywords. The expression “skin this cat” is actually parsed as skin(this, cat) but the former can look more natural.

Another interesting quote from John Lam in that interview was “only a masochist would program office from C#.” He said that because of late binding, automating Microsoft Office is much easier from Ruby. The office object model was designed to be used from a language with late binding  (i.e. VB) and so Ruby is easier to use than C#.

Academic publications as spam

From an article by Luis von Ahn on academic publications:

… there is an insane number of papers written every year, the vast majority of which contribute very little (or not at all) to our collective knowledge. This is basically spam. In fact, for many papers (including some of my own), the actual idea of the paper could be stated in one paragraph, but somehow people manage to write 10 pages of it.

Evaluate people at their best or their worst?

Here are three ways to evaluate a person’s performance.

  1. How good are they at their worst?
  2. How good are they on average?
  3. How good are they at their best?

Schools use the first two criteria, but the market uses the third.

Schools evaluate people at their worst

Teachers average grades to come up with semester grades, and semester grades feed into a grade point average. So in some sense schools evaluate average performance.

But in more subtle ways schools evaluate students by how good they are at their worst. To graduate, your lowest course grade in all your required courses must be passing. Brilliant achievement in one area cannot compensate for a failing grade in another area, so in that sense grades aren’t really averaged. Your creative writing grades are excellent, Mr. Shakespeare, but we cannot let you graduate until you pass physics.

How do you get on the honor roll? Your lowest grade has to be above a certain level. Again, what matters is how good you are at your worst.

How do you get to be valedictorian? Be good enough at every class to get an A. You have to be pretty good at everything, but you don’t have to be truly exceptional at anything.

Schools encourage perfectionism, not excellence. They encourage people to avoid mistakes, not to be creative.

Markets evaluate people at their best

Markets often evaluate people and products at their best.

If you write 100 obscure novels and one best-seller, you’re a best-selling author. If you consistently write moderately popular novels, you’re not. If you write one really good novel, you might get a Nobel prize. Imagine the Nobel committee evaluating a writer saying “Yeah, these two novels were brilliant, world-changing. But he also wrote this one novel that was mediocre. Let’s give the prize to someone whose books are consistently pretty good.”

The Ford F150 did poorly in focus groups. The average rating wasn’t good. But the people who liked it really liked it. And the F150 went on to be the most popular truck in history. All that matters in business is people who like your product enough to buy it. You don’t make any money by being everyone’s second choice.

If a company has one product that is a runaway success, the company is a success. If it has two or three runaway successes, even better. But a company can produce a few dismal failures (think Microsoft Bob or the Apple Newton) and still do quite well if their flagship products succeed.The same is true of the people behind these products. Someone can make a successful career with one big win even if they have a number of failures.

We all want others to see the best in us. There are ethical and economic reasons to look for the best in others. But years of education can incline us to look for the worst in others and in ourselves.

Related posts

What is the shape of the Earth?

To first approximation, out planet is a sphere. But how accurate is that approximation? What’s a better approximation? How good is that? This post will answer these questions and some related questions.

How well does a sphere describe the Earth’s shape?

The Earth’s polar diameter is about 43 kilometers shorter than its equatorial diameter, a difference of about 0.3%.This is due to the equatorial bulge caused by the Earth’s rotation.

What’s a more accurate description of the Earth’s shape?

An oblate spheroid.

What is an oblate spheroid?

It’s the shape you get by spinning an ellipse around its minor axis. That says if you were to take a cross-section of the Earth containing the polar axis, the shape you get would be an ellipse. The polar axis would be the minor axis and the equatorial axis would be the major axis. But if you were to take a cross-section through the equator, or any plane parallel to the equator, you’d get a circle.

What is a prolate spheroid?

A prolate spheroid is what you get by spinning an ellipse around its major axis.

What is an ellipsoid?

An ellipsoid satisfies the following equation.

\left(\frac{x}{a}\right)^2 + \left(\frac{y}{b}\right)^2 + \left(\frac{z}{c}\right)^2 = 1

A sphere is an ellipsoid with a = b = c. An oblate spheroid is an ellipsoid with a = b > c. A prolate spheroid is an ellipsoid with a = b < c. A scalene ellipsoid is an ellipsoid for which a, b, and c are all distinct.

How good is the oblate spheroid model?

The error in approximating the Earth’s shape as an oblate spheroid is less than 100 meters, two orders of magnitude better than the spherical model.

How are other planets shaped?

The other planets in our solar system are also oblate spheroids with Saturn being the most oblate: the polar diameter of Saturn is about 10% shorter than its equatorial diameter.

More geodesy posts