GUI vs Console Programming

Programming differences between the command line and the GUI

© Guy Lecky-Thompson

Oct 5, 2006
PostIt, sxc.hu
Programming for a GUI is very different to programming for the command line, no matter what the operating system. This article hilights some of the issues.

Introduction

When starting a project, a programmer can be faced with a decision as to whether to proceed with a command line (console) project, or a GUI version. Depending on the GUI, and the tools available, the question is not always a straightforward one.

Nonetheless, for those who cannot even begin to answer this question, here are some differences between the two to help decide which path to follow. This can be important in helping a programmer select the right tools, or even help a learning programmer to select the right operating system and tools to start with.

Console Programming

Command line programming is easy, fast, and useful. It is most commonly used where an advanced user interface is not necessary, or where the target platform is not capable of displaying a GUI.

Also, back end web software for which the front end is rendered in HTML is also typically a collection of command line utilities. So, it does have it's uses, and if a programmer is writing software that falls into any of these categories, then the command line is the way to go.

enu Systems

However, the GUI does offer one clear advantage - the menu system. A drop down menu system is easy to use, and, more importantly, familiar. This is why there is such a large number of drop down menu Java Scripts available on the internet for use on web pages. Drop down menus, an integral and automatic part of the GUI are familiar.

The command line programmer has to use a series of category based menus:

  1. Enter data
  2. Process data
  3. Print Data
  4. Save Data
  5. Loaad Data
  6. Quit

The other alternative is to create a whole GUI, using basic text characters, in the command line environment. It is far more efficient to create native GUI software, but could be less portable, since each GUI (Windows, GTK+, MacOS, PalmOS etc.) has it's own special way of working.

Some cross-platform solutions exist, but they are beyond the scope of this discussion.

Mouse Control

The next principle difference is in the way that data is entered. The mouse is a key part of any GUI, and the command line environment does not have an equivalent. The cursor keys can be used to move around the screen, and since we are usually limited to 80 columns and 25 rows, thsi is not usually much of a drawback.

However, for menu selection, moving between fields during data entry, and HTML navigation, a mouse is very useful. If software requires a mouse, or if a mouse makes it more user-friendly, then the GUI is the way to go.

Widgets and Dialog Elements

Finally, most GUI imlementations come with widgets and dialog elements used to communicate information to the user, and allow interaction. They can be created in the command line environment, but it requires building a shell that is so close to the GUI, that it is often much less effort to just build the GUI version straight away.

A Notepad Clone for the Command Line

A good way to illustrate the key differences between the programming effort required to build an application in the command line as opposed to GUI environment is simply illustrated. Image creating a Notepad clone for the commad line.

A menu is needed, as is editing by moving around with the cursor keys. A buffer is required to store the text in, and navigation across pages (scrolling the whole text up or down) necessitates another buffer to store the screen state in.

All in all, thousands of lines of code will be spent in building the application.

A Notepad Clone for a GUI

A Windows Notepad clone, without file or printer handling, runs to about 150 lines of code. The menu handling is automatic. The actual editing area is a single widget, known as an edit control.

Adding file and printer handling will probably double the code required. Most of the code (80% up) is start-up and shut-down code required for all Windows programs.

A similar story can be told for any other GUI based programming environment.

Further Reading

The following articles will interest the reader who wishes to follow either programming paradigm for their next project:


The copyright of the article GUI vs Console Programming in Computer Programming is owned by Guy Lecky-Thompson. Permission to republish GUI vs Console Programming in print or online must be granted by the author in writing.




Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo