Paul M. Jones

Don't listen to the crowd, they say "jump."

A New Book About The N+1 Problem, and an Update to MLAPHP

I’ll have a new book finished and ready for you soon: Solving the N+1 Problem in PHP. Although I have written and spoken about the N+1 problem several times over the past few years, this book is an extended disstertation on the topic.

Describing the N+1 problem is one thing, and talking about the solutions in the abstract yet another. But how to diagnose and discover the problem, as well as refactoring strategies to resolve N+1 problems in your codebase? Those are something else, and they are what the new book provides, similar to the strategies I presented in Modernizing Legacy Applications in PHP. At about 40 pages of narrative and code, in many ways the new N+1 book serves as a topic-specific add-on to MLAPHP.

Speaking of which, MLAPHP is getting an update! The update is nothing extensive, mostly typo fixes and a couple of added details, all from attentive and interested readers. Current owners will receive the update for free.

So when will they be completed? Monday. And there’s a special deal involved for the week they’re finished.

MLAPHP is just about a year old, so to celebrate this new book, if you purchase both MLAPHP and the N+1 book as a bundle next week, they will each be about 50% off. That’s a total of $23.99 $22.99 (suggested $39.99 $28.99) for both books, with a 45-day money-back guarantee backed by Leanpub.

After the sale week, they’ll go back to their normal prices, so this is your chance to get a bigger bang for your buck. Of course, the new N+1 book is only $5.99 (suggested $7.99), so it’s not exactly a bank-breaker in the first place.

More updates when the new book and the update are finalized!

UPDATE (Fri 20 Mar): The bundle is now available at https://leanpub.com/b/mlasn1php. Go get it while you can!


I'm not anti-intellectual; I'm anti-intelligentsia.

One kind of “anti-intellectualism” is opposition to “intellectuals” considered as an interest group or social class in the Marxian sense – what Russian writers called the intelligentsia. The only more specific term I can think of for this is anti-intelligentsianism, an ugly coinage which will have to do for the duration of this essay.

...

The intelligentsia has displayed a consistent political pattern over the last 150 years: believing in its own intellectual and moral superiority, it has sought a leading role in politics, promoting a vision of itself as benign philosopher-kings who can steer society to virtue, equality, and fulfillment.

The vehicles of this belief have been many. At its worst, it has led the intelligentsia to endorse and propagandize for totalizing systems like Communism, which the intelligentsia conceived could be guided to good ends in its use of power by – who else? – intellectuals. It is forgotten, but true, that before World War II many intellectuals were attracted to Fascism for the same reason. In this way much of the intelligentsia of the 20th century became accomplices in and apologists for the most hideous mass murders in human history.

Via The Varieties of Anti-Intellectualism, worth reading in its entirety. (it gives voice to part of what I mean when I say "It's not enough to be smart; you have to actually know things.")


Everything You Think You Know About The Crusades Is Wrong

It is generally thought that Christians attacked Muslims without provocation to seize their lands and forcibly convert them. The Crusaders were Europe’s lacklands and ne’er-do-wells, who marched against the infidels out of blind zealotry and a desire for booty and land. As such, the Crusades betrayed Christianity itself. They transformed “turn the other cheek” into “kill them all; God will know his own.”

Every word of this is wrong.

via Inventing the Crusades by Thomas F. Madden.


Bookdown: DocBook-Like HTML Output From Markdown

From bookdown.io:

Bookdown generates DocBook-like HTML output using Markdown and JSON files instead of XML.

Bookdown is especially well-suited for publishing project documentation to > GitHub Pages.

Features include:

  • Automatic table-of-contents generation as index pages at each hierarchy level

  • Custom index-page titles via JSON configuration

  • Automatic numbering of page headings

  • Automatic previous/next/up navigation headers and footers

  • Multi-page hierarchical output

  • Loading of remote content files via HTTP

  • Templated output for theming

  • Overridable page processing, especially for rendering

Bookdown can be used as a static site generator, or as a way to publish static pages as a subdirectory in an existing site.

Yes, I know, there’s a ton of static site generators for PHP out there already. Sculpin seems to be the big one (hi Beau!) but it’s not specifically for documentation. Then there’s Couscous (hi Matthieu!), which is for documentation, but it’s not DocBook-like documentation.

