Thoughts on Reference-Based Copying

One of the biggest annoyances I remember when learning scripting languages was wrapping my head around copy by reference. I came from a typical “C/C++ rules everything” background, and I was amazed how quickly I was able to pick up Python because it was oh so similar to C++. Except that copy and deepcopy made no sense to me. Yesterday I was learning object-oriented programming in PHP, and the __clone() method came up.

One might argue why the language designers have gone to such elaborate fence-building when it comes to copying objects? Why not simply copy by value and let that be the end of it. One explanation, of course, is memory usage. But I think it’s also part of language design philosophy.

The so-called modern languages were created to make programming faster and more intuitive. And so we have loose typing, which most people agree is a sanity-saver (including me). This is why when you write “$” * 4 in Python you get $$$$ and not an error; after all, if you forget about computer architecture for a while, isn’t that what you were trying to accomplish?

I think the same thing is going on in reference-based copying. When we write a = b, we tend to think in our minds that a and b are now identical. This means that if one part of a is changed, b is changed as well. Of course you might argue that it’s essentially mathematical notation and there it has no connotations of “identical-ness”; but hey, let’s not split hairs here. :-)

Coding without Syntax Highlighting?

How good is the idea of coding without syntax highlighting? Like, when everything is pitch black on white background (or reverse, if you’re intent on losing your eyesight early). Despite what I thought earlier, it’s one horrible idea. Syntax highlighting is not just eye-candy; the color scheme you follow is a powerful filtering system that helps you quickly locate what you’re looking for: “An error occurred while parsing a string? Hmm, then I need to quickly scan the red portions in the login script”.

And this, in turn, reduces the pressure on your eyes and nervous system A LOT. The conclusion, which I accept with humility, is that I can be an ass sometimes.

My First Attempt at Limericks

Today I felt like sitting down and writing a few limericks. These might not be great, but I feel an odd joy in the thought that these are original. Here goes!

~1~

I’m often confused about what to read
with what my brilliant mind to feed
those mystery stories with clever hooks
or the tales of unfortunate crooks
but like always, I can’t decide, and am undone by greed.

~2~

When it rains outside my home
on the faraway marble dome
through the window comes a light
dancing, twirling, with footsteps light
and my thoughts follow the clouds that roam.

~3~

Am I saint or a heathen sinner
a loser or a glorious winner
these thoughts occupy my mind
against my wish, oh what a grind
I lose sense of time, and every day, forget my dinner.

~4~

There was a girl who always said
she will never embrace the marriage bed
one day the pressure became too much
from somewhere she got a gun or such
and when they found her, her eyes were full of lead.

~5~

Don’t ask me to say something profound
I’ll only keep talking round and round
until your patience will run out
and you’ll begin to stomp and shout
while I’ll still be admiring the insects on the ground.

It’s all about Sex

I started reading J.M. Coetzee’s Disgrace, anticipating the rush of pleasure that comes from reading a fine book. It’s a great read, but I’m kind of getting fed up with sex featuring as the bedrock of every great work. Now, don’t get me wrong — sex is interesting; very interesting, in fact. But I’m kind of getting tired of reading about frustrated desires, lost desires, suppressed desires, and whatnot.

Maybe it’s time I turned to the Russians? I remember no sex in Crime and Punishment, and Master and Margarita also looks like a promising read. Anyway, here’s to bad luck, which follows us more faithfully that a tail follows a dog!

Cleverness in Software

Sometimes you come across life-changing statements that enter your mind quietly and make you chuckle. I came across one in the open source book Eloquent JavaScript. Here it is:

A useful principle is not to add cleverness unless you are absolutely sure you’re going to need it. It can be tempting to write general “frameworks” for every little bit of functionality you come across. Resist that urge. You won’t get any real work done, and you’ll end up writing a lot of code that no one will ever use.

Wonderful English from around the World

Found this funny collection buried in my mailbox. Too good not to be shared!

In a Bangkok temple:
It is forbidden to enter a woman;

Even a foreigner, if dressed as a man.

Cocktail lounge, Norway:
Ladies are requested not to have children in the bar.

Doctor’s office, Rome:
Specialist in women and other diseases.

Dry cleaners, Bangkok:
Drop your trousers here for the best results.

