Thursday 4 November 2010

Take 2 Cygwin a day and call me in the morning

For developers who have never ventured out of their Windows environments and in to the world of UNIX based operating systems (like Linux and Mac OSX), the command line is an often under-utilised tool.

This is quite understandable in the case of the Windows command line that lets you relive your early DOS days. With all the lack of power of DOS, the command line was long ago abandoned for many mouse clicks and maybe once in a while a RUN command that is copied straight off the Internet and into the START->RUN control.

For the uninitiated, who have never dropped back to a command line or shell or who never even started there like us oldies, the commands look like line noise. Amusingly enough, those who were not Bourne from a shell probably do not even know what line noise is. Ahh, the days of whistling along to our high speed 9600 baud modems are long and lost along with bulletin boards and green on black screens. Those days are lost because the world has progressed to the point that you need not listen to the squealing down the phone line or force your eyes to work in a Matrix like world.

The good things haven't gone. The powerful languages that let their engineers create low level code like C and C++ are still around. Even if more and more amazing higher level languages appear, there will always be a place for the land of hardcore programming. They are needed. They are powerful tools. Weapons even. When wielded by good software engineers, great things happen. Of course, you do need the high level languages because who really wants to spend all their time perfecting memory management and automation of the reinvention of the wheel.

The other thing that will never leave us is UNIX land. The beauty and capacity of the UNIX tools will never become obsolete. They have been ported to every new environment to follow UNIX and implemented as APIs wherever possible. To live without these tools is for some developers, like cutting off a limb at the neck. It's a horrid disabled world.

Windows is one of these worlds that lacks the default access to UNIX tools. The DOS command line is not a poor substitute because it's not even in the same league. It's like comparing Java as a programming language to pig latin. It's simply a silly and meaningless comparison.

For those of us (usually .NET devs) who must play in an exclusively Windows world, we have a few ways around it. We either have a non-Windows machine at hand or we use Cygwin. Cygwin is a library that provides POSIX functionality in the Windows environment. You install it on any Windows machine (an install that takes at least four coffees) and it gives a UNIX like environment for Windows. The Cygwin commands look like UNIX commands but are actually wrapping Windows system calls that do a similar thing or have been extended to do so.

There are of course limitations to the scope of Cygwin that are based in the fundamental differences between the Windows and UNIX based operating systems. Pretty much, the foundations aren't the same so only so much can be faked. Often that much is enough to provide a developer with these much needed tools.

Now Cygwin on it's own is a nice little tool and a lovely idea but the serenity comes from all the tools that are built on this basic foundation. There are shells that let you believe you could be using bash; text tools like grep; and much more.

The zealots will kick me and say this is a poor replacement in a bad environment. I tend to agree but it's the best thing out there for us .NET devs. How any developer can live without it, is beyond my understanding.

You'll find Cygwin here.

Have fun.


cyberbofh said...

I use Cygwin for some years now and I see it as my electronic "Swiss Army knife"

dangph said...

Have you tried PowerShell? MS has totally leapfrogged Unix with PowerShell.

As a scripting language it makes sh look like the 1970s technology that it is.

As a command line interface it's also pretty decent. I haven't used anything else for, I dunno, about a year.

PowerShell especially good for .Net programmers. It's easy to call into .Net assemblies, including the .Net framework itself.

It does have a bit of a learning curve. You really need to read a tutorial (but not the official one -- it sucks). I find it however a lot more sensible than Unix shell scripting.

Acknowledge Me

Apple started a user experience trend many iOSes ago when it accepted Settings changes and did not ask for confirmation. Once the chang...