By “DocBook-like”, I mean (among other things) numbered headers, auto-generated tables-of-contents on their own pages, hierarchical multi-page presentation, and the next/previous/up linking at the top and bottom of pages. Look at the Solar documentation sites for a better idea; the content on those pages was generated with DocBook.

And frankly, look at the dependency listings on those two projects (Scuplin, Couscous). They’re rather extensive. It that a bad thing? No, but it’s not my speed. I think we we all know at this point that I’m about reducing dependencies as much as possible, and those are just too much for me.

Also: I can’t stand YAML. I don’t like YAML embedded in pages, and I don’t like YAML config files. I much prefer JSON, and I don’t want to add YAML frontmatter on Markdown pages.

So: Bookdown. This scratches my particular itch, with very few dependencies.

Bookdown, although it can be used as a site generator, is only incidentally a site generator. What it really is is a page generator, with the idea that you can integrate the pages into any other site you want.

Additionally, Bookdown allows you to pull content from remote locations. This is especially interesting to me because of the decoupled nature of Aura libraries. I would like very much to keep the manual documentation on each library in the same repo as that library, then publish each alone, and as part of a collection, without having to copy files around. Bookdown remote content should allow for that.

I’m happy with the architecture as well. It took two weekends of experimenting, and then almost exactly a week of dedicated development, to build Bookdown.

The library is fully separated from the project. That means you can either run it as a project on its own, or integrate the core library into your own project and glue its services and commands into your own work.

Everything uses dependency injection through an application-specific container which helps to keep the concerns well-separated. Everything uses factories and builders, which helps to enable the dependency injection.

All the underlying processes are decoupled from each other, which should make it easy to replace them with custom processes. For example, the ConversionProcess currently uses CommonMark, but I find it easy to imagine end-users replacing that with Textile, ReStructuredText, or even a combination of conversions that examines the filename extension.

Finally, the code style is a little bit of a departure for me as well. I have previously used $snake_case variables, but I tried on purpose to use $camelCase instead, and it was not a hard switch to make. Camel-case seems more popular these days, so I may bow to common convention from now on.

I really enjoyed putting this together. It’s something I’ve wanted to see in PHP land for a long time, and I finally got the opportunity and inclination. Take Bookdown out for a test drive, see how you like it, and please feel free to provide constructive feedback!



The Formula For Anti-Capitalist Concern-Trolling

Then economists ... commenced worrying about, to name a few of the pessimisms concerning “capitalism” they discerned: greed, alienation, racial impurity, workers’ lack of bargaining strength, workers’ bad taste in consumption, immigration of lesser breeds, monopoly, unemployment, business cycles, increasing returns, externalities, under-consumption, monopolistic competition, separation of ownership from control, lack of planning, post-War stagnation, investment spillovers, unbalanced growth, dual labor markets, capital insufficiency, peasant irrationality, capital-market imperfections, public choice, missing markets, informational asymmetry, third-world exploitation, advertising, regulatory capture, free riding, low-level traps, middle-level traps, path dependency, lack of competitiveness, consumerism, consumption externalities, irrationality, hyperbolic discounting, too big to fail, environmental degradation, underpaying of care, slower growth, and more.

... [The formula is this:] First, discover or rediscover a necessary condition for perfect competition or a perfect world (in Piketty’s case, for example, a more perfect equality of income).

Then assert without evidence but with suitable mathematical ornamentation that the condition might be imperfectly realized or the world might not develop in a perfect way.

Then conclude with a flourish that “capitalism” is doomed unless experts intervene with a sweet use of the monopoly of violence in government to implement anti-trust against malefactors of great wealth, or subsidies to diminishing-returns industries, or foreign aid to perfectly honest governments, or money for obviously infant industries, or the nudging of sadly childlike consumers, or, Piketty says, a tax on inequality-causing capital worldwide.

From McCloskey in a long, but inspired and genius, review of Piketty; lightly edited for brevity from the original at http://ejpe.org/pdf/7-2-art-4.pdf.

UPDATE (also lightly edited):

One begins to suspect that the typical leftist starts with a root conviction that capitalism is seriously defective. The conviction is acquired at age 16 when he discovers poverty but has no intellectual tools to understand its source.

Then the lifelong “good social democrat”, in order to support the now deep-rooted conviction, looks around when he has become a professional economist for any qualitative indication that in some imagined world the conviction would be true, without bothering to attach numbers drawn from our own world.

