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
Political

Early Weblogging Dec 2001

Recovered from the Wayback Machine.

If you’re concerned that Ashcroft and the White House are going too far in their hunt for terrorists, email Senators Leahy and Kennedy, as well as your own state senators. You can find senator email addresses at http://www.senate.gov/contacting/index.cfm. Even if you don’t agree with me, email anyway — let your voice be heard.

Categories
Political

Agreeing on Ashcroft

This is likely the earliest weblog entry I’ll be able to recover from the Wayback Machine. My earlier Manila weblog site entries were overwritten by an overzealous web bot that Userland was running. This includes postings that happened right after 9/11/. And before that, I created each individual writing using static HTML. 

I’ve found that weblogging is particularly useful when you want to say something quickly. What can I say? I just can’t stay away!

Speaking about saying something, Dave Winer writes about his concerns regarding Ashcroft’s recent actions. I’m writing to say that I concur with Dave, completely and totally on this issue.

The scariest thing I’ve heard from a member of the ruling politic is the following, from Ashcroft:

    • To those who pit Americans against immigrants, citizens against non-citizens, to those who scare peace-loving people with phantoms of lost liberty, my message is this: Your tactics only aid terrorists for they erode our national unity and diminish our resolve. They give ammunition to America’s enemies and pause to America’s friends. They encourage people of good will to remain silent in the face of evil.

I supported President Bush and his campaign in Afghanistan. I still do. And the more I hear about the Taliban the more I think we should have gotten involved with the situation a long time ago. However, I draw the line at secret military tribunals, holding people for months without any legal representation, profile-based questioning without merit or just cause, and most particularly, telling the people of this country that criticising the white house is aiding terrorism.

Liberty. Freedom. Justice for all. What the hell are we fighting for if these are nothing more than token words: red, white, and blue-speak. These are rights we have to fight for daily; to preserve not only from the enemy without, but also from the enemy within.

Previous weblog entries can be seen here.

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.