epiphanies

81 posts under this tag.

Star
HyperScript 2
0
0
7
Jul
06

A 16-line hack to make the JS DOM API a tad more humane.


...absolutely amazing. I’ve yet to find a smaller and yet more astounding example of how you can encapsulate functionality within JavaScript and create brand new APIs on the fly.


Web pages are written in HTMLWP but as they have become more and more complex, they now tend to be written, clientside, through JavascriptWP, which can manipulate and insert HTML. Google Images, for instance, uses Javascript to write the HTML that displays your image results.

Yes, it’s roundabout, but it’s due to the nature of the languages: Javascript does stuff, HTML displays stuff. When you want the browser to do things (instead of merely displaying dumbly what it receives) and when these things themselves involve a lot of displaying, you end up writing HTML through Javascript.

It’s a little like writing French through English (André went to Marie and said: ”Bonjour! Ça va, ma chérie?”) and just as frustrating, particularly because you sometimes have to narrate whole scenes in French (pidgin tends to be painfully verbose) and your English self is left completely in the dark—so you end up naming things in both French and English and it gets as ugly as you can imagine.

HyperScript is a bizarre and quixotic attempt to write French in English; that is, HTML in Javascript. Basically, you do what went on in the Norman conquest of EnglandWP: you anglicize as many French words as you can; that is, you turn into Javascript as many HTML words as you can.

The lark itself takes gratefully (and rather surpisingly) only 16 paltry lines of Javascript code (highlighting thanks to Mark “Tarquin” Wilton-Jones.):


function each(a, f) { for(var i=0, l=a.length; i<l; i++) f(a[i]) };
each('a big blockquote br b center code div em form h1 h2 h3 h4 h5 h6 hr img iframe input i li ol option pre p script select small span strong style sub sup table tbody td textarea tr ul u'.split(' '),
    function(label){
        window[label]=function(){
            var tag=document.createElement(label);
            each(arguments, function(arg){
                if(arg.nodeType) tag.appendChild(arg);
else if(typeof arg=='string' || typeof arg=='number') tag.innerHTML+=arg;
else for(var attr in arg){
if(attr=='style') for(var sty in arg[attr]) tag[attr][sty]=arg[attr][sty];
else tag[attr]=arg[attr];
};
            });
            return tag;
        };
    });


and you can play with it right here, right now:




Test Area:

The translation between HTML and Hyperscript is straightforward, where you would have written
<b>Hello world!</b>,
you now write,

b(‘Hello World!’).

Instead of

<em style=”background-color:yellow”>Hello world!</em>,

now it’s,

em({style:{backgroundColor:’yellow’}},’Hello World!’).

And so on.

HTML in a Javascript syntax. Enjoy!

You move on 2
0
0
7
Jul
05

Fascinating Economist article on the music industry’s new developments. Very reminiscent of Dyson’s thoughts on intellectual property:

“[...it] is dead; long live intellectual process. Long live service; long live performance.”
and anime’s general stance towards piracy:
“If it succeeds, milk it; if not, try something different. And if the fans are into file sharing (which they are), keep the lawyers leashed and find a way to make piracy work for you.”

Seven years ago musicians derived two-thirds of their income, via record labels, from pre-recorded music, with the other one-third coming from concert tours, merchandise and endorsements, according to the Music Managers Forum, a trade group in London. But today those proportions have been reversed—cutting the labels off from the industry’s biggest and fastest-growing sources of revenue. Concert-ticket sales in North America alone increased from $1.7 billion in 2000 to over $3.1 billion last year, according to Pollstar, a trade magazine.

Frustrated record companies have responded by trying to get their artists to spend more time promoting records and less time touring and endorsing products, says Jeanne Meyer of EMI, another big record label. “Sometimes you’ve got a tug of war going on,” she says. Yet the more labels spend on marketing pre-recorded music, the more they raise their artists’ profiles and boost their other, more lucrative, sources of income. Pre-recorded music, no longer the main cash cow, increasingly serves merely as a marketing tool for T-shirts and concert tickets. The best seats for The Police’s world tour this summer cost over $900; the group’s entire catalogue on CD costs less than $100.

