Ncurses makes C all warm and fuzzy

Get it? CC cuddling cheese-kun? Warm and fuzzy? C? Get it? When I first started messing around with GNU ncurses I was under the impression it was a simple framework to create interactive, windowed console applications…

In reality it's a complete, really polished environment that extends C in some really nice ways; so much so that I would argue it would be a misnomer to say you're simply writing "C" code any more. It's to C what Cream is to Vim. It's CC with Cheese Kun. I could go on.

Header files

The first sign you get that ncurses is something special is that importing it's single header file gives you all these below header files automatically.

In fact you're actively encoraged not to import any of these usual suspects because you'd needlessly inflate your compiled applications. I assume it's doing some clever tricks to only use what's nessisary. It also adds a bunch of it's own functions that provide similar functionality, more on that below.

Booleans

Most people start with C and move on to C++, I went the other way… you can probably see where this is going! When you import you get a boolean data type for C for free. Paroozing the header file it seems to cleverly make sure it doesn't conflict with the C++ bool if that's the language you're using, pretty cool.

Alternatives to standard in/output

This is what I mean by ncurses almost being like an entire environment for C, it makes so much stuff easier and more fun. As well as supporting the basic C output functions such as printf(), ncurses comes with a bunch of extras that make sense when dealing with GUI-like interfaces in a terminal.

What's also really cool though are the functions for reading in data from the keyboard which is much nicer than vanilla C:

getch() /* get character */
getstr() /* get string of characters */
getnstr() /* same as above, but measured */
scanw() /* equivilent to scanf(); */

Why?

I'm surprised by the number of people asking me why, in 2010, I'm interested in writing console applications, because we all know console applications are passe and unsexy. I'm hoping in the coming weeks when I start writing code for a few projects (and am hopefully allowed to publish some of it) you'll see why. There's still a ton of life in this environment and I'm really excited to see what I can accomplish in it.