Tuesday, March 24, 2009

Vacation

I'll be on vacation with little or no internet access until April the 18'th.

No internet and no cellphone is really the only way to have a real vacation these days...

Monday, March 16, 2009

Running a program on a server after logging off

At work we have a pretty powerful server on which we run computationally intensive programs. Many times, I want the programs I execute to continue running after I log off. This is how to do it:
screen -S blah
run_my_command
Ctrl+a d

I can now log off and go home. The program will continue executing safely.

The following day, I log back to the server and type:
screen -r blah

I'm now back where I was.

Sunday, March 15, 2009

Language Verbosity

I recently took a look at the upcoming C++0x specification, and I was annoyed that yet more keywords were introduced into the language. C++ is already a very complicated language, and it takes months and years to truly master. I just didn't think that introducing more keyword would advance the language. In some sense, the size of a language's vocabulary is a measure of the language's complexity.

My concern is that as the technology advances, it will become increasingly difficult to be proficient even in one single language. The learning curve just becomes steeper and steeper with time, which is fine if you're there when they make the curve steeper, but not if you're at point zero. And I know that specialization happens for all sciences as they advance, but programming isn't a science and a programming language is a tool, not a science (from the user's point of view).

Natural languages (such as the one you talk to your mom with, I hope) are not like that, however. Their vocabulary size increases with time, regardless of the language. Unless your language of choice is Newspeak, of course. Another curious fact about human languages is that they allow one to learn the language, using the language. This might not be too clear, so I'll illustrate:

John Robert Jr IV is 6 years old. His parents speak English (not American, mind you). Little Robert can't understand everything his intellectual parents say, but, by the time he starts his studies in a snooty British college, he'll have already mastered the language. How did this happen? Little Robert doesn't know any other languages but English!

The answer is that one can use English to learn English. This happens because you can understand snippets of code, er, words, and understand the rest from the context and the non-verbal information (intonation, body language, ...). In addition, there are always several ways of saying anything, at different levels of complexity. There are synonyms for nearly all words, some down-to-earth, others only for people with a PhD. in Literature. This is how Robbert will slowly learn new words which better articulate what he wants to say.

Sorry, but we really need to get back to programming languages.

Programming languages are like that as well. C++0x may introduce many new constructs, but you don't really need to use them. When I started programming in C++, I simply changed the file extension to .cpp and continued programming in C. I eventually started using the object-oriented facilities, and after that started learning what the STL really has to offer. So I think there's room for hope. Having different ways of saying the same thing, some concise, some verbose, is actually a good thing.

This is one of the clashing points of two of my favorite languages - Perl and Python. The Perl philosophy is that there should be many ways to perform the same task. Python believes there should be one (see The Zen of Python). And the thing is that Larry Wall studied linguistics. The language he devised may be a write only language, but the basic idea of having many different ways of expressing yourself doesn't just give you the opportunity to make yourself clearer, it also makes learning the language easier. You can learn new tricks as you go along, but it doesn't block you from getting what you want done.

Of course, the above isn't really true for Perl, unless you can remember what $x is for any x, but the potential is there.

Sunday, March 1, 2009

And Then There Were Two

I have decided to split this blog in two. All the programming related posts will remain here. The Origami posts will move to their new home at: http://origamitips.giladnaor.com

I hope this will allow me to better concentrate on each subject. Good week!

Thursday, February 26, 2009

Productivity Tip #2

I recently realized that I'm actually two very different people. I'm one person at night, and another when the alarm clock goes off. My night-self, let us call him Mr. Gogo, is tired, but his brain is functioning pretty well. My night self makes all kinds of plans for the next day. And then, my morning-self, Mr. Gozen, screws everything up. So, my second productivity tip is:

Tip #2 - Kill Mr. Gozen

I don't mean to promote violence or anything, it's just that Gozen is an asshole. He has only one thing on his mind - going back to sleep. That just plain sucks. I want to do things, and he ruins everything. So I've decided to terminate him.

For the past week, my alarm clock has been going off at the ungodly hour of 5:58 am. I get up and start looking for the damn clock, usually thinking of nothing else but going back to sleep. By the time I find it, I'm pretty much awake, and Gozen is dying. You see, much like the Wicked Witch of the West (WWW) melts in water, my morning self melts in wakefulness. And I must say that life is much better without him.

Every morning, I do the dishes while I finish waking up, ignoring the last feeble screams of Gozen, then stretch and exercise, drink something warm, and head off to the computer to work for an hour on one of my hobby projects (I promise to reveal what they are soon). Then I wake the wife with a kiss, and on I go to work. It's great.

Now, most of you are probably worried that getting up in the morning will be bad because you'll lose sleep. Well, nothing can be further from the truth. While I do sleep less, I don't lose any sleep. If the left hand side of the equation is waking up early, than the right hand side must be to go to sleep early. Well, no, No, NO! That's were the beauty of this whole habit is - my evening self has some ability for cognitive action. And when he gets tired, he says - off to sleep, because being tired after a long day means that that's what you need to do. On the other hand, being tired after 6-8 hours of sleep means you are not thinking properly, Gozen has taken control.

Picture of a roadThe beauty of the system is that everything balances up. If you don't get enough sleep, you'll go to sleep earlier. But you will never oversleep anymore - you'll get exactly the amount of sleep that your body needs.

I find I'm more productive in the morning, even though I work pretty well at 2-3 am as well. It's just that I have plenty of peace and quite to do what I want.