The shift away from recorded music is due in part to the recognition that touring and merchandise are more lucrative. But it may also be a consequence of internet piracy, as free downloads give music fans more money to spend on other things. Jwana Godinho, the director of Música no Coração, a concert promoter in Lisbon, thinks many music lovers have a “mental budget” that they are prepared to spend on music, and have switched their spending from CDs to tickets and merchandise.

The logical conclusion is for artists to give away their music as a promotional tool. Some are doing just that. This week Prince announced that his new album, “Planet Earth”, will be given away in Britain for free with the Mail on Sunday, a national newspaper, on July 15th. (For years Prince has made far more money from live performances than from album sales; he was the industry’s top earner in 2004.) Outraged British music retailers were quick to condemn the idea. As far as the record industry is concerned, it is madness. But for the music industry, it could well be the shape of things to come.

The Economist, A change of tune

I’ve always hated, with a passion, moral-indignation ads against piracy—not only because they’re manipulative but because they’re stupid. And the best defense for piracy may be how hard it is to make an argument against it that doesn’t stink of moral indignation—if maudlin pleas are the best you can do, you’re probably rotten. (On a related sidenote, I found it mighty interesting when The Economist circuitously referred to Kazaa as “a file-sharing program that was widely used to download music without paying for it”—as much as ads want to make us believe pirating is stealing, there are crucial differences, which is why such circumlocutions are essential.)

To solve intellectual property’s malaise I’ve long sought for grand economic solutions (new innovative schemes or perhaps even a new concept of property rights) rather than grand political ones (which are just, ugh, imposed moral rules). While there has been plenty of both, I’m starting to see these days that maybe the solution will be simply to move on. Piracy is just another (admittedly extreme) form of commodificationWP. You don’t fight commodification by outlawing it, you take the next thing that hasn’t been commodified yet, you offer value however you can, you move on.

Star
I know why manga are so good 2
0
0
7
Jun
20

It’s because they’re so bad.

Some days ago I bought my first mangaWP on a whim (Kare KanoWP, IH and FurubaWP, IH). I couldn’t believe my eyes reading them. They were so bad, so unlike any other comic I had seen.

They were black and white, with extremely simple, sketchy, cartoonish drawing—much of it seemingly left undone, symbols almost. Text was everywhere, sometimes in sketchy balloons, often not, often pointing (pointing!) cutely at things in tiny, jokey blurbs. Personal, painfully amateurish messages from the author were interspersed along the text (“As I’m writing this, I’ve been cutting my hand on the paper a lot.”). There were patterns instead of scenery, when there was any scenery at all. Long shots took entire panels, empty and mood-setting. Panels felt like paragraphs instead of pigeonholes and drawings flowed in and out of them, below and atop. By far, most panels were filled with people interacting, their faces and expressions. Closeups were everywhere. Everything was just so loose, so personal, so free, so bad.

Cryptoanarchy is the shit 2
0
0
7
Apr
25

Never had the bug bit me before—always thinking crypto-anarchismWP a hangover from the cyberpunky 80s. It isn’t. It’s pure magic. And it may be anarchy’s best hope—ever.

Timothy C. May’sWP long, superb essay, True Nyms and Crypto Anarchy (which appears in an essay collectionAM around Vernor Vinge’s True Names novel) has made a wild-eyed believer out of me. Fascinating stuff, this. (May, btw, is a former chief scientist at Intel, confirming my hypothesis that the people at the trenches of the Moore revolution had to be among humanity’s very best.)

Crypto anarchy is the cyber spatial realization of anarcho-capitalism, transcending national boundaries and freeing individuals to consensually make the economic arrangements they wish to make..

[It] ensures that men with guns cannot be brought in to interfere with mutually agreed-upon transactions, the only kind of economics interaction possible in crypto anarchy. Some people will of course scream “Unfair!” and demand government intervention, which is why strong cryptography will probably be opposed by the masses, unless of course, they are wise and take the long view. This may smack of elitism, but I have very little faith in democracy. De Tocqueville warned in 1840 that, roughly translated, “The American Republic will endure, until politicians realize they can bribe the people with their own money.” We reached that point several decades ago..

