The Disciple

Monday, May 22, 2006

Programming Editors Reloaded

Many years ago when I was still a junior disciple, I had a fetish for trying out different programming text editors. I was always on the hunt for that ultimate code editing program. Various times I would fall in love with a particular editor and stick with it for a significant time period, until I would eventually get curious and try a different editor just for fun.

I've tried and used Sidekick Notepad, Brief, Multi-Edit, Codewright, the Turbo C IDE Editor, vi, emacs, Visual C++ 2.0 IDE, notepad, metapad, notepad2, TextPad, UltraEdit - you name it, I probably tried it.

In the early to mid 90's, right before Windows 95 came out, I had to use Unix at work, and my primary editor was vi. Ugh, I didn't like it at all. It was tiresome shifting from cursor mode to edit mode. But after a year or so, I got so used to vi it became second nature and I learned to love moving the cursor with the hjkl keys. What makes vi unique is that your fingers never have to leave the home position (other than when you're pressing Esc to switch modes), which is kinda nice. But I always wondered why Unix didn't have those pretty, easy to use editors that Windows and DOS had.

During my free time at work, I taught myself Windows programming. Man, the Visual C++ 2.0 IDE was so pretty. And it was revolutionary at the time, imagine an IDE running in graphics mode! And you could design dialog boxes visually and such. I was used to running Turbo C under DOS, and while it probably ran faster and enabled speedier edits, the Visual C++ IDE was so pretty that I knew I had to develop for Windows 95.

Prior to that, for all DOS work I used Multi-Edit and enjoyed every second of it. That was a fantastic DOS app. It had this thing called 'syntax highlighting' which at the time was extremely cool. The language keywords would be displayed in different colors, to make reading source code easier. You can also integrate your own makefiles and scripts in Multi-Edit. So to build your project, you just hit a hotkey (I think it was F5 or something) and it would run make, compile and link your program. You never had to leave the editor. I still have fond recollections of Multi-Edit.

That said, Codewright was probably the more popular of the two, and Codewright might have been first. I tried Codewright once but I guess I was so used to Multi-Edit that I never had the desire to switch to another editor.

Going back in time further, back when I was in college, for some reason I enjoyed assembly language programming. It was challenging and I had the feeling of power, as if I controlled the whole machine, no compiler came between me and the CPU. You could get real intimate with your computer when coding in assembler. One mistake and you crash the whole system (it was DOS ok), and you define your memory and register usage to the very last byte. It also gave me a sense of pride when I completed an assembler program. In this case, my favorite app to code were TSRs, also called Terminate and Stay Resident programs. So you run your program and it would stay alive in main memory.

My favorite editor for editing assembler code was curiously enough, a TSR program called Sidekick. Oldies will remember this. Back then, DOS could only run one program at a time. But by using Sidekick, you just hit a hotkey and a popup notepad editor would appear. You type in your code in the popup editor, save it, then escape back to DOS leaving the editor present in memory. Then you could run MASM to assemble the code, test, run, repeat. Using Sidekick Notepad saved me a lot of time and I still have fond memories of using it.

In my Unix job, I would occasionally have tasks writing DOS utilities in Microsoft C. Before I became a diehard Multi-Edit user, I used this lightning quick editor called Brief. Brief was great, it had unlimited undo which was state of the art at the time (Multi-Edit I believe went further by providing unlimited undo and redo). Brief also ran very fast. I created a shortcut called 'b' so to edit a file quickly I just typed "b foo.c" and the editor would appear instantly.

Later on, after I moved on to Windows development jobs, I sort of lost track of my obsession for programming editors. I stuck to the Visual Studio IDE, it was good enough for me. If I remember right, I think I liked Visual Studio 4 the most. It was no-frills, ran fast, you could access the library reference within the IDE. Some stuff in Visual Studio 5 and particularly VS 6 annoyed the hell out of me. I don't even remember the exact reasons why but I think it had to do with the Find in Files interface. Actually I take that back, VS 5 was ok but I still miss the simplicity of Visual Studio 4.

I went through my Linux and open source phase in the late 90's. I wanted to try something new. It felt weird going back to vi. I even used vim in Windows instead of notepad for quick edits. Vi worked good in laptop keyboards, especially those where the arrow keys were out of reach. You see, in vi you can get by with the hjkl keys for navigation and never use the arrow keys. I also used emacs extensively for several months. I always read about these Unix diehards that promoted emacs as the greatest IDE/editor ever made and wanted to see what the fuss what all about. You know, up to now I still don't know what the fuss is all about. I guess the one good thing about emacs is that you can program LISP in it. But the key bindings were just too weird and hard to remember for me (Ex. Ctrl-X, Ctrl-C). I forced myself to use it for several months, but I found myself more productive in the Windows text editors.

Windows editors have one huge advantage over Unix editors such as vi and emacs. In Windows, you can selectively highlight a section of text and type over it to replace it with some new code. So for instance, when I want to replace a certain word with another word, all I have to do is highlight that word and immediately overwrite it by typing over. In the default vi and emacs modes, you need to two keystrokes to do this: 1. select text, 2. delete text, 3. write new text. I later learned that emacs had a 'select-overwrite' mode that emulated Windows editors, so indeed it was possible in Unix text editors, but it wasn't obvious.

Another huge advantage that Windows editors had was that you can use the numeric keypad arrow keys PgUp, PgDn, Home, End, Ctrl-Home (go to top of doc), Ctrl-End, Shift-Home (select up to start of line), etc. This just felt so natural for me to use. I use the numeric keypad arrow keys, PgUp, PgDn for all my navigation. You could do this in vi and emacs, I guess but this would entail remapping the keys. The actual keystrokes to do Home, End in vi and emacs were a bit more obscure.

I learned later on that most people don't use the numeric keypad arrow keys at all, to my surprise. Most people use the inverted T-Bar arrow keys. These were usually young people who grew up on the larger 101-key keyboards w. I grew up using those old IBM 83/84 key keyboards which didn't have the inverted T-bar. You just had the numeric keypad arrow keys and that was it. And I'm glad I use the numeric keypad as I can outrace anyone using the inverted T-bar in navigating a document.

I eventually gave up Linux after getting frustrated installing simple stuff such as Apache, Perl, and MySQL, and getting the those programs to work with each other. I figure this is much easier now because Linux distributions have come a long way since then. But Windows (as well as Mac OS X which runs on BSD) is also so much better now that for me it doesn't make sense to work in Linux unless you want to do it as a hobby. I said goodbye to Linux and went back to my old ways in trying out different text editors. And I experimented with a lot of freeware stuff which I still use today.

My current favorite quickie editor is notepad2. It is a notepad replacement that has syntax highlighting for all the popular development languages. It also has a regular expression search which is handy since notepad doesn't have it. I used notepad2 extensively for coding in python. The limitation is that it can open only one text file at a time. Notepad2's goal was never to become an ultimate programmer's editor, it just wanted to be a quick and simple text editor for the masses, which suits me just fine.

I also have metapad, another notepad replacement handy for typing in notes and editing non code files. I don't know why I still use metapad when notepad2 will probably work fine. I guess it's just force of habit that I use notepad2 for quick code edits, and metapad for quick non-code edits. Probably another reason is that I leave word-wrap enabled in metapad, while leaving word-wrap off in notepad2. That said, I know it doesn't make much sense using two different notepad replacements.

I tried TextPad and UltraEdit-32. I'll probably buy a copy of UltraEdit and make this my mainstream heavy-duty code editor. The big downer for me in using TextPad is that the keyboard shortcuts and non-standard, for instance, typing Ctrl-F to find a word doesn't work. And I don't think it has syntax highlighting built in.

Most of my coding stuff is still done in the Visual Studio .NET IDE. Sometimes I use VS Projects and Solutions, but for most of my work code, I just open the files in VS.NET without a Project, then do the compilation in a command-prompt window. The reason for this is that usually in production environments, the build scripts are separate from the IDE, so you have to compile the code on the command-line (usually typing in an alias or batch script to compile the whole thing). Believe it or not, there are many days when I don't use VS.NET entirely, and just use
notepad2 to edit and modify code. Usually when a program is in maintenance mode, I prefer to do quickie edits and forego the heavy duty IDE. That said, I plan to shift to using UltraEdit for both quickie and extensive edits.

That's a lot of text editors we've covered. But I haven't mentioned my current fave. This is what I currently use now at work and it's great. In fact it's not just an editor, it's a source code analyzer and editor in one package. I've gotten so attached to this program that I don't think I can code without it. It's called Source Insight and I highly recommend it. If you've never used an Editor/Source Code Analyzer like Source Insight, you're in for a huge treat.

Say you're tasked with maintaining a large codebase that you know little about. Or if you're modifying some of your old code that you've already forgotten and haven't touched in years. Source Insight will help you out. It's like having dozens of helpers assisting you in your code as you type. Move the cursor over a function and it will display the function definition in the lower pane. No more grepping around to look for where the function was defined. Or say, you want to know more about a particular struct variable, where it was defined, what are its members, etc. Source Insight does this for you, just move the cursor over the variable and it tells you more information about it. I estimate that I am four times more productive in maintaining code using this software. Source Insight is jampacked with all sorts of practical features.

Some other good stuff, it actually makes the code easier to read by enlarging and highlighting different sections of the code. For instance, function names are displayed in a huge font and in a different color, emphasizing the function name over its body. I remember editing in Source Insight for a week or two, then going back to Visual Studio. It was scary because the VS editor looked so dull in comparison. I knew then that I couldn't go back to using a 'normal' programming editor after that.

More cool stuff, you can traverse through code much more easily. For example, hit Ctrl-= over a function call and the editor will automatically open the function definition. I understand this can now be done in Visual Studio but only if you have the whole Solution open. If you're maintaining a huge codebase that doesn't have Projects and sln files set up, then you're out of luck. Opening files are easier too. No more hunting around in the various folders looking for source files. Just add all the source files to your Source Insight project, then hit Ctrl-O, type in the filename and it will highlight the file to open as you type. Such as a simple feature, but it makes a big difference when editing lots of source files.

I heard the SlickEdit editor/analyzer is also popular and has a similar featureset so you might want to check that out too. I haven't used it myself as we don't have a license for it at work. But the SlickEdit demos are pretty cool, and it will give you an insight on the power of what next gen code editor/analyzers are all about.

For me, Programming Editors are when I spend the majority of my coding time in, so it should feel like home. When you finally find your a text editor that feels second nature and compliments your abilities, you know you've found nirvana.

Thursday, April 27, 2006

Bum Part 1

I took some time off last week to clean the apartment and rearrange some of the furniture. At least now I can breathe and walk around indoors without stepping over old papers and books.

With the new arrangement, I have the small 13" TV side by side with a CRT monitor that is connected to an old laptop. That way I can surf the web and chat on IM with a wireless keyboard and mouse while watching TV at the same time. Of course I can use IM directly on the laptop via wireless, but you end up having to shift your neck up and down when switching between TV and computer, which isn't very optimal. Plus, with the two screens side by side, I can watch sports with the volume muted while viewing good videocasts such as DL.TV. Plus, I can quickly look something up on the other screen. Say for instance, I'm watching the game but I want to check on the stats of a certain player, or see highlights from another game that is playing at the same time. I can do that with ease and I don't even have to leave the couch.

I also retrofitted the L-shaped desk in my "office" with a smaller height-adjustable desk I bought from Staples that I use as a glorified keyboard drawer. Most of the computer desks on retail seem to be designed for giants. Not very ergonomic for a puny guy like myself. With the desk within the desk setup in my office away from the office, I am a happy man.

What else, I got a small standing TV tray (I don't have a dining table), so I can sit on this big executive chair while eating on the TV tray and watching sports and watching videocasts at the same time. I consider this a dramatic improvement as I can now eat dinner without sitting on the floor.

I'm also a big fan of free podcasts and videocasts over the web. So much so that I can foresee a day when I give up TV entirely, relying instead on the web for everything. There are still a couple of non-pro sports TV programs that I'm loyal to: Criminal Minds, Survivor, South Park, anything else? I like that more and more TV shows are being made available over the web (I'm referring to those that are legally available). Which is a good sign. In the future the internet will be like electricity and kids who grow up on the internet will treat it as a basic necessity. I'm still trying to convince my parents to go online more often so we can do voice chat over skype for free, but they need someone to set it up for them, which will ordinarily be me. Maybe the next time I visit home.

My mother used to call me a 'high tech bum' by the way, but I think in the future everyone will be a high tech bum, only it will be normal.

Thursday, March 31, 2005

Tools of the Trade

I use a computer a lot, both at work and at home, making the programs and utilities I use day to day very important. They make my life a whole lot easier. Here are some of my favorite software utilities and tools:

Notepad2 - I use this free text editor for all my editing and coding tasks. It's compact, easy to use, and has everything I need: syntax highlighting, string searching with regular expressions, tab indent customization, visual brace matching, can display line numbers too.

What notepad2 lacks is an MDI interface which allows you to edit multiple text files in the same window. A Find in Files function would also be nice. These features aren't a big deal for me at the moment, but I may consider switching to UltraEdit in the conceivable future.

Autohotkey - I love this utility. It allows you to configure hot keys to run user-programmable scripts on Windows. I set it up so that pressing CTRL-1 sets the focus to the command prompt, while CTRL-2 sets the focus to any open notepad window. When writing and testing code, I frequently have to switch between the text editor and command prompt. With autohotkey I can toggle between them by pressing CTRL-1 and CTRL-2. I also have a hotkey for opening frequently-opened files without needing to double-click them on Windows Explorer. Great timesaver.

Virtual Dimension - This is a free virtual desktop utility that allows you to have multiple virtual screens in Windows. I use this to avoid desktop clutter. I would do all the serious work (code, command-line, help screens) in one virtual desktop, and place all the fun stuff (browser, media player, etc.) in another virtual screen. You can even configure it to display different wallpaper background for each desktop.

I plan on connecting an additional monitor to the machine to get the advantage of simultaneous multiple displays (code in one screen, debug/output in another). This will probably eliminate the need to use a virtual desktop manager in the future.

Findstr - I have to mention this because it's my favorite command-line utility. It's the Windows equivalent to 'grep'. Search for string patterns from multiple files and directories. Need to find that function or class and forgot where you defined it? Just use findstr.

Unxutils - It's good to have a Windows version of the unix command-line utilities handy. gzip/gunzip, unzip, wc, which, cp, ls - they're all included here when you need them. Fills in the gaps in Windows tools.

Python - Excellent programming language and environment. Very underrated, can be used for over 90% of the most common programming tasks. Simple and productive environment with a huge library. I also use the interactive interpreter mode to try out new stuff, and do simple calculations. My main complaint with the Python environment is the lack of good documentation, most glaringly in the wxPython GUI library.

Visual C++ 2005 Express - It's important to have some sort of C++ compiler to fill in the gaps. You have access to the native Win32 API, and other great libraries such as DirectX. It's a good feeling knowing that you can initially code in Python, then have C++ to fall back on when you need native code speed. Don't forget to install the complete Platform SDK documentation as it is the ultimate Windows development reference.


I'm always on the lookout for great tools and utilities so feel free to send me some of your favorites.

Wednesday, March 30, 2005

The Disciple

I am a student of learning.

I observe complex patterns in the universe, in order to make them simple to understand.
I analyze human behavior, then attempt to find hidden greatness in individuals.

I represent your worst dreams, and your best nightmares.
I am your brother. I am your lover. I am your teacher. I am your friend.

I am... The Disciple.