Archive for Rants

How to not switch to Dvorak

Once in a while, I practice to improve my touch typing skills. Most of the time, I just find some online stuff or use KTouch. But today, I wanted to try something different. I always hear good things about the Dvorak keyboard layout — i.e., how it’s supposedly more efficient and more comfortable than the Qwerty layout. Being a curious person, I wanted to test this out.

So when I opened up KTouch, I selected the Dvorak lecture, instead of the typical Qwerty one. The first lessons were fairly easy. As I went through the lecture, I managed to keep a fairly high pace and accuracy – i.e., about 210 characters per minute with a 95% accuracy. About at the fifth or sixth lesson, I said to myself: “Wow, I must have been a Dvorak typist in another life.” I was really impressed how quickly I had learnt the basics of the layout and I was indeed starting to believe that the Dvorak layout was vastly superior to Qwerty.

Shortly after, I was sold. At this point, I was thinking how was going to remap my Emacs key bindings.

However, when I got to the tenth lesson, I found something strange, very strange. The letter ‘q’ on the Dvorak layout was in the upper row on the left — exactly where it is on the Qwerty layout.

I stopped typing for a second…

…and look at the keyboard displayed on the screen.

“asdf asdf asdf”

Oops! I had forgot the change the actual layout of my keyboard. So, I was still using Qwerty.

Now, I realize that I have been victim of what they call the “placebo effect”. This little anecdote has certainly thought me to be more careful, in the future, when trying something new sold has “better”.

Tips on Emacs

Update: Please take the content of this post with a grain of salt. I wrote this at a time I was easily impressed. I still think Emacs is great editor, but it is not the only one. Look around, do your own experiments and pick the editor that fits your needs best. Although I don’t like the evangelizing tone of this post, I still believe in its conclusion: mastering an editor is an extremely worthwhile investment if you are doing a lot text editing.

Here a few Emacs tips and some gospel for those who are still using a butter-knife editor. First, the most important skill you must develop is touch typing. This is what make the most difference in your productivity. I found out that Emacs is really pleasant when you are able to type, at a rate above 50WPM. One thing is sure, being able to type fast, make any typing task more pleasant. From my own experience, when you get good with the keyboard, you start spending less time reading about other people achievements and start creating your own cool stuff. And learning to type fast is easy. Find some online typing material and spend 15 minutes per day, working on your typing skills. You will never regret it.

Most IDE do a lot of code generation, because some programmers are too lazy to learn touch typing. So, they need snippets, IntelliSense, automated refactoring, etc. They’re all nice features. But, do they really make you more productive? I don’t think point-and-click programming is really productive. That is where Emacs comes in. Emacs, and also Vim, are different in the way they attack the problem of rapid development. They both try to make editing easier, and this is a truly challenging task.

Emacs gives you the power to make your editor. Some people may argues that, this feature made Emacs an operating system. Yet, it is this flexibility that made Emacs so powerful. Almost all the commands in Emacs are coded with Emacs Lisp — a full programming language built in Emacs. Even the cursor behavior is coded in Emacs Lisp. How many of these point-and-click IDE have you seen, which allowed you to change how you move the cursor? I bet the number is near zero. An example of this power, is a mode called chop. This mode makes your cursor behaves like a binary tree. It allows you to reach any line on your screen in O(log2 n) steps, where ‘n’ is the screen’s height. In plain English, this means you can reach any line, on a 130 lines screen, in less than 7 keystrokes. However in reality, the number steps is much smaller, because Emacs has a full set of other tools for moving your cursor, where you want it.

Now the interesting part, how to get good with Emacs. Learning Emacs is the same thing as learning touch typing. You need to practice a lot and frequently. The first thing you need to master is the keyboard shortcuts. There is a lot of shortcuts, in Emacs. There’s probably more than your brain can hold. But with some training, we will see that Emacs’ keyboard shortcuts are easy to remember. They all follow the same structure. Like touch typing, there’s also tools for learning the keyboard shortcuts. I highly recommend keywiz, which run within Emacs. This tool analyzes all the keyboard shortcut in Emacs, even the one you changed, and generate quizzes about them. Again, same idea as touch typing, practice about 15 minutes per day on a daily basis.

