C# For Programmers

January 31st, 2010

I just breezed through Illustrated C# 2005, and made a list of language features / concepts that struck me for one reason or another, mostly as a function of being either different from (or similar to!) features in other languages I am already familiar with.

ref and out parameters
pass value objects into or “out of” methods by reference
properties
allow exposing properties as fields, backed by getter and/or setter methods
static constructors
where it is possible to initialize static fields
finalizers
where it is possible to clean up resources used by an instance. Syntax is reminiscent of syntax for C++ destructors.
indexers
allows the square bracket operator (i.e. [5]) to be applied to instances
delegates
essentially closures that invoke zero or more methods with the same signature. Event handlers are implemented as delegates, such that adding and removing listeners is accomplished using the += and -= operators.
partial classes
allow classes to be defined / extended across multiple files
using statements
a convenience construct that maps to a try { ... } finally { ... } block, calling Dispose() (from IDisposable) on the used object if an exception is thrown
attributes
essentially Java annotations
inherited methods with virtual, override, new
method overridding must be explicitly permitted with virtual. Overriding and hiding also must be explicitly called out, via override and new.
iterator blocks, yield return statements
when defining new iterators for use in foreach statements
nullable value types, ?? (null coalescing operator)
value types can be allowed to have the value null. The null coalescing operator allows an alternative value to be specified more concisely, when a variable is found to be null. Similar to Groovy’s “elvis” operator ?: .
implicit and explicit type conversions
conversions can be defined between types for which an inheritance relationship does not exist. Overall, this seems like a confusingly “clever” feature to use, and probably best avoided.
generics and constraints (where clauses)
like Java generics, but with more expressive type constraints expressed as where clauses.
is, as, typeof()
how to dynamically check type information; is is like Java’s instanceof; as is like a C++ dynamic_cast; and typeof() returns a Type object.

Shorty Awards Rigged

January 24th, 2010

I suppose it is completely unsurprising that so-called user-nominated awards such as the Shorty Awards are manipulated by the big boys.

Loose Change

August 1st, 2009

I flicked a quarter to a guy on the street today.

A memory suddenly flashed in my mind – one of those indelible instants. Walking down some street in Cuenca, I saw a beggar sitting quietly by the side of the road. I can’t recall exactly, but he had some disabling deformity. Quietly is important – he seemed almost contented, completely at ease. He said nothing.

I had two dimes and a quarter in my pocket. I took the two dimes and pressed them into his hand.

That was the crucial moment. The way he received the coins from me was so special – it was so gentle and innocent, like an infant curling its fingers around your pinky, not knowing why – just something to grasp softly. It was as if the money melted away, and all that was left was the intention to give, just the idea of giving floating there in the air between us. Not even gratitude in his response – not even the seeking that is inherent in gratitude. Simply the acceptance of a flow. I have never had someone receive something from me like this.

Immediately I felt vexed. Why had I only given him the dimes, and not the quarter? What was the use of that lousy quarter to me anyway? Just what sort of miser was I? And then …

Just how do we decide who we give to, and how much? Why is it we give our friends much, those who typically are not lacking in material things, yet begrudge the needy of little? And a stranger can become a friend in an instant – one moment we feel we would never give him anything, and the next we are ready to invite him into our home! How can this change of heart be reconciled? Is there rhyme or reason to how these lines are drawn?

In Quito, I was walking down the street, and a lady was passing by. She had a scowl on her face, and was looking at nothing in particular. I thought, my, what a distasteful person! Yet for some reason I decided to smile at her. This was a little unusual in the sense that it is always easier to smile at someone who is already smiling, or who at least appears receptive.

Seeing my smile directed at her, suddenly, her expression completely changed! The scowl erased, her expression transformed with a broad, beaming smile! No trace of anything but joy?!

I was shocked! – I couldn’t believe it! – how utterly total the change was. I could not believe this was the same person who had just conveyed the essence of a dark thundercloud. Are we all like this – we teleport from this state of mind to that, this emotion to the other, this understanding of the world to that? Like a toad that jumps away every time you reach out to grab it – there is no pattern, all is changeable and uncertainty? The mysterious woman who calls Mr. Wind-Up Bird … her voice would change without warning …

An article in Harper’s a while back proposed an idea which I instantly saw truth in – Americans – and all people really – have an honest desire to do good, to enact philanthropy. But something in the fabric of society, in the confluence of expectations or whatever, is blocking us from being able to carry out our altruistic intent. It’s a double whammy – we feel crappy because our desire to be good is never fulfilled, only frustrated – and the good deeds themselves never get done, to the detriment of others and the environment.

Indeed, you can’t do anything right when you do good. It’s never good enough. When you do something nice, the feeling immediately gets diluted with the realization that you didn’t go as far as you could have – you could have been nicer, more generous of your time / energy / resources. The devilish seed has somehow been planted – you always second-guess anything that might be construed as good. Was it enough? Was it truly selfless? (It only has value if it was?) Doing good is a logical workout, and an exhausting one … to the point that it seems less tiresome to not even bother …