In a Nairobi restaurant:
Customers who find our waitresses rude; ought to see the manager.

On the main road to Mombassa, leaving Nairobi:
Take notice: when this sign is under water; this road is impassable.

On a poster at Kencom:
Are you an adult that cannot read? If so we can help.

In a city restaurant:
Open seven days a week and weekends.

In a cemetery:
Persons are prohibited from picking flowers from any but their own graves .

Tokyo hotel’s rules and regulations:
Guests are requested not to smoke or do other disgusting behaviours in bed.

On the menu of a Swiss restaurant:
Our wines leave you nothing to hope for.

In a Tokyo bar:
Special cocktails for the ladies with nuts.

Hotel, Yugoslavia:
The flattening of underwear with pleasure is the job of the chambermaid.

Hotel, Japan:
You are invited to take advantage of the chambermaid.

In the lobby of a Moscow hotel across from a Russian orthodox monastery:
You are welcome to visit the cemetery where famous Russian and soviet composers, artists and writers are buried daily except Thursday.

A sign posted in Germany’s black forest:
It is strictly forbidden on our black forest camping site that people of different sex, for instance, men and women, live together in one tent unless they are married with each other for this purpose.

Hotel, Zurich:
Because of the impropriety of entertaining guests of the opposite sex in the bedroom, it is suggested that the lobby be used for this purpose.

Advertisement for donkey rides, Thailand:
Would you like to ride on your own ass?

Airline ticket office, Copenhagen:
We take your bags and send them in all directions.

A laundry in Rome:
Ladies, leave your clothes here and spend the afternoon.

Don’t Get Mad, Get Git

I’m overjoyed that my full day’s effort of struggling with Git has finally paid off. I now have a proud addition to my development and professional profile, and unlike most developers I meet, I can boast of being able to create and merge branches in Git.

It wasn’t easy, trust me. Git is quite complicated to understand at first, and I can’t even begin to describe how many times I had to draw diagrams and reread paragraphs for my understanding.

Finally, I can develop projects in multiple directions, not worrying about what happens to changes I make.

Life is awesome. Heck, I am awesome! :D

Linus Torvalds is a One Mean Guy

When not writing kickass software like the Linux kernel or Git, Linus Torvalds likes to spend time taking potshots at lesser beings and coding systems. I thought C++ was the only super-fast, C-like language that got on his nerves, but it looks like he’s also unhappy with C. At least the some of the implementations of it, like, like . . . nothing less than the GNC C Library! From the Wikipedia page of glibc:

glibc has been criticized as being “bloated” and slower than other libraries in the past, e.g. by Linus Torvalds and embedded Linux programmers.

Gosh, this guy is sooooo hard to please!

Coding without Syntax Highlighting

I’m a bitch when it comes to settling down on things, I admit. Two of the things that have bugged me the most for the past several years are font family and syntax highlighting. I can vividly remember the countless hours of torment trying to find the “perfect” font when I used to work on Windows (PT Serif and Georgia came close), and fiddling with syntax highlighting of code when I came to Linux (don’t even get me started about font rendering on Windows).

Should string be deep red, as they are in Kate, or is the pro-PHP blue better? Or maybe green, like some Python scripts online show? Should variables be blue, royal blue, deep blue, electric blue, dull blue? Bold? On and on and on, until I thought I’d go mad.

And then a simple thought struck me: why not give up color altogether?

The result is this, which is how every editor I own these days looks like:

No Syntax Highlighting

Is this the answer to my prayers? Time will tell, but for now I’m experiencing indescribable relief.

Thinking of App Downloads

A common tendency on my part, when it comes to screening free apps for download, is to look at ratings (of course) and the number of downloads. Just take a look at any of the category leaders, and numbers like 5 million are not unheard of. However, I can’t help thinking of a caveat.

I grant that I’m an outlier when it comes to a modern consumer, but a typical app that I like and use has seen multiple removals and installs on my mobile phone — typically like 10 or 20 times at least. And then we have updates to think of. Is an update equivalent to a removal and reinstall (why else do we have to download the full app even for “bug fixes”?)?

I think I wouldn’t be wrong in arguing that very roughly speaking, we can take one tenth of the advertised figure as the true number.