To put it bluntly, crypto anarchy basically undermines democracy: it removes behaviors and transactions from the purview of the mob. And once crypto is deeply entwined into the fabric of life and commerce, it will be too late to pull the plug.

Timothy C. May, True Nyms and Crypto Anarchy

Never had I been more than casually interested in cryptography. Now my copy of Schneier’s Applied Cryptograpy is on its way. Can’t wait.

3 legs 2
0
0
7
Apr
22

Of course! A 3-legged table wouldn’t wobble! Why? Any three points define a plane. Why did I never think of that?

So you’ve purchased your coffee and chosen to sit at one of those round outdoor tables. As you lean on the table to write comments on a paper, it rocks annoyingly, possibly spilling some of your coffee. You try moving the table slightly on the uneven pavement, hoping to stumble into a stable configuration for its four feet, but several attempts fail. Eventually you resort to shimming one of the table feet with a piece of folded up paper, or a stack of sweetener packets, and this creates at least a metastable condition. Looking around, you notice that many other tables have similar combat repairs, so that the cafe looks like a furniture trauma ward.

Why don’t these tables have three legs instead of four? With three legs, they wouldn’t rock on uneven surfaces because any three points define a plane. You wouldn’t need those adjustable table feet that no one ever bothers to adjust because it’s so awkward to lean down and twist them. While each leg would have to be slightly bigger, you’d have fewer assembly or machining steps to perform. Is a 60 degree angle that hard to produce in this day and age?

Steven Postrel, Design Puzzles

World of constraints, world of choices 2
0
0
7
Mar
21

Ultimately, the debate about choice is not about markets but about character. Liberty and responsibility really do go together; it’s not just a platitude. The more freedom we have to control our lives, the more responsibility we have for how they turn out. In a world of constraints, learning to be happy with what you’re given is a virtue. In a world of choices, virtue comes from learning to make commitments without regrets. And commitment, in turn, requires self-confidence and self-knowledge.
Virginia Postrel, Consumer Vertigo

Bloody good quote.

Star
Economic Self-sufficiency 2
0
0
7
Mar
20

The other day dad told me he considered Mexico’s relative economic self-sufficiency—that if we had to, we could, more or less, feed ourselves and scrape some living with only our national resources—one of our greatest strengths. I didn’t buy it. At all. Self-sufficiency seems to me a much overrated, much idealized kind of economic independence.

guava

I’m not self-sufficient, neither is my father, and I’m willing to bet that if you’re reading this, neither are you. Neither is anyone that lives in a city. The only truly self-sufficient people left in Mexico (and in the world)—indians who mostly grow and tend their own food, weave their clothing, and build their huts—live in what we call extreme poverty. Not all poor people are self-sufficient but all self-sufficient people are poor. The more self-sufficient the poorer. The more self-sufficient the more bounded to their own meager abilities, to their own fragile circumstances, to the weather (now when’s the last time you worried about it?).

Rather than its opposite, competition is cooperation’s complement.

We, the codependent, have made a different bargain with the world. We betted on specialization and cooperation, and I stand by that decision. It has given us far more wealth and independence than our forebears dreamt of. I don’t think you wake up at night scared of how much the butcher has over you because the only thing you know how to do is sing. Modern cooperation is breathtaking, isn’t it? This MacBook from which I write you, this computer in which you’re reading me—they required the work and talent of thousands of people around the globe.

All this begs the question: Why? What ties these invisible threads of people around the world into building the things you need? Why don’t you fear your butcher will extort you? Why are we all so reckless as to depend on each other for our very sustenance? The answer is trade and competition. Trade is simply the name we’ve given to peaceful cooperation and is the fiber that binds the world. On the other hand, competition, as much as it’s been demonized, is simply the prerequisite of cooperation—rather than being cooperation’s opposite, it is its complement. You don’t fear your butcher because you can always go to another one (or become one!)—it’s as simple as that. Cooperation without competition is indeed the fragile, vulnerable dependence most people rightly fear. Cooperation and competition—free trade, that is—is the resilient, magic codependence to which we owe our wealth and our freedom. (Think about it the next time you hear of a trade barrier of any kind, realize how it ultimately makes you more dependent, more subject to the whims of the special interests pandered.)