I would like to see things from the vantage point of a beggar. Not the angsty, unsettled beggar who is grasping and conniving, a “striving beggar”. Not that contradiction – how ridiculous it sounds! although we have all met them. But the beggar who has seen and accepted and merged with the vicissitudes of people, their moods, their motives, their emotions. Who has through this interactive experience come to understand changeability in the core of his being. Who completely accepts that sometimes people are, and sometimes people are not.

A beggar like this has seen many things, and can impart wisdom with a single, guileless brush of the hand. A beggar like this, in reality, is rich.

Not The Same

July 12th, 2009

What cost me my life, what turned it into that empty shell, I believe, was something in the light I saw at the bottom of the well – that intense light of the sun that penetrated straight down to the very bottom of the well for ten or twenty seconds. It would come without warning, and disappear just as suddenly. But in that momentary flood of light I saw something – saw something once and for all – that I could never see again as long as I lived. And having seen it, I was no longer the same person I had been.
Lieutenant Mamiya, Wind-Up Bird 208

The penetration of the vertical line, just a ray of light coming into your darkness of horizontal life, is the beginning of enlightenment.

You will look the same but you will not be the same. Those who have a clarity of seeing, to them you will not look the same either – and at least for yourself, you will never look the same and you can never be the same. You will be in the world, but the world will not be in you.
Osho, Maturity 90

No Me Olvidas

July 12th, 2009

Two characters specifically asked that I not forget them, so I will memorialize them here.

In the small plaza at the center of Vilcabamba, a group of young twenty-something men sit in benches and squat on the cement. There’s nothing much to do on a Tuesday afternoon. One waves me over intently.

“Jackie Chan? Do you know kung fu?” he quizzes me in garrulous Spanish. He is certainly the most bold of the group.

The men are really boys with a dose of machismo – as we chat, I am reminded of my students in Hunan – behind that facade of manliness, exists sort of timid openness, that could easily hook onto something or someone with a strong sense of direction. Despite a slurred manner that suggests they’ve all been drinking, they pay rapt attention to me, giggling frequently.

Jose is from Columbia. He’s in Vilcabamba working as an errand boy for various tourism needs.

A group of young girls walk by across the street, eating ice cream. Some wear halter tops, as seems typical for this area. At any rate, the plaza is the one place in Vilcabamba to be seen, for locals. The boys start hooting and making catcalls – I am amused at how excited they actually get. The girls, in turn, completely ignore them.

Jose turns to me and asks, “You like? Very nice, right?”

“They’re very young!” I exclaim.

“Hey! No problem!” he assures. “Yeah, you don’t drink, you don’t smoke – do you … ?” he makes an “O” with one hand and sticks an index finger through. The others twitter half-sheepishly.

I’m not sure how to respond, and certainly not in Spanish!

For some reason, they all want to keep talking to me. Jose, in particular, doesn’t want to let me go. Finally, after we have a few more laughs, he tells me not to forget him.

“No me olvidas!”

A few days later ….

We are walking uphill, with some difficulty, on a street going towards the Condor reserve outside of Otavalo. We pass dogs lazing around, children squatting in groups whispering to each other, and a passerby here and there taking an interest in the two tourists who have decided to come this way on foot.

Seeing us pass by, one man calls out, “Extranjeros!” He ambles towards us directly.

He looks like he might have been drinking, but then again maybe not – it’s hard to say for sure. He asks some basic questions, speaking and responding very slowly, but his eyes seem clear. He carries sadness with him, however.

He finds out we are Chinese, and has Mom write down his name – Francisco – in Hanzi. “You are welcome to come to my house,” he says. He asks what I do in the states. I tell him I’m an engineer.

“I’m an engineer too,” he says. “Of bread. I work in a panaderia in town.”

Without warning, he tells me that his girlfriend has just passed away. Tears well up immediately in his eyes, and I feel like he is in great need of consolation. “I’m really sorry,” I say, but in Spanish it comes out sounding flat, emotionless – I myself am shocked by the way it sounds. I translate the story to Mom, and she sighs and offers a sympathetic look. I still feel helpless.

Francisco collects himself somewhat, and slowly the conversation moves onto another topic. Again, he says, “You are welcome to my house!”

“Your house? Thank you,” I say, a bit uncertainly. For some reason, an image of Kasimjahn flashes through my head.

“My house is Ecuador,” he continues, not to answer any question my response had contained. “You are welcome to my house. But we are brothers and sisters around the world, am I right? Brothers and sisters everywhere. Don’t forget me.”

I take this as a cue to end the conversation. “Adios!” I say.

“No!” he replies abruptly. “Never ‘adios’. That’s when you part forever. Just ‘hasta luego’. We will meet again.”

“Hasta luego,” I repeat. With this he seems satisfied, and with a sad smile, starts moving away down the hill.


Bad Behavior has blocked 153 access attempts in the last 7 days.