Categories
Just Shelley

Bad girl

I still can’t believe my mother sent me a telescope for Christmas. I guess parents know what a kid needs — no matter how old the kid is.

I’m a ba-a-ad, bad girl. I missed the deadline for my quarterly state and federal employer tax filings. I’m late. I forgot. They’ll probably do something nasty to me, now. I’ll send the filings in today and hope that the holiday season will warm the hearts of the California EDD and IRS workers and they’ll be kind to me.

Yeah, right. And a big fat guy with a white beard dressed in red carrying a sack load of goodies is going to break into my apartment at Christmas just to give me presents.

A huh. Sure.

Categories
Just Shelley

Bad Knee

Recovered from the Wayback Machine.

Walked to Pier 39 tonight. Weather was very pleasant, and crowd was fun. I got some silly socks for my brother and his family for Christmas.

Walking back, my knee gave out completely and I literally couldn’t walk at first. I managed to hop to a wall to sit until the pain stopped a bit. I grabbed the streetcar and was finally able to make it home, though going was slow.

I hurt my knee when I tripped over computer cables while working at what is now the defunct skyfish.com. The orthopedic surgeon I saw recently thinks I may have broken my knee at the time and have damage now. I’m supposed to try therapy for several weeks to see if we can avoid surgery, but the insurance company is being extremely difficult. As an FYI, If your company has Liberty Mutual for worker’s compensation insurance, all I can say is good luck if you get hurt on the job. Cheap assholes.

Categories
Just Shelley

While in San Francisco

Recovered from the Wayback Machine.

I just noticed that a lot of folks running weblogs have the flu or bad colds this week. Tis the season I guess. To all the sickies out there, get well.

I’m feeling pretty good myself. Friday was a beautiful day and looks like the weather will be nice next week. Bad knee or not, I’m getting off my butt and am heading into the wilds surrounding San Francisco. I’m in an antsy mood and need to cut loose a bit! It’s either go out of town and do some hiking, or hit some of the bars in SOMA or Mission. Of the two choices, I’ll be safer in the back country.

Categories
Just Shelley

A Seventies kind of thing

Drugs – Sugar Bowl Park, where rich family members came out to play Frisbee and the rest us came out to pop a little speed. Don’t let those Just Say No ads fool you folks; the only time we acknowledged that this country had a drug problem is when all those rich kids started getting high. Before that it was all Sugar Bowl.

Trip over the mountain – met these two little old ladies in a white van going across the pass from Reno to Sacramento. One lady was the mother of the other which seemed al-most un-believable to such young eyes when I realize how OLD the daughter was. And the mother had a wooden leg. Now, if you are going to cross a mountain pass in a snow blizzard this has got to be a one of kind way of doing it.

Berkley — There it was, the Mecca for all the flower children all over the world. All of us lined up for probably about 5 miles with cardboard signs saying “Seattle” or “New York” or “London”. Now, I can give you Seattle and New York, but London? Did these people really think that someone would be on their way to London on an expressway outside Berkley? It was a gimmick. We were learning even then. No wonder we grew up to what we are today.

Ketchup – a favorite way of attracting attention at demonstrations was to wait until a camera was near, try and get some poor fool of a cop to come near you, and splat – hit yourself in the head with a little bag of ketchup that you keep in the palm of your hand.

Pad – Cheap living room in a cheap apartment in a dirt cheap city with beads on the door and a mattress of the floor. Boones Farm wine in the fridge, and a water pipe on the table. Nothing more than a place on the way to somewhere.

Commune – Group love, group dishes, group dinner, group getting stoned, group love, group showers, group trips, group hugs, group work. Oh, and group love.

Sunrise – Through a halo with dancing colors and walking with Blue and friends to a cheap diner that stays open all night.

Rock – Far out man, groove to the tunes. Let it all hang out. Dance to the music, baby. Dance.

Categories
Technology Writing

Creating C# Applications: Chapter 4

One of the most innovative features of C# is the concept of managed and unmanaged code. It is this that truly differentiates this language from its more commonly used cousins, C++ and Java.

What is unmanaged code? Well, put simply, unmanaged code is any C# code that uses pointers. Conversely, managed code could be considered to be any use of C# that doesn’t include the use of pointers. However, the concept goes beyond these simple statements.

In C++ if you want to work with a block of data, such as a large text string (anything that isn’t a simple scalar value), you must allocate the resources for the string, initialize and use the resource, and then free or deallocate it manually when you’re finished. To pass a reference to the string in a function you wouldn’t need to pass the entire string, but only a pointer to the string’s location in memory, its address. Using pointers is efficient, but one of the problems with manual allocation of resources and the use of pointers is that the developer may forget to free the resource, causing a loss of the resource commonly referred to as a memory leak. After many iterations of the code, the application’s performance can degrade, and may even stop performing.

Java eliminated this problem by eliminating the need to manually allocate and deallocate resources. The Java Virtual Machine (VM) provides the resources necessary to support the application and also provides garbage collection (defined in more detail in the next section) to clean up and free the resources after the application is finished. This approach prevents problems of lost resources but also prevents the use of pointers as the support for garbage collection and pointers are mutually exclusive.

C# eliminates the problem of having to choose between the use of pointers and the associated problems of resource loss, and automatic garbage collection but without support for pointers. The language does this by providing support for both garbage collection and pointers — if you follow rules carefully defined within the language that allows both of these seemingly incompatible capabilities.

In addition to the support for managed and unmanaged code, C# also has other unique concepts available to it based on the runtime language support provided by the Common Language Runtime (CLR), such as the WeakReference wrapper class, useful with larger objects and collections.

First, though, let’s take a closer look in the next section at why the use of pointers and garbage collection are so contradictory. If you already know this, you can skip to the section titled “Managed and Unmanaged code,” following.

Garbage Collection and Pointers

As stated earlier, in a programming language that doesn’t provide automatic management of resources, you must allocate and initialize the resource and then deallocate it when finished. However, when garbage collection is supported, you don’t have to manage the resources as the garbage collection mechanism does this for you.

Within the CLR environment, storage space for a new object is pulled from a managed heap. As a new object is created, it’s allocated space within the heap and an address is assigned to the object that references the starting address of its location in the heap. The object’s given the next available space within the heap that can contain it completely.

The amount of space in the heap assigned to the object depends on the structure of the object. A pointer is used to traverse the heap until a contiguous block of space large enough to fit the object is found.

Garbage collection is used to find objects that are no longer being used and to free up the heap space the object is occupying. In the Common Language Infrastructure (CLI) architecture, the garbage collection mechanism is triggered when the pointer used to search for an available heap location travels past the boundaries of the heap.

During the garbage collection process, the collection mechanism visits each address on the heap, checks to see if the object is still being referenced (can be reached and is therefore accessible by existing process) and then freeing up the space if the object is no longer within the scope of the existing process or application scope. The mechanism also optimizes the heap by shifting the addresses (the pointers) of existing objects to provide contiguous blocks of free space for new objects as they are allocated.

This last statement actually explains why manual creation of pointers and garbage collection are not compatible within the same development environment. You can’t create an object and reference it via a pointer to an address that could then be modified by an automatic garbage collection mechanism, thereby making your reference — the pointer — meaningless.

In addition, in this process the garbage collection mechanism must know how much space an object takes up — its structure — in order to manage it efficiently. In C++, it isn’t unusual to cast a pointer from one object/structure type to another, making garbage collection virtually impossible as the mechanism wouldn’t be able to determine the exact structure of the object, and therefore how much space is needed or occupied.

The problem of using pointers and garbage collection in one language is solved through the use of managed and unmanaged code, discussed next.