Linux Tips #1



---------------------------------------------------------------

If you like Tip of the Day please share it with friends and 
co-workers, and encourage them to sign up! It's free. You can
unsubscribe or change your e-mail address at any time.

To subscribe to or unsubscribe from this newsletter:
* Use your browser to visit our Newsletter Subscription Center:
  http://www.winmag.com/subscribe/
* Scroll down to the Tip of the Day section.
* Click "Choose an option," and select Subscribe or Unsubscribe.
* Scroll to the top of the page, and type your e-mail address 
  in the "E-mail" field.
* Click the Submit button below your e-mail address.

Copyright 2000 CMP Media Inc. A service of Winmag.com.
http://www.winmag.com/

Distributed by MessageMedia Inc. - http://www.messagemedia.com

---------------------------------------------------------------


*1.   MAKE                 
        
Many programmers, having used only GUI project managers, have
 never had to cope with a make file. Make files can be very
 simple or extraordinarily complex (and thus use automake to
 manage the make process). 

Make is the utility that is used to control the compilation of a
 program via a make file. While not, strictly speaking, a
 necessity--since each piece can be hand-compiled and the lot of
 the pieces all put together--make files are a practical
 necessity to getting consistent and quick results.

The current stable version of make is 3.77. You can find the
 online make manual can be found at 

http://www.gnu.org/manual/make/html_mono/make.html


*2.   PORTABILITY                 
        
So many Linux systems are x86-based that programmers sometimes
 forget about issues that make code nonportable--for example,
 byte-ordering. Systems are either little-endian (x86) or
 big-endian (PowerPC)--or byte-aligned, which differs between
 32-bit processors, not to mention the 64-bit processors such as
 the Alpha. If you don't account for these issues, data files
 will not be shareable among the various Linux programs. Some
 programs, erroneously relying on one ordering over another,
 may not work at all. 

Furthermore, one of the benefits of programming in Linux is that
 porting from Linux to almost any other Unix is relatively
 simple. Thus, consider the possibility that you may be running
 under another flavor of Unix some day and may wish that you had
 started with a portable system. It's easier to start out right
 than it is to fix later. 

For some commentary on portability, see 

http://www.gnu.org/prep/standards.html#SEC22


*3.   FINDING DIFFERENCES                 
        
Often, you might need to know the differences between what you
 changed two days ago and today. Or between two slightly
 different implementations. Several GNU utilities will help solve
 all these issues. 

"diff" finds the differences between two files. 
"diff3" finds the differences between one source file and two
        alternate versions. 
"cmp" will show the characters that differ between the files. 
Diff is most frequently used to generate files that are an input
     to patch. 

For more information on these utilities, see 

http://www.gnu.org/manual/diffutils/html_mono/diff.html


*4. PATCHING UP PROBLEMS                 
        
If you keep current on Linux kernels, you will be familiar with
 patch iles. Essentially, a patch file is a listing of the
 differences between the prior version of a file and the new
 version you'd like to have. This file is generated by diff and,
 when executed by the program patch, will make the existing
 version of a file into a new version. You will then have what is
 identical to downloading a whole new version. 

Patch files are popular for two major reasons: 
1. they conserve bandwidth and therefore time for the end user 
2. they log the changes from version to version and thus can be
   useful for developers 

There are several patch utilities, including the GNU utility 

http://www.gnu.org/software/patch/patch.html


*5. NCURSES                 
        
Very often, an X-based interface is overkill, particularly for a
 small utility that might be used across a network where X
 security can be an issue. Thus, character graphics in a console
 window might be an appropriate user interface. 

The most common library for this is called ncurses. The main page
 for ncurses information can be found at 

http://www.clark.net/pub/dickey/ncurses/ncurses.faq.html 

While the classic ncurses programming is performed in C, some
 languages, including Python, have curses bindings: 

http://www.python.org/doc/howto/curses/


*6. GUI TOOLKITS: LESSTIF                 
        
LessTif is a free implementation of Motif, the classic GUI
 toolkit for building X applications. Since it is
 Motif-compatible, and since Motif is installed on many
 commercial Unix systems, LessTif gives ready cross-Unix GUI
 capability. While the Linux trend is to use either Gnome or Qt
 as a toolkit (covered in other tips), LessTif has
 been overlooked. 

In part, LessTif is overlooked because it is a relatively new
 project, and early versions weren't as stable as they should
 have been. This issue has largely been resolved, and many
 programmers use LessTif without problems. 

Some of the features of the full Motif have not yet been
 implemented, but LessTif is still worth a look: See 

http://www.lesstif.org


*7. GUI TOOLKITS: Tk                 
        
Tk is the GUI toolkit half of Tcl/Tk. (The first half is a
 scripting language, pronounced "tickle.") Tcl/Tk is portable
 across more platforms than anything else including all Unixes,
 Windows, and the MacOS. 

Tk can be used somewhat independently of Tcl; both Perl and
 Python have Tk bindings and can be used to make GUI Tk
 applications. Several books about using Tcl and Tcl/Tk have
 been published. 

Scriptics, the company that ships Tcl/Tk, offers an impressive
 variety of resources, including training, at 

http://www.scriptics.com


*8. PROLOG                 
        
Many times, students are taught that there are the functional
 languages (like Lisp and ML) and the imperative (procedural)
 languages like C and Pascal--neatly skipping over the
 logic-programming languages such as Prolog that handle
 rules-based programming for things such as expert systems. 

The best site for learning more about Prolog programming can
 be found at 

http://kti.ms.mff.cuni.cz/~bartak/prolog/index.html


*9. GUI TOOLKITS: Qt                 
        
Qt is a C++ based GUI application framework that can be used to
 generate both X and Windows applications. It is used as the
 underlying framework for KDE, one of the popular desktop
 environments for Linux. It will also be used as the underlying
 framework for the Linux version of Opera, a popular lightweight
 Web browser on Windows. 

Those who prefer C++ will find Qt's C++-based mature framework a
 distinct advantage. Qt comes in both free and non-free versions,
 depending on your ultimate goals and platform. 

O'Reilly & Associates 

http://www.ora.com 

has published a book on developing with Qt; however, it is not
 yet available in the United States. More information on Qt can
 be found at 

http://www.troll.no


*10. GUI TOOLKITS: Gtk+                 
        
Gtk+ is the Gimp Toolkit, initially written for the graphics
 program Gimp 

http://www.gimp.org 

In part, the libraries were written in response to Qt's
 licensing, which many Linux developers were unhappy about. Qt's
 licensing has since changed. 

Qt and Gtk+ are the two most popular application frameworks for
 new development on Linux. More information about Gtk+ and
 explanations on learning to code with it can be found at 

http://www.gtk.org