As your journey progresses, you will find the need to change some of the default behaviors of Emacs. This is done by putting stuff in your .emacs — the most precious file of any Emacs user. Trust me, you don’t want to lose this file. So, make sure you do regular backups or use a version control system, like Subversion, to protect it. How to use this file is an art itself. Some people like to keep all their configuration in a single file, some don’t; some others don’t care if it’s messy, some don’t; and so on. Personally, I like to separate the different components into smaller files. And, I like to use customize for the on/off type of settings. But, that is just question of personal taste. There isn’t a better .emacs. The best one will always be yours. You will, although, want to see how the others configured their Emacs. That is normal. We are all curious creatures, after all. A final note about .emacs, don’t spend too much time playing on it. Configuring Emacs is fun and addictive, but it won’t help your productivity by much, if you can’t touch type or use the keyboard shortcuts.

The last, but not the least, thing you need to know, is Emacs Lisp. This is probably… No, this is the greatest feature of Emacs. And, it’s also the hardest to master. Learning a programming language is not the same thing as learning touch typing. Dumb practice won’t help you. You will need to sit down and think. Lisp, and all its parenthesizes, freak most people, who got some programming experience. Unlike some people says, Lisp is easy to learn. There’s nothing exceptional about learning Lisp. You learn it as any other programming language. Get a book, read it attentively, write some code, repeat. That’s my general algorithm for learning programming languages, and it works. I learned several programming languages, including Lisp, this way. One more thing, knowing Lisp do not make you a superior programmer. What makes you a superior programmer is your ability to learn new ideas. So, don’t get caught by this lie from Lisp evangelists.

Emacs is still a great tool, even if you don’t learn Emacs Lisp. In fact, many Emacs users never learn it and are still more productive than the majority of the other editors users. You can always copy-and-paste some Emacs Lisp code found on the web.

However, I haven’t said yet why you should learn Emacs Lisp. The reason is that if you know it, you can add features to your editor, on-the-fly, without even restarting Emacs. Did ever wished your editor had a particular feature? Well with Emacs, when you know Emacs Lisp, you just add it. Emacs evolves with you. So, if you do a lot of programming, you will end with a lot of programming helpers and macros. On the other hand, if you write a lot of web articles, you will probably end up with a lot of text manipulation utilities. It is just beautiful, how Emacs can adapt to your editing needs.

Finally, mastering a good editor is a lifetime investment. You better choose one that can evolve with you or you will end up using many different editors poorly. Remember, that being productive isn’t that important, but the fun of mastering something is. You will smile when you will transform a painful editing task into a trivial one. So, enjoy your journey in the world of Emacs.

Web Design Tips

Today, I been impressed how high my comment has scored on Reddit. So, I taught it would be useful to repost it, here, on my blog for future references.

First, learn how to write proper HTML without any IDE, like Dreamweaver. Or if you do, only use the code view. After that, embrace the web standards, but without becoming a fanatic. Finally, learn how to separate the structure of your web pages from their design with CSS.

In summary, to improve your website you should:

  • Rewrite it or do a heavy clean up job, without Dreamweaver’s design view.
  • Make it pass this test.
  • Fix all the links.
  • Learn how to use the <title /> tag.
  • Remove any animated GIF image and Flash applet (unless it helps to the comprehension of the content).
  • Fix the fonts. Try to use (or at least fallback to) either “web core fonts” or serif/sans-serif.
  • Replace the <font /> tags with their CSS equivalents.
  • Use tags properly (ie. only use <table /> if you really want to make a data table).

References

The secret of Ubuntu success

Ubuntu has been my first distribution of Linux. I learned everything I know about Linux, on Ubuntu. However, there is a question that has been bothering me for a while: “Why Ubuntu is so successful?”. It took me some time to find the answer. The answer is simple, we are nice to new comers. We don’t try to prove anything to them; we just help them. (Of course, being the best distribution out there helps :) )

The slogan of Ubuntu, “Linux for Human Being”, took all its meaning when I finally understood that. We are the humans. We aren’t supposed to work for the computers. They are the ones supposed to do the work.

That brings me to the second reason of Ubuntu’s success. We are making Linux works out of the box. Users shouldn’t need to have to read a 10,000-pages manual just to use Linux. Not because I read the manuals, everyone should. Of course, we need all those friendly howtos and guides. They make Ubuntu so much more fun to use.

I think we need to continue in that direction. Sure, translucent windows are cool, but we should always remember the roots of our success.