All posts by Andrew Arensburger

Soft Coding

Over at Worse Than Failure, Alex Papadimoulis has an article on soft coding. Hardcoding is when something is written in the code when it ought to be in a header constant or an external config file. Soft coding is the opposite, when something is put in a config file that really ought to be in the source. For instance, the number of days in a week isn’t likely to change any time soon, so you may as well just use “7” in your code. You might

#define DAYS_PER_WEEK 7
#define WEEKS_PER_YEAR 52
#define LOAN_DURATION DAYS_PER_WEEK * WEEKS_PER_YEAR

to make it clear what you’re calculating, but putting it in an external, user-configurable file is just absurd.

I’m guilty of softcoding, myself. In my experience, it comes from trying to be too generic. Code that’s too specific, too hardcoded, is hard to maintain and extend, so a good programmer will ask himself, “What requirements might change in the future? How should I write this so that when it changes, I can do it without too much pain?” This leads to things like declaring configuration constants at the top of a script, in a Makefile, or in a header file; or having the code read messages from an external file, rather than hardcoding them as strings.

But it’s also easy to overcompensate, and start making everything customizable, or overly generic. So it’s important to remember that at some point you have to actually make the code do something.

Captchas of the Future

Captchas are good at weeding out spam, because they rely on tasks that humans do well and computers don’t, and because spammers use bots.

But as spammers get more sophisticated, their tools will get better and better at reading letters and numbers, so we’ll need to use new types of problems to keep them out:

Max was born May 12, 1947. His son was born on Max’s 22nd birthday.
How old is Max’s son?

points out that this would also be a good way of keeping out the riff-raff, such as people who can’t write a sentence without doing violence to the English language:

Fill in the blanks:
the person keys I found?
Tell them I found keys over .

(Adjust for whatever language your site is in.)

Or people who just don’t belong on your site:

And since spammers now get email subject lines from news headlines, perhaps it’s time to turn the tables on them:

Complete this sentence:
was recently named in a government corruption scandal that has embroiled several high-ranking officials.

Okay, maybe not that last one: for a captcha to work, there have to be at least some wrong answers.

What’s A News Octet?

One of my peeves is the phrase “news byte”.

A “news bite”, I can understand: it’s a bite-sized, i.e., small piece of news; something that fits on a napkin.

But a “news byte”? What is that? A news item that can only take on one of 256 values and fits into a C char?

The same goes for “sound bite” and “sound byte”, by the way.

How to Move an Entire Gas Giant Planet

One of the advantages of working in academia is that there are often lectures on interesting topics. (Those of my friends who went drinking last night before heading out to the VNV Nation concert last night may not share my assessment, though.) Yesterday, I went to a talk by Doug Hamilton about the axial tilt of the planets, and in particular about Saturn’s 20-some degree tilt.

Read More

Kurt Is Up in Heaven now

For those who haven’t heard yet, Kurt Vonnegut has passed away. And so it goes.

So this might be a good time to repost his list of liberal crap he’ll never have to listen to again:

  • Give us this day our daily bread.
    Oh sure.
  • Forgive us our trespasses as we forgive those wh trespass against us.
    Nobody better trespass against me. I’ll tell you that.
  • Blessed are the meek.
  • Blessed are the merciful.
    You mean we can’t use torture?
  • Blessed are the peacemakers.
    Jane Fonda?
  • Love your enemies
    Arabs?
  • Ye cannot serve God and Mammon.
    The hell I can’t! Look at the Reverend Pat Robertson. And he is as happy as a pig in shit.

(See PZ’s explanation of the title of this post.)

Johnny Hart Has Passed Away

So says the Washington Post.

More Godless Numbers

Newsweek reports the results of a religious identification survey they recently conducted. The bits of interest to me are:

  • 91% of Americans “believe in God”.
  • 82% identify themselves as Christian.
  • 10% have “no religion”.
  • 6% “don’t believe in a God at all”.
  • 3% “self-identifies as atheist”

Read More

Too Much Packaging

I think I like the idea of a tax on packaging more and more. Not a punitive tax aimed at discouraging the activity altogether, like taxes on tobacco, but just enough to make people stop and think, “Do I actually need this particular bit of packaging?”

Read More

Two Aphorisms

Computer science is no more about computers than astronomy is about telescopes.
— Edsger Dijkstra

Math is no more about equations than music is about staves and sharps.
— me

Whith-arrrrrr Freedom of Religion?

The Asheville, NC Citizen-Times tells the tragic story of a High School student whose religion is being persecuted:

being kicked out of school for a day?

Bryan Killian doesn’t think that’s a fair reaction to his decision to come to North Buncombe High School wearing an eye patch and an inflatable cutlass.

“I feel like my First Amendment was violated,” Killian, 16, said. “Freedom of religion and freedom of expression. That’s what I tried to do, and I got shot down.”

Freedom of religion?

Yes, Killian says, his “pirate regalia” is part of his faith — the Church of the Flying Spaghetti Monster.

And as if that weren’t bad enough, even those who love him won’t support him:

Killian’s mother, Vanessa, agreed with the school’s decision despite sympathizing with her son.

“I think Bryan should be able to voice his opinion,” she said, “but he kind of got carried away.”