- •About the Author
- •Dedication
- •Author’s Acknowledgments
- •Contents at a Glance
- •Table of Contents
- •Introduction
- •Who Should Buy This Book
- •How This Book Is Organized
- •Part I: Programming a Computer
- •Part II: Learning Programming with Liberty BASIC
- •Part III: Advanced Programming with Liberty BASIC
- •Part VI: Internet Programming
- •Part VII: The Part of Tens
- •How to Use This Book
- •Foolish assumptions
- •Icons used in this book
- •Why Learn Computer Programming?
- •How Does a Computer Program Work?
- •What Do I Need to Know to Program a Computer?
- •The joy of assembly language
- •C: The portable assembler
- •High-level programming languages
- •Database programming languages
- •Scripting programming languages
- •The program’s users
- •The target computer
- •Prototyping
- •Choosing a programming language
- •Defining how the program should work
- •The Life Cycle of a Typical Program
- •The development cycle
- •The maintenance cycle
- •The upgrade cycle
- •Writing Programs in an Editor
- •Using a Compiler or an Interpreter
- •Compilers
- •Interpreters
- •P-code: A combination compiler and interpreter
- •So what do I use?
- •Squashing Bugs with a Debugger
- •Writing a Help File
- •Creating an Installation Program
- •Why Learn Liberty BASIC?
- •Liberty BASIC is easy
- •Liberty BASIC runs on Windows
- •You can start using Liberty BASIC today
- •Installing Liberty BASIC
- •Loading Liberty BASIC
- •Your First Liberty BASIC Program
- •Running a Liberty BASIC program
- •Saving a Liberty BASIC program
- •Getting Help Using Liberty BASIC
- •Exiting Liberty BASIC
- •Getting input
- •Displaying output
- •Sending Data to the Printer
- •Storing Data in Variables
- •Creating a variable
- •Assigning a value to a variable
- •Declaring your variables
- •Using Constants
- •Commenting Your Code
- •Using variables
- •Working with precedence
- •Using parentheses
- •Manipulating Strings
- •Declaring variables as strings
- •Smashing strings together
- •Counting the length of a string
- •Playing with UPPERCASE and lowercase
- •Trimming the front and back of a string
- •Inserting spaces
- •Yanking characters out of a string
- •Looking for a string inside another string
- •Using Boolean Expressions
- •Using variables in Boolean expressions
- •Using Boolean operators
- •Exploring IF THEN Statements
- •IF THEN ELSE statements
- •Working with SELECT CASE Statements
- •Checking a range of values
- •Checking a relational operator
- •Boolean expression inside the loop
- •Looping a Fixed Number of Times
- •Counting with different numbers
- •Counting in increments
- •Anatomy of a Computer Bug
- •Syntax Errors
- •Fun with Logic Errors
- •Stepping line by line
- •Tracing through your program
- •Designing a Window
- •Creating a new window
- •Defining the size and location of a window
- •Adding color to a window
- •Putting Controls in a Window
- •Creating a command button
- •Displaying text
- •Creating a check box
- •Creating a radio button
- •Creating text boxes
- •Creating list boxes
- •Creating combo boxes
- •Creating group boxes
- •Storing Stuff in Text Files
- •Creating a new text file
- •Putting stuff in a text file
- •Adding new stuff to an existing text file
- •Retrieving data from a text file
- •Creating a new binary file
- •Saving stuff in a binary file
- •Changing stuff in a binary file
- •Retrieving stuff from a binary file
- •Creating a Graphics Control
- •Using Turtle Graphics
- •Defining line thickness
- •Defining line colors
- •Drawing Circles
- •Drawing Boxes
- •Displaying Text
- •Making Sounds
- •Making a beeping noise
- •Playing WAV files
- •Passing Data by Value or by Reference
- •Using Functions
- •Defining a function
- •Passing data to a function
- •Calling a function
- •Exiting prematurely from a function
- •Using Subroutines
- •Defining a subroutine
- •Passing data to a subroutine
- •Calling a subroutine
- •Exiting prematurely from a subroutine
- •Writing Modular Programs
- •Introducing Structured Programming
- •Sequential instructions
- •Branching instructions
- •Looping instructions
- •Putting structured programming into practice
- •The Problem with Software
- •Ways to Make Programming Easier
- •Breaking Programs into Objects
- •How to use objects
- •How to create an object
- •Creating an object
- •Starting with a Pointer
- •Defining the parts of a linked list
- •Creating a linked list
- •Managing a linked list
- •Making Data Structures with Linked Lists
- •Stacks
- •Queues
- •Trees
- •Graphs
- •Creating a Record
- •Manipulating Data in Records
- •Storing data in a record
- •Retrieving data from a record
- •Using Records with Arrays
- •Making an Array
- •Making a Multidimensional Array
- •Creating Dynamic Arrays
- •Insertion Sort
- •Bubble Sort
- •Shell Sort
- •Quicksort
- •Sorting Algorithms
- •Searching Sequentially
- •Performing a Binary Search
- •Hashing
- •Searching by using a hash function
- •Dealing with collisions
- •Picking a Searching Algorithm
- •Choosing the Right Data Structure
- •Choosing the Right Algorithm
- •Put the condition most likely to be false first
- •Put the condition most likely to be true first
- •Clean out your loops
- •Use the correct data types
- •Using a Faster Language
- •Optimizing Your Compiler
- •Programming Computer Games
- •Creating Computer Animation
- •Making (And Breaking) Encryption
- •Internet Programming
- •Fighting Computer Viruses and Worms
- •Hacking for Hire
- •Participating in an Open-Source Project
- •Niche-Market Programming
- •Teaching Others about Computers
- •Selling Your Own Software
- •Trying Commercial Compilers
- •Windows programming
- •Macintosh and Palm OS programming
- •Linux programming
- •Testing the Shareware and
- •BASIC compilers
- •C/C++ and Java compilers
- •Pascal compilers
- •Using a Proprietary Language
- •HyperCard
- •Revolution
- •PowerBuilder
- •Shopping by Mail Order
- •Getting Your Hands on Source Code
- •Joining a Local User Group
- •Frequenting Usenet Newsgroups
- •Playing Core War
- •Programming a Battling Robot
- •Toying with Lego Mindstorms
- •Index
- •End-User License Agreement
372 Part VII: The Part of Tens
real-life people — for example, at computer user groups in your area or Usenet newsgroups on the Internet.
To save you money, this chapter also points you to mail-order houses where you can find a wide variety of programming tools at steep discounts. If you get tired of practicing programming, this chapter also directs you to various programming games that you can play to sharpen your programming skills and have fun at the same time.
Just remember that no matter what language you use or where you find additional programming help, ultimately your own skills determine whether you finish your programming project on time and it works or is so buggy and unreliable that users abandon it.
Trying Commercial Compilers
The most important tool for any programmer is a language compiler. (See Chapter 4 for information on what a compiler does and why you’d want one.) Although you can find plenty of free language compilers, most programmers rely on commercial compilers that offer support and regular updates. Most commercial compilers cost several hundred dollars (which doesn’t matter if your company is paying for them), but you can often buy special beginner or standard editions of compilers that cost much less (typically ranging in price from $50 to $150).
Windows programming
Like it or not, Microsoft Windows is the dominant operating system on the planet (although Linux is quickly gaining momentum). If you plan to write a program to sell to people, the largest and most profitable market is the Windows market.
The standard language for writing Windows programs is Visual C++ .NET, which the friendly folks at Microsoft (at www.microsoft.com) produce. Despite the addition of the term “Visual,” Visual C++ .NET is a fairly complex C/C++ programming environment that even professional programmers have trouble mastering. Still, if you want to write Windows programs, you can’t go wrong by picking up a copy of Visual C++ .NET.
Despite the popularity of C++, the future for Windows programming lies in Microsoft’s newest language, C# (pronounced C-sharp). Their Visual C# .NET compiler combines the best features of C++ and Visual Basic to create a friendlier language that also protects you from making the majority of horrendous mistakes that plague C++ programs.
Chapter 27: Ten Additional Programming Resources 373
Because few people want to devote half their lives to learning the cryptic structure of C/C++ or C#, many programmers choose the second most popular programming tool: Visual Basic .NET.
Unlike Visual C++ .NET or Visual C# .NET, Visual Basic .NET is much easier to learn since the BASIC language more closely resembles English than C++ or C#. If you want to preserve your knowledge of Liberty BASIC, learning Visual Basic .NET is the next logical step in any programmer’s quest to dominate the programming world.
Because of the growing popularity of Java, you may want to take a look at JBuilder by Borland (at www.borland.com). Borland has a long history of providing quality programming tools and also sells two other popular rapidapplication development tools, C++Builder and Delphi. Like JBuilder, C++Builder and Delphi let you design the user interface visually, and then write code in either Java, Pascal, or C++ to make the program actually work.
A rapid-application development (RAD) tool enables you to build the user interface quickly. (For more information about RAD tools, see Chapter 2.)
If you have any interest in creating cross-platform applications (programs that can run on different operating systems such as Windows, Linux, and the Macintosh), a popular choice is Metrowerks CodeWarrior (at www. metrowerks.com). Unlike most of its competitors, such as Visual C++ .NET or C++ Builder, CodeWarrior runs on such different operating systems as Windows, Solaris, Linux, and the Macintosh, so you can (theoretically) copy
your source code from the Windows version of CodeWarrior to the Linux version of CodeWarrior and compile your program for another operating system with little or no modifications.
To help you choose the best compiler for your needs, Table 27-1 lists several popular Windows compilers.
Table 27-1 |
Popular Windows Compilers |
|
Compiler Name |
Language Used |
Web Site |
Visual C++ .NET |
C, C++ |
www.microsoft.com |
|
|
|
Visual Basic .NET |
BASIC |
www.microsoft.com |
|
|
|
Visual C# .NET |
C# |
www.microsoft.com |
|
|
|
CodeWarrior |
C, C++, Java |
www.metrowerks.com |
|
|
|
RealBasic |
BASIC |
www.realbasic.com |
|
|
|
(continued)
374 Part VII: The Part of Tens
Table 27-1 (continued)
Compiler Name |
Language Used |
Web Site |
JBuilder |
Java |
www.borland.com |
|
|
|
C++ Builder |
C, C++ |
www.borland.com |
|
|
|
Delphi |
Pascal |
www.borland.com |
|
|
|
Macintosh and Palm OS programming
The Macintosh easily maintains its reputation as one of the easiest computers in the world to use — and one of the hardest to program. Fortunately, the latest Macintosh programming tools make Macintosh programming much easier.
The premier Macintosh programming tool is CodeWarrior (which many often credit with saving the Macintosh, because it was the only reliable programming tool available at one time). CodeWarrior, by Metrowerks (at www.metrowerks.com), enables you to write programs in three different languages: C, C++, and Java. So rather than buy three separate compilers, you get everything that you need in one package.
Best of all, Metrowerks sells special versions of CodeWarrior so that you can write programs for Windows (including Windows 98/Me/NT/2000/XP and Windows CE), Solaris, Linux, Sony PlayStation game consoles, Nintendo game consoles, and the most popular handheld computer in the world, the Palm handheld computer. If you plan to write programs for the Macintosh, the Palm handheld, or game consoles such as Nintendo or Sony PlayStation, CodeWarrior is your first (and probably only) choice.
Of course, CodeWarrior doesn’t support BASIC, so if you want to program a
Macintosh by using BASIC, you have only two choices: Future Basic and
RealBasic.
Future Basic (at www.stazsoftware.com) closely resembles Liberty BASIC but runs entirely on the Macintosh.
RealBasic (at www.realbasic.com) is another BASIC programming language that closely resembles Visual Basic. As with Visual Basic, you can design the user interface of your program and then write BASIC code to make your program work.
RealBasic even goes one step farther and enables you to convert Visual Basic source code to run on the Macintosh. If you have any Visual Basic programs
Chapter 27: Ten Additional Programming Resources 375
that you need to turn into Macintosh programs, you can do so by using RealBasic.
Of course, converting Visual Basic programs into RealBasic isn’t 100 percent accurate, which means that you may need to modify the programs slightly. So if you really need to create both Macintosh and Windows programs, write your program in RealBasic and have RealBasic turn it into Macintosh and Windows programs at the same time.
Table 27-2 lists the most popular Macintosh compilers for writing programs for the Mac.
Table 27-2 |
Popular Macintosh Compilers |
|
Compiler Name |
Language Used |
Web Site |
CodeWarrior |
C, C++, Java |
www.metrowerks.com |
|
|
|
RealBasic |
BASIC |
www.realbasic.com |
|
|
|
Future Basic |
BASIC |
www.stazsoftware.com |
|
|
|
Linux programming
If any operating system can break the Microsoft stranglehold on the personal computer market, Linux looks like the best choice. Linux is surging in popularity, and many companies and programmers are quickly porting their programs to run under Linux.
Several commercial vendors have released Linux versions of their compilers (such as CodeWarrior, JBuilder, and Kylix, which is a Linux version of Delphi), but you may be pleased to know that Linux also offers a rich assortment of language compilers that you can use for free.
Depending on your version of Linux (RedHat, SUSE, or Debian, for example), you may already have a language compiler such as GNU C (a C language compiler) or EGCS (a C++ compiler).
Although Linux doesn’t offer as many popular applications as Windows or the Macintosh, plenty of Linux compilers are available for a variety of languages, including Ada, Pascal, FORTRAN, and BASIC. For more information about many popular Linux compilers, visit www.gnu.ai.mit.edu/ software/gcc/gcc.html.