|
By Ifi Okoye, October 2006
|
|
|
Solaris OS and Sun Studio Software Can Help Students Program With C on UNIX
No matter how odd and worrisome it is to program in C, the truth is that most operating system programs are written in C, as are programs used in optimizing for performance in the operating system. C and C++ are still basic languages in which Computer Science students are expected to be reasonably proficient. Also, the job postings on craigslist, Monster, and specific company sites, usually list the ability to program in C/C++ as part of their requirements for a candidate with a Computer Science degree.
It is common knowledge that students and new programmers have to make a leap to program in C on a UNIX system. A large part of this leap is learning how to program from the command line. There is the belief, and a salient one, that UNIX programmers should be able to use the command line to do their work. The power of the command line lies in being able to make it do different things by specifying different options. This takes a lot of time.
Applied technology is something that is meant to make life easier or better. So, if a tool can apply this power of the command line, it should be applauded for making life easier for programmers. This is what the Solaris OS and Sun Studio software have done. These products together have eliminated the hassle that comes with using the command line to program and have made it easier for programmers to write C code on UNIX systems.
Creating and Editing Source Code
When I learned how to program on UNIX systems, which was about two years ago, one of the steps I went through was learning how to use a powerful editor such as vi. No matter what level of programming you are at now, think back to when you learned vi, and you'll no doubt agree that the learning curve is steep. I was ecstatic when I discovered the Sun Studio compilers came with a graphical user interface. With the Sun Studio IDE, creating and editing a source file is now intuitive. I started the GUI and went to File->New to create a new source file.
I didn't need to scroll through a 15 page-long man page to understand how to create and edit source files. Here's another example showing the use of File-New.
And here is a screen capture of the New Wizard with the C templates.
Creating a Makefile
Searching for "makefile tutorial" on Google returns over a million hits, showing just how much emphasis is put into learning how to create a makefile on UNIX.
The first time I was told to submit a makefile in school as part of a C program I wrote, I panicked. All the code I had written before then was for simple programs, and the time it took to compile was never an issue. However, with a program that simulated an operating system, compilation time was definitely a metric in grading.
Makefiles are useful because they tell the compiler how to compile the code. Makefiles ensure that when you change a line or section of code in one file, only the edited file gets recompiled, saving compile time. Sun Studio software automates the creation of a makefile, thereby further reducing the difficulty associated with programming on UNIX using C. With the Makefile Wizard, you can specify which compiler you want the makefile to use in building your code, either Sun's CC compiler or GNU's GCC compiler (see the following screenshot). You even get to choose if you want to compile the code for the Solaris OS or a Linux platform.
Debugging
As a new programmer, due to uncertainty about when and how to use the debugger from the command line, I resorted to using print statements to trace C code. While this works for simple programs, it is tedious, increases runtime because of unnecessary I/O, and could introduce errors into a program that is error-free. For debugging code, the debugger seemed like a tool for advanced students. But with Sun Studio software, debugging a C program using the dbx debugger in the IDE is really rudimentary. It's as easy as Debug->Load Program, Debug->Continue. Here is a screenshot of Debug->Load Program.
And here is an example of Debug->Continue.
Different sub-windows show you the call stack, local variables, break points, watches, and their values at each step of the program.
Summary
The Sun Studio IDE, the GUI for the free Sun Studio compilers and tools, makes it easy for students to program on UNIX. This takes away the urgency of memorizing commands and continually searching the man pages, and instead refocuses the students on enhancing their programming skills. Memorizing commands and their options, or leafing through man pages, is par for the course, but having a GUI makes the journey much, much easier.
I think the Solaris OS is an ideal platform choice for helping students make the leap to programming on UNIX systems: Apart from offering the Sun Studio compilers, which are free, it also supports the usage of GNU'S GCC compiler. This can make programmers who are accustomed to compiling for Linux platforms comfortable with compiling on a UNIX platform.
|