It is the utopianism of good-hearted leftward folk who say, “Surely this wretched society, in which some people are richer and more powerful than others, can be greatly improved. We can do much, much better!” The utopianism springs from the logic of stage theories, conceived in the eighteenth century as a tool with which to fight traditional society.



Conspicuous *Production*: "Sexy" Work, "Schlep" Work, Automation, and Artisans

People who seek sexy work are often members of what I called the Jeffersonian middle class in an earlier post -- motivated by creative self-expression and a sense of personal dignity rather than economic survival.

... Sexy work is attractive to those who like their social identity to be harmoniously integrated within itself (what your mom thinks of you and what your boss thinks of you are not in conflict) and with your private identity (you don’t feel misunderstood). There is consensual external validation of your internal sense of self-worth. You feel authentic.

Sexy work is easy to enjoy, learn, value and integrate into your identity, primarily because it is downhill psychological work: it is the cognitive equivalent of muscular atrophy. You have to choose to make it hard for yourself. You can cash out some status and attention even if you’re not making any money. It does not test your sense of self-worth significantly.

Schlep work has the opposite characteristics along all four vectors. It is harder to enjoy, learn, value and integrate into your identity, primarily because it is uphill psychological work for a social species. It is hard whether or not you want it to be. It is hard to cash out status and attention even if you’re making good money. It tests your sense of self-worth every day.

Somehow, over the past decade, we’ve gone from a useful heuristic (“focus on your strengths” and “find flow”) down a slippery slope of use-with-caution ideas (“work smart, not hard” and “follow your passion”) to the idea of work as a kind of consumption that should be chosen based on the pleasure one can derive from it.

Sexy/schleppy is to my mind, the most natural way to break down human preferences for work. They arise from fundamental desires and aversions. In choosing consumption behaviors or conspicuous production, we tend to feed desires and starve aversions. In schleppy work, we do the opposite: we defer gratification and accept, even seek out, a degree of pain based on the no-pain-no-gain heuristic. A little nudge from a plausible “play to your strengths” philosophy is enough for us to choose the easier way.

Unfortunately, the entire current conversation around work is confused because we prefer a less meaningful distinction, creative vs. uncreative.

Via You Are Not an Artisan.


Burning Responses

Imagine a hypothetical YouTube where the videographer burns a Koran and urinates on the ashes. We in the modern West consider this kind of thing an act of free speech.

Would that act be offensive to Muslims? Absolutely. It be offensive to Jews if it were a Torah. It would be offensive to Christians if it were a Bible. It would be offensive to United States patriots if it were the Constitution.

Do Jews, Christians, or United States patriots use that kind of speech as a pretext to riot or murder? If so, would their violence be met with sympathy from the West? No, no, and no. Burning a Koran, and reactions thereto, should be no different.

But here's the thing: you feel *safe* when you criticize Jews, Christians, and United States patriots, because you know they don't consider it acceptable to do violence in response to offensive speech. You *don't* feel safe when it comes to Muslims, because you know there is a non-trivial number of them who *do* consider it acceptable, even a requirement, to do violence in response to offensive speech.

The vast majority of Muslims reading this are civilized, and recognize that violence is not a civilized response to offensive speech. But there are some Muslims, and their sympathizers, who believe that offensive speech must be answered with violence, and who will use offensive speech as a pretext for riot and murder. The behavior is uncivilized, premodern, and barbaric, and should be recognized as such.


Cafe Coca and Snake Eyes

Cafe Coca from De-Phazz (YouTube) samples some movie lines at about the 2:00 mark:

And in the end we'll meet in one of the seven circles.
And I'll be there for not doing what I could to help you.
And you'll be there for doing what you could to stop me.
You'll blow my brains out.

It always stuck with me, and after some searching it appears to come from a 1993 movie called "Dangerous Game" or "Snake Eyes." Google revealed it from Subzin.


The Varieties of Scientific Experience

I liked this mostly because it exposes a lot of "fans of science" as mostly tribal, not as actual adherents to a methodology or approach. The varieties are:

- Science as Method

- Science as Production and Stewardship

- Science as Authority

- Science as Belonging

- Science as “Progress”

- Science as Aesthetic

- Science as Dispassionate Sensibility

- Science as Nihilism

- Non-Experience of Science

Via The Varieties of Scientific Experience.