So no, I don’t think our relative national self-sufficiency is anything to be particularly proud of. It’s a blessing that we live in such a fertile, bountiful land. If we turn it into an excuse for isolation it’ll be our curse.

Courage 2
0
0
7
Mar
19

What is courage? Courage is what it takes to overcome fearELZR.

By describing how my own failures of courage feel to me, I hope to help you recognize such failures in yourselves. I seek to encourage you. I mean that literally. I seek to extend your courage by making you aware of your need for it and by describing some symptoms of its failure. I will offer some ways to reduce your need for courage, to marshal what courage you can muster, and to husband your store of it.

Ivan SutherlandWP, Technology and Courage

I don’t even remember how it was that last Thursday morning I ended up reading Sutherland’s classic article. But I’m glad I did. It was exactly what I needed. Thank you Mr Sutherland.

Star
Why read The Economist 2
0
0
7
Mar
16

Here 2 examples—a graph and a paragraph—from a typical article (about the paper industry’s dire prospects, of all things) in this week’s edition of The Economist.

Restructuring in the paper industry is proceeding at a furious pace. The first thing some paper companies have jettisoned is ownership of forests. International Paper (IP), one of the world’s biggest pulp-and-paper companies which is based in Tennessee, used to be the largest private landowner in America. A year ago the company sold 5.7m acres, or 90%, of its forestland—an area larger than Massachusetts. The $6.6 billion sale was “probably the hardest decision that I’ve had to make since I became CEO,” says John Faraci, IP’s boss since 2003. Most buyers were financial investors, but 5% of the land went to conservation groups.

The Economist, Flat prospects, Mar 15th 2007

Starting with the graph: it’s a 16-year window to worldwide newsprint production that drives home the article’s main point with eloquence: North America’s newsprint production (a fifth, you will notice, of the world’s; used to be a fourth) is slowly but decisively dwindling; production in the rest of the world, on the other hand, is increasing, albeit not in a hurry.

It’s full of conventions too, but they’re so well thought that you never need to be consciously aware of them as a reader: Take the upper-left red patch, a gentle way to guide your eyes to the graph’s title and instructions. The source always goes at the bottom, smaller-typed, and the y-axis is always labeled at the right, which I find more natural than the common left convention (it makes you look at the graph first, notice its pattern). The x-axis is usually the time axis, its gridlines usually obviated for clarity’s sake, and its labels, usually years, presented in a simple format that marks millennia only when needed. And graphs are always in this blue scheme—a convention to avoid color misinformation that still allows for meaningful distinctions between color shades: darker blue for the main variable under discussion, the foreground; lighter, fading blue(s) for the background variable(s).

As for the paragraph, it’s brimming with fascinating facts about the world. Did you know who the world’ biggest pulp-an-paper company was and that it was located in Tennessee (WP)—of all places? Did you know it also happened to be the largest private landowner in America? (A paper company! The largest private landowner in America!) Did you know it recently sold, because of restructuring, 90% of its forestland, 5.7m acres—an area larger than Massachusetts? Did you know it sold them for $6.6 billions? (Surprisingly cheap, considering it’s an area big enough for many a country.) Did you know most buyers were financial investors but 5% were conservation groups? (A wonderful example of how trade allocates resources, peacefully and quietly, to those who care about them.) Now you know.

Back and Forth: the endlessly recursive joke 2
0
0
7
Mar
10

A: “We will embarrass our descendants, just as our ancestors embarrass us. This is moral progress.”
B: “That’s only a superficial view, eventually we’ll come to recognize how wise our ancestors truly were.”
A: “As I was saying, I’ll embarrass you.”
B: “Oh you’re right, you were right all along!”
A: “But then that means you‘re right! Now I can’t believe the things I said!”
B: “Don’t worry, that is moral progress.”
.
.
.

My first (self-)published joke. They should lock me.