Chad Perrin: SOB

31 December 2007

thinking in FP or OOP syntax

Filed under: Geek — apotheon @ 03:00

Bear with me. I’m sure most of my readers know most, if not all, of the following explanation.

We (where “we” means “programmers”, “mathematicians”, and even “people who have been in third grade”) should all be familiar with infix syntax. That’s where you divide 10 by 2 with this syntax:

10 / 2

That’s common to many C-like programming languages such as Perl, Java, and C itself, when using arithmetic operators. It’s not so common to languages like Lisp, of course — and even in C-like languages, it tends to be limited to special (if common) cases, like arithmetic. C and Perl tend to use functional syntax for everything else — even when doing object-oriented things in Perl. In Lisp, it would look like this:

(divide 10 2)

That’s not how most languages employ functional syntax, of course. Most of them do something a bit more like the way functions tend to look in pure mathematics:


One might also call this prefix syntax. Of course, in C and Perl, division (an arithmetic operation) uses infix notation (what C and Perl use for arithmetic operations). Much of the rest of the language uses the above sort of syntax, however — and one could easily define a divide function like the above:

#/usr/bin/env perl

sub divide {
  ($dividend, $divisor) = @_;
  $dividend / $divisor;


There’s also postfix functional syntax, of course. Division with such a syntax might look something like this:

10 2 /

. . . but that’s not really relevant. It wasn’t until I started playing with Lisp-like languages (again) that I really grokked the value of a prefix/functional syntax for arithmetic. I began refamiliarizing myself with Logo, via UCBLogo — a Logo that supports macros at least somewhat like those of Lisp, and uses an M-expression functional syntax (that is, a syntax that doesn’t require the “fingernail clippings” of Common Lisp). In Logo, division looks like this:

quotient 10 2

One of the great things about prefix (and postfix) notation for arithmetic is that it makes all the problems of precedence common to grade school arithmetic and many programming languages irrelevant. Arithmetic operations are organized hierarchically rather than linearly, which means that multiple operation dependencies for a single operation can be handled without specific grouping characters and messy precedence rules.

There’s another syntactic form that interests me right now: object oriented syntax. It varies somewhat in its appearance depending on the implementation language, of course. In Ruby, it looks like this:


I got to thinking about all this when I saw someone post something on the ruby-talk mailing list that used a method invoked thusly:


What struck me about this is that, for the first time since re-encountering Logo and learning to love prefix arithmetic notation, that looked wrong to me. I actually found myself wanting to rewrite the method so that it worked like this:


The object oriented arithmetic notation has insinuated itself into my preferences somehow. It hasn’t truly supplanted prefix notation. For one thing, this object oriented syntax is an odd mix of prefix and postfix notational syntaxes. It provides many of the same benefits of either of them — but it is tailored more specifically to an object oriented programming style (obviously).

Rather than having an operator that operates on the arguments on either side of it, or an operator that operates on the following (or preceding) operators, it is instead an operator used by the object before it to operate on the argument following it. If you don’t understand how that’s beneficial, it probably means you haven’t really grokked object oriented programming fully.

I understood all that for years, but it’s only now that it has come to feel as familiar and natural to me as prefix notation for arithmetic operations. I guess one could say I’m thinking in OOP syntax just as easily as in functional programming syntax.

30 December 2007

instameme: policy uncertainty

Filed under: Cognition,Liberty — apotheon @ 09:10

Over at Marginal Revolution, the inimitable Tyler Cowen “praises” uncertainty — or, less ironically, discusses policy of areas of particular uncertainty for him. Coincidentally, I had a rare moment of uncertainty on some very fundamental policy issues this weekend in conversation with Ogre.

Keep in mind, as you read this, that when I speak of certainty and uncertainty, I speak in relative terms. On one hand, all of it is uncertain to some degree, as I am always open to someone bringing up an argument I hadn’t considered before and allowing myself to be swayed to the extent that argument makes sense. On the other hand, I am generally very certain of my position on various policy issues (at least relative to the mainstream), with very rare exceptions. It usually takes one of two types of person to actually catch me in a moment of uncertainty on a policy issue:

  1. someone whose views are close enough to mine that the points of uncertainty are more likely to come up in discussion
  2. someone quite intelligent who thinks deeply about policy issues, getting down to the principles that underlie them as well as the superficial matters that occupy most people, quite often

Ogre is both of these — as is, for another example, Ratha (whose website seems to have vanished as of this writing), who questioned the foundations of my thoughts on copyright law, an act that ultimately led to those views changing drastically to what they are now.

The policy issue that came up, and for which I’ve harbored some uncertainty for quite a while, is that of national defense.

  1. I’m not entirely convinced that centralized management of national defense is necessary, in and of itself.
  2. I’m of the opinion that a constitutional minimal government (far less extensive, and far more restricted, than provided for by the founding of the US of A) can both be ethically constituted and more effective in the long run as a means of safeguarding personal liberties than anarchotopia.
  3. In the presence of a state of any size, it seems extremely difficult to come up with a workable scenario for national defense that does not involve some central management of national defense.
  4. While government can pay for itself without imposing coercive appropriation (taxes) on the citizenry (thus the ability of a constitutional minimal government to be ethically constituted), adding central management of national defense to the mix begins to make that task look difficult.

In high school, I was a (somewhat naive, in many respects) proponent of Ancapistan — of an anarcho-capitalist non-state as the only ethical basis for society. I don’t mean that anarcho-capitalism is necessarily naive; instead, I mean that the manner in which I arrived at that belief was somewhat naive. I have since then become a libertarian minarchist (in other words, someone who believes the only ethical government is one that is truly minimal within the restrictions of a need for an instituted protection of individual liberties).

My libertarian minarchism is grounded in a number of observations. A few are:

  1. Whatever the general run of an-caps say, there is not a necessary monopoly on force in a single body for the existence of a state. Force can be employed by anyone (ethically) under an ethical state. The state would simply exist as an additional, intentionally enduring repository and employer of force — more of a mediator with an enforcement arm than a social authority. Indeed, for a state to be ethical, it cannot monopolize force — as the United States did not for quite a few years back in the early days (though it had its unethical issues nonetheless).
  2. Nature abhors a vacuum. I hope the manner in which this is applicable here is blindingly obvious.
  3. Economic management is not the same as protection of rights even as they pertain to the market economy. One can enforce rules against fraud without imposing prior restraint on businesses in a misguided attempt to forestall fraud.
  4. A system of jurisprudence is only ethical if it takes as its first mandate “First, do no harm,” and as its second that only by guilt of violating rights (through intent or willful negligence) do someone’s rights become subject to restriction in pursuit of protecting liberty (as such acts imply a willful abdication of rights). This is, I believe, achievable via constitutional restriction of a governmental organization, but not so much through the “private security firms” model popular among an-caps — for reasons of longevity, variability of business climate, and intrinsic goals of differing policy environments. Any private security firm that achieves sufficient constitutional limitation to serve the same purpose becomes a state, after all — as does one that otherwise insinuates itself into a position of corporate longevity, though “otherwise” implies that it would not be so benevolent as the constitutional state I describe.
  5. If nothing else, before Ancapistan can ever be viable, I think the Minarchist States of Libertopia would at minimum have to serve an extended term as a stepping-stone.

Despite all this, discussion with Ogre about the (lack of) necessity of a centralized organization of national defense has me revisiting the issue of whether I should, in the future, continue to consider myself a libertarian minarchist, or instead return to anarcho-capitalist sentiments (far better informed and more well-thought-out this time) of old. It’s going to require some consideration in the near future, and may not be fully concluded in the foreseeable future. While national defense issues prompted this, an additional reason for the continuing thought on the matter is that of what exactly differs between the Minarchist States of Libertopia and Ancapistan. All things considered, the difference seems to consist only of a distinction in longevity — and that is not between “fleeting” and “permanent”, but between “slightly less permanent” and “slightly less fleeting”, if you get my drift. As long as things erode, there arise downsides to greater longevity as well as upsides: thus my uncertainty.

I’d love to see this spread to other weblogs, and prompt a widely distributed increase in the honest discussion of what we do and do not know about our own dearly-held principles for public policy. So . . . tell the world:

What are your policy uncertainties?

Coyote Blog reports: Arizona Business Death Penalty Enacted

Filed under: inanity,Liberty — apotheon @ 08:23

Apparently, Arizona legislators think the employment rate in that state is too high. After all, it has just passed legislation that makes it far more difficult to hire people — to the extent that at minimum, most businesses will try to cut down on their workforces. In many cases, where such is possible, they’ll move out of the state or (if multi-state) simply close up shop on their Arizona offices. In other cases, they may simply go out of business.

If it was an effective law, one could at least excuse the legislators as being misguided — but it’s not. In fact, it’s self-contradictory. Imagine trying to run a business where you are required to check up on the citizenship of all employees current and future, and at the same time it is illegal to check up on the citizenship of current employees. Furthermore, it’s illegal to check up on citizenship of prospective employees until within three days of hiring (before or after, I think) — which means that only after the costs of interviewing, telling other candidates that might be good choices to go home, and so on, you may then find out that your top pick cannot be hired.

Arizona: the state of “damned if you do, damned if you don’t,” apparently. If you’re an entrepreneur thinking about moving to Arizona, just don’t.

You probably don’t want to go to Massachusetts (aka Mordor), either.

Older Posts »

All original content Copyright Chad Perrin: Distributed under the terms of the Open Works License