Choosing your text editor

Any programmer worth his or her salt will tell you that the text editor is one of the most important things in a code-writer’s toolkit. There are tons of text editors out there, come are simply clones of each other, while some are really unique. Windows Notepad is about the bare minimum that you can get, but if you really want to be an efficient programmer, you’ll probably want something that lets you do more than simply enter text. Most programmer like text editors that allow for mundane tasks to be automated, while otherwise staying out of their way. However, all programmers have their own likes and dislikes as well as varying ideas of the perfect text editor. But how does one find their own suitable text editor?

The first step is to figure out what exactly you are using your text editor for. If you mainly code in just one or two languages you might prefer to have an editor that has inbuilt features for working with those languages. In that case it’s best to see what others like you are using and try out the choices. However, most programmers don’t spend their whole lives coding in one or two languages and as new languages come onto the scene, you probably don’t want to have to switch to a new editor every few years. This is where extensible text editors come in to the picture. Extensible text editors have a small core that deals with routine text editing tasks and also gives you a way to add plugins or extensions which are language or task specific. If you need to switch to a new language, all you have to do is find corresponding extensions (or write your own, if you don’t like what is available).

The most extensible text editor of them all is probably Emacs. Unlike most other software which allows extension via API or some sort of simple configuration scripting, Emacs packs a full-fledged LISP interpreter for a custom dialect of the language. This allows almost limitless configuration. Not only can you write simple scripts to clean up your code, you can embed full-fledged programs, like file managers and FTP clients. In fact, many people have claimed that Emacs is not a text editor at all, it is operating system squeezed into a text-editor’s skin. While Emacs may be God’s greatest gift to anyone who loves making customizations, it is not without it’s problems. Firstly, Emacs depends on lengthy key combinations involving pressing the Shift, Ctrl and Alt keys one after the other along with a few letters in a wide variety of combinations. These key combinations can be quite hard to remember unless you make it a point to memorize them and because of all the unnatural finger movement that have to do, there is quite a high risk of Repetitive Stress Injury. Definitely not fun. And to top it off, it looks like something out of the stone age. For all these reasons (and some more) a lot of people like Vi and its clones.

Vi is a text editor that has been around since the earliest days of UNIX operating systems some thirty years ago. Vi does not pack a full code interpreter, and is not as easily extensible as Emacs (though the newer Vim editor includes a nice little scripting which might be of interest if you have some free time). But that is not the only difference. While Emacs uses long key combinations to let you access a host of text editing functions, Vi requires to switch modes to manipulate the text. In the insert mode, you can type in text, use the arrow keys to move around and use delete and backspace to erase mistakes. But if you need to do something like copy/paste or find/replace, you have to enter the command mode by pressing the escape key. In this mode, you can’t type in text, but you execute commands to manipulate the text. These commands are short (generally just a few characters) and according to Vi lovers over the world, far easier to remember than Emacs’ key combos. Most people who use Vi probably use a clone called Vim, which has both command line and graphical modes, and the graphical mode actually looks pretty decent.

But are either of these really for you? Both of them have substantially learning curves and you will have to spend a good few hours learning your way around if you want the maximum benefits. Both allow extremely fast and efficient text manipulation and a good deal of customization. But a lot of people simply don’t want to spend time learning commands and simply want to get on with it. So what do they do? Why they write their own of course. There are loads of text editors out there because their creators got tired of unwieldy key combos or switching modes all the time. Most of these will not be actively developed for more than a few months, but there are some that are quite good.

Both Vim and Emacs are cross-platform running perfectly on Windows, Linux, BSD and Macintosh. One other cross platform editor that I like and have used quite often is jEdit. It’s written in Java and runs anywhere with a Java Runtime installed. It’s not as powerful as the above but there is an active community of plugin developers and a number of very good plugins (as well as an internal plugin manager that is very useful). Actual development on the editor stalled for a while after the original creator left, but it has recently restarted. The only problem is that it can be rather slow to start up, especially on older machines.

If cross-platform isn’t a necessity, then I have some recommendations for you. For Windows, Notepad++ is one of the best free and lightweight editors that I’ve used. It’s based around the excellent Scintilla editing components but throws in a number of useful extras and sports a nice clean UI. For Mac users, TextMate will probably fulfill all your needs. I haven’t had the opportunity to use it myself, but I’ve heard that it can be as powerful as Vim or Emacs. It’s not free, but if coding is your full time job, it will probably be a wise investment. Linux users have a wide galore of editors to choose from. You can use the editors that come with the two major desktop environments, Gedit and Kedit. If you are a full KDE user, Kate is a more powerful alternative. One of the newer editors that is getting some publicity is called Scribes. It’s a compact editor with a few killer features like a very good auto-complete system and good template support. But there’s a catch: it’s very dependent on GNOME libraries and if you don’t use Gnome that means a large extra download, but more importantly, unlike all the other editors that I’ve talked about, it has a single document interface, i.e. opening a new file doesn’t open a new buffer or a new tab, it opens a new window and if you’re handling multiple files, you’re handling multiple windows, which may not be the easiest of things.

