Category: C

American != English

May 18th, 2010 — 2:29pm

Computer languages are specific ways of speaking that rely more heavily on process than content. And at this time, all major computer languages are dialects of English. But there are interesting cultural differences encoded into the structure of the different languages. I would say, to be even more specific, that most computer languages are dialects of American English and that some of our national personality comes through in the grammar and syntax.

The equals sign is a good example, as it has a unique meaning in languages like ObjectiveC. When you say ‘if (self = [super init])’ you aren’t really asking a question. This is exactly the same sort of question as “Could you pass the butter?” You know for a fact that the person you’re talking to can almost certainly pass the butter and you are actually requesting that he or she do it; right now. It’s a polite command. The equals sign is like that. In C, ‘=’ is used to make something become something else. If you are actually making an inquiry you have to repeat yourself like this “==”. All of which is second nature to the programmer, but programmers tend to be socially awkward, so the differences between commands, requests, and inquiries may not be particularly noticeable to them.

‘if (self = [super init])’ means, “You should initialize yourself right now. And if you can do that, I want you to continue with the rest of my request…”

Americans drape their orders in layers of false politeness, and their computer programs do the same.

Comment » | C, language

Surrealism meets Objective C

May 3rd, 2010 — 6:31pm


– (BOOL) isEqualToString: (NSString *) aString;


NSString *this1 = @”a pipe”;

NSString *this2;

this2 = [NNString stringWithFormat: @”a pipe”];

if (this1 == this2) {

NSLog (@”This is a pipe”);


else {

NSLog (@”This is not a pipe”);


The string ‘this1’ is “a pipe” and string ‘this2’ is also “a pipe”. And yet, when you compare the two you get the result string: “this is not a pipe.”  The reason is because ‘this1’ and ‘this2’ are not actually strings but pointers to strings. ‘This1’ is just a number that directs the program to the space in memory where the string “this is a pipe” resides.  Because you are comparing two pointers, which are pointing to different areas of memory, the == is not true, and the result is “this is not a pipe”.

The word and the thing it represents should not be confused…

Comment » | C

The Self

April 29th, 2010 — 8:49pm

In Objective C, the functions that objects perform are called methods. And when you ask an object to do something, you are ‘calling’ a method. However, when you call a method there is a hidden parameter that is transmitted to the object, known as SELF.  You would think that self would be some innate quality that each object would just automatically know, but in fact it doesn’t know, or need to know, that information until a method is called. At that point you are, in a sense, bestowing it with selfhood, or identity.

The interplay of SELF calls being made in a given program is a map of its consciousness.  My studying is going to have to take a backseat in the near future however, as the Austrian doctors are excited about this new test they’ve been working on. Apparently the big holdup was the strobe rate that they had to nail down.

Comment » | C

C’s the day

April 28th, 2010 — 11:44am

The C programming language is like Latin: no one actually uses it, but it forms the foundation for more popular languages that evolved out of it. Knowing Latin roots is helpful when confronted with new English words. Similarly, C is a great foundation for learning Objective C, which is the offshoot that allows Object Oriented Programming.

Object Oriented programming takes all the functions and variables from old-fashioned procedural-type programming and wraps them into semi-autonomous objects, which are pretty much just little entities that run around serving the needs of the larger program. The code is compartmentalized so there’s less alteration of existing text when making changes or additions. This is a big deal because any time you rewrite something you might introduce an error. Object Oriented Programming limits those errors.

Which is the same solution life came up with billions of years ago. If your genetic code addressed you in a procedural manner, as a single, multifunctional, inter-related blob, then tiny errors in coding (which in the physical world are called mutations and which lead to evolution) might easily make some fundamental, creepy and unpleasant changes in the functioning of the program (which is you).

If every organ in your body were dependent on the viability of every line of code in your DNA, you would essentially be screwed. Actually, considering that mating fitness is a prerequisite to attraction, the chances are that you would not be screwed at all. Or reproduce; or probably be alive. The answer to this problem of complexity is Object Oriented Programming.

The genes for the organs of the body are, generally speaking, units that are somewhat self contained. That way the stomach can evolve into a better stomach without having to worry about the code integrity of your white blood cell body wall instructions, or the code relating to the permeability of the blood brain barrier. You are an example of Object Oriented Programming at its most successful.

So my body does it without thinking. Somehow I still have to learn it.

Comment » | C, science

Not Thinking About That Thing

April 24th, 2010 — 4:15pm

Learning C is like reading one of the ancient philosophy books I ignored back in college. Now I’m reading about Pointers. Pointers are interesting because they are not concepts (variables/functions/things) but locations where those concepts may be found. By switching back and forth between a manipulation of the thing and the location where that thing may be found, you can work on data without having to ‘know’ the data. It’s abstraction at its most basic.

But even abstractions have a location. There is nothing you can think, no matter how removed from the physical world, that itself does not have a mental footprint. And so functions (which are like verbs that act upon the undefined nouns of variables), themselves have pointers. A pointer to a function will tell you the point in memory at which you can begin the operation of a function, but without having to ‘know’ what the function is.

The first thing that occurred to me when reading about function pointers is that this means we do not have to be enslaved to our unwanted thoughts. The phrase ‘don’t think about snakes’ is self defeating. You can’t help thinking about snakes. But “don’t think about the function beginning at…” is safe.  This would have been helpful to know as a kid when I would wake up sweaty and anxious after another dream of trying unsuccessfully to avoid thinking the thought that would drive me insane…

Comment » | C, consciousness

Countdown to senility.

April 23rd, 2010 — 1:12am

I fear that I might be developing early-onset Alzheimer’s (or else I’m just getting lazy). Ever since I came back from my trip to Indonesia I have to say that I find myself drifting off now and then, occasionally even holding a phone to my ear and not remembering who it was that I had just been talking to.

My wife doesn’t seem that concerned, but I mentioned it to Dr. Pierley (more tests finally, after a couple of months of stringing me along…) and she gave me some pills that she said would probably help. It is a generic form of the Alzheimer’s medication Aricept and she told me that it can help form new memories or strengthen neuro linkages, whatever. And considering how much this stuff costs I am pretty grateful she is handing it over at no charge.

These people are legitimate doctors doing valuable work.

1 comment » | C

Back to top