Ultimately it is up to you to find your perfect editor. I recommend trying a few out before you find your match. And if nothing appeals, you could try your hand at spinning your own. With the various tools available today, it is actually quite easy to create a simple text editor (although it is quite a challenge to create an editor that is not simple).

Is Google Reader getting ignored ?

Google Reader has been one of the more erratic Google products. When it was first launched, it didn’t garner much attention. But it’s 2.0 release almost a year made quite a few heads turn and it now has quite a large user base. There have been a few improvements after that (like including video and a widget for the Google Personalized Homepage), but only the major development was probably the reporting of the number of users to services like FeedBurner. Even though Reader is now over two-and-a half years old, there is still one major feature that it lacks: search. Almost all the other services have search including much less used services like Notebook. A few hours ago, Google offered an updated user interface including a bar on top for the various Google services. Once again, Reader is one of the services that do not have this update. One would think that Reader’s substantial user base, Reader development would be one of the top priorities, but from the looks of it, Google Reader is getting ignored. With all the invest that Google is making in new services and software, is it too much to ask for a way to search through our feeds?

Falling in Love with Scheme

Since I have some three months before I start my computer science course at college, I decided that I’d get a head start and learn some real computer science (not just programming) before I get started. Though I’ve dabbled with a number of programming languages (and have a number of “beginning” books thanks to Apress publishers) they really aren’t good for computer science per se. I’ve decided to go with a long-standing computer science classic: Structure and Implementation of Computer Programs.

The book has been the textbook for MIT’s introductory computer science course for over two decades and has a wide reputation. One of the reasons that it has been regarded as a classic is that it doesn’t use any “industry standard” programming language at all. Rather it uses Scheme, a dialect of LISP, a functional programming language and one of the oldest to still be in active use. Scheme is extremely well-suited to be a “learner’s language” for serious computer scientists and it’s hard to actively use Scheme without being deeply impressed by it. Even though I have only been using Scheme for a few days, I’m already in love with it and though it isn’t quite my favorite programming language, I really enjoy using it, much more than most of the other languages I’ve used before. Here’s why:

Scheme has very little syntax

One of the things that makes Scheme stand out from most other common programming languages is that it is a functional programming language with very little actual syntax. All the code that you write is part of a function and your program works as a series of interactions between these functions. Not only are there no classes, or objects, there are not even the more common syntactic forms such as loops (while, for, do-while etc.), these are implemented via function recursion. In fact, besides the function definitions, the only major syntax students have to deal with are conditional statements in the form of an if-else idiom and a general conditional syntax with multiple conditions and corresponding actions, such as:

(cond

(test1 expr1 ...)
(test2 expr2 ...)
...
(else exprn))

Though there are an abundance of data types, students do not really have to bother about these when they get started. All this means that any intelligent student can grasp the fundamentals of the language within a few hours and concentrate on actually learning computer science concepts and their implementations.

Scheme has a great IDE

… in the form of Dr Scheme. Though not really necessary to use Scheme, this IDE makes it very easy to get down and dirty with Scheme. Not only does it offer several implementations of the language (so it’s useful for a wide variety of CS courses), it let’s you immediately run and test code that you’re written. The standard window features both a text area for you to write your function definitions and an interactive interpreter right below it where you can directly use your functions.Along with that there are also simple debugging tools which let you step through your program to find out what’s wrong. Here’s a screenshot to show you what I mean.

DrScheme's multiple panes

Scheme really isn’t a language at all

Many programming languages are created because some people somewhere want a better way to get something done. For Scheme, however the story is a bit different. Scheme has it’s basis in mathematics and in fundamental theories regarding programming language implementation. As a result Scheme is not bound by arbitrary standards or needs to get it to work like other people expect it to. In Scheme, all the code is written in the form of S-expressions, a type of mathematical expression. Add to this it’s complete lack of syntactic sugar and the fact that it’s implementation is based on the theories of lambda calculus, and you end up with something that feels more like a slightly peculiar way to organize your logical thoughts rather another programming language. I personally have come to view Scheme as a sort of “executable pseudocode”. I find that once I’ve come up with an appropriate algorithm to solve a problem, it takes almost no effort to put it into code. This is far from the experience I’ve had with languages like C++ and Java where coming up with running code can be as cumbersome as getting a working algorithm.

Scheme fundamentally changes the way you think

Ask anybody who has worked with Scheme or any other LISP derivative for a considerable length of time, and you’ll probably hear the same thing. Scheme encourages you to put aside the implementation details of a program and concentrate on finding the optimal solution. It’s use of S-expression syntax and functional nature helps you learn to properly segregate the different aspects of a problem instead of letting you cobble everything together. Use Scheme for long enough and you’ll find your Scheme-oriented thinking spill over into other aspects of your life (like wanting to use brackets all the time (and put brackets inside brackets (which is probably something you’ve never done before))). If you haven’t used Scheme yourself, you may not quite have believed everything that you’ve read now, which is actually more evidence for the fact that Scheme changes your thought patterns. If you have a few days worth of time on your hands, go get Dr Scheme and some good Scheme documentation and dig in.

Announcing Backlog

A large part of what I post on this blog has to do with new stuff: new technologies, new services, new trends. In order to offset this large amount of information regarding new things, I’m going to periodically write articles under the heading “Backlog”, i.e. articles regarding slightly older technologies and tools, but ones which are still useful today. Don’t worry, I’ll try my best not to turn them into boring history lessons, wherever possible I’ll be drawing comparisons with modern alternatives and giving instructions to put these time-tested utilities to work for yourself. I intend to post one Backlog article a week, starting from next week. And also from next week I intend to post at least every alternate day, if not everyday. Once again, thanks to all my readers for sticking with me through a dry spell and I will try not to disappoint again.

What Silverlight Means For You

If you keep tabs on the world of web 2.0, then you’ll have heard something about Microsoft’s newest offering, Silverlight. Silverlight is an outstanding piece of technical wizardry, with even long time Microsoft critics admitting that it is a very good product. But while the technical people and the application developers may be very happy about it, what does Silverlight mean from the tech-savvy web 2.0 user who isn’t a developer, but simply a user? Right now, not much. However, given time and sustained interest in the new platform, it could mean a lot. Let’s take a look at what might come of Silverlight.

More Variety

When first announced, it sounded like Silverlight was being poised as a direct competitor to Adobe’s popular Flash technology. But the latest announcement (the one that has garnered the most interest) has made it clear that Silverlight is not quite so simple. The Silverlight plugin (which weighs in at a mere 4MB) will contain a version of Microsoft’s .NET Common Language Runtime. The CLR allows programs written in a number of popular languages like JavaScript, C#, Python and Ruby to be run directly in the browser itself. While this gives developers a large choice in how to implement their web apps, it means that users can expect to see a new generation of even richer, more feature packed applications delivered right in the browsers. It also frees users from having to understand what plugins or virtual machines are required for their selected web app and developers no longer have to bother with maintaining a plugin in addition to their web app, Silverlight does the worrying for them.

Speed

One of the major benefits for end users will be the greater responsiveness that Silverlight will allow for Internet based applications. The recent demonstrations have shown than Silverlight can run JavaScript apps many times faster than native browser implementations. No more waiting around for long periods of time for the applications to load before you can start using it. Heavy duty applications like online web suites, image editors or publication tools similar to Yahoo! Pipes will most benefit from the vast speed increase, but some of the improvement will trickle down to even the smallest pieces of JavaScript. Silverlight applications will also be able to access and alter the basic structure (the DOMs) of the web pages that they will use as interfaces. This means that users can expect far richer, more interactive programs where the program will be able to keep track of any changes made and react accordingly.

Better Multimedia

Flash is currently the most popular technology on the market when it comes to developing streaming media via a browser. But Silverlight promises to do all that Flash can do and much more. Silverlight will allow distribution of video at very high quality (720p or high definition) and will also allow native full screen viewing (as opposed to the current alternative of a maximized browser window). What might eventually make Silverlight a better option than Flash are the new web services that Microsoft is building around Silverlight (and currently distributing full of cost). A service called Silverlight already allows users to store their content and Silverlight based web programs on Microsoft’s servers. If Microsoft handles this properly, we might soon see a large number of new multimedia sites springing up offering richer multimedia and data services and overall better usability for the end user.

While Silverlight currently seems more like a developer tool than an end-user must-have, that might change very soon. Silverlight has a lot to offer for developers, especially those who have been struggling for a long time to consolidate disparate technologies like JavaScript, XML and Flash to make robust web products. Of course, Adobe will stand to lose a lot if Silverlight eclipses Flash, but Adobe already has a firm grounding in the market, which it will be trying to consolidate with the growth of rich web 2.0. In the middle of all this will fall the various web-startups who are currently using AJAX alone, but might easily be outclassed if newer start-ups start using Silverlight vigorously.