Real Programmers Use Pascal(转自borland.com)
by Ray Lischner, author of Delphi in a Nutshell
In case you haven't heard the news yet, Borland is porting their landmark Delphi product to Linux. To many professional programmers, this is wonderful news. Earlier, you may have read Kylix is Coming!, in which I introduced the Kylix project and described it in general terms. Now that Borland has revealed more information about Kylix, I can give you more details.
Delphi is a rapid application development (RAD) environment, powered by a modern, object-oriented programming language and an extensible, component-based architecture. Currently, all this power is available only on Windows, where it is successfully being used in games, development tools, desktop applications, and used to drive web sites and connect multi-tier database systems. This article takes a closer look at Delphi for Linux and its companion product, C++ Builder for Linux.
Kylix is Borland's code name for a large project that involves porting Delphi and C++ Builder to Linux, working with tool and component builders to make sure third-party support is in place when the products ship, and getting the word out that rapid application development is coming to Linux.
Kylix isn't for everyone, though.
For one thing, the main programming language is Delphi Pascal. Just the name Pascal sends many programmers scurrying for the exits. But don't be too hasty. This is not your father's Pascal. A far cry from traditional Pascal, Delphi has a number of modern conveniences, such as:
Object-orientation (single inheritance of classes, multiple inheritance of interfaces, single root class)
Integer overflow checking
Array bounds checking
ANSI and Unicode strings
Runtime type information
Unit-based modular programming
Static or dynamic linking of units
Strongly typed, except when you need latent type checking, which comes in the form of the Variant type
Multithreading support (TThread class, synchronization, thread-local storage)
Arithmetic operator overloading
Fast, optimizing, native compiler
In other words, Delphi has everything a programmer needs for modern software development (with one exception--generic types--but no language is perfect).
Rapid Application Development
The Kylix package contains more than just a souped up Pascal compiler, though. The integrated development environment (IDE) supports rapid application development, which means:
Visual design of forms (windows and dialog boxes)
Visual design of menus
Extensible, component-based framework
Rich assortment of visual controls and widgets
Components to integrate with many popular SQL databases
Components for many popular Internet protocols
Commercial and freeware third-party components
Extensible design-time tools for creating:
Simple or complex database applications
Commercial and freeware third-party tools
No need to learn a separate extension or scripting language
Still not convinced? That's okay. As I wrote earlier, Kylix is not for everyone.
Don't use Kylix if:
You like to get your hands dirty in the code. If you don't want to click and drag a component, but would rather write a few hundred or thousand lines of code yourself, you probably won't like Kylix.
You need to write kernel modules. Kylix does not support the GNU extensions that the Linux kernel depends on. (In particular, Kylix has a different syntax for writing inline assembly language.)
You are writing intensive numerical code. Kylix has an optimizing compiler, but it doesn't optimize floating-point arithmetic.
You have all the free time in the world to spend banging out code.
What Is RAD?
Now you know what Kylix isn't good for. What use is it? Rapid application development means just that--writing applications quickly and effectively.
Applications can be desktop tools, from games to word processors. They can be database clients, servers, or middle-tier layers. They can be network clients such as email readers, or network servers such as web servers.
The "rapid" part of the description means you can use Kylix to write applications faster than you could with traditional tools, such as gcc, emacs, vi, and gdb.
The first part of being rapid is the ability to design forms (windows and dialog boxes) visually. Click on a component, drop it on a form. Select a component and modify its properties. These features are commonplace, and you can find them in Glade, KDevelop, and other tools, so it's no surprise to find this feature in Kylix.
Kylix is much more than a mere GUI-builder, though. It uses an extensible, component-based framework for widgets, database components, network components, and more. The framework is called CLX (component library for cross-platform, pronounced "kliks"). CLX is easily extensible. Already, third-party developers are writing components to supplement the standard components. Writing your own component can be as easy as deriving a new class from an existing component.
CLX comes in several parts:
BaseCLX contains the core parts of the component framework. Included are some simple collection classes (array-based lists), string-manipulation, I/O, date and time functions, file management, exception-handling, and more.
VisualCLX uses Qt , TrollTech's GUI toolkit, for graphics and visual controls. (Borland has negotiated a limited license with TrollTech, so if you purchase Kylix, you have a royalty-free license to use parts of Qt in freeware, shareware, and commercial products. You do not need to pay any additional fees to TrollTech for use of Borland-licensed Qt technology.)
DataCLX uses Borland's dbExpress to connect to a wide variety of SQL databases, including Interbase (which is now an Open Source product) and mySQL. You can use DataCLX in a single-tier architecture (database and application on the same machine), client/server, or multi-tier architecture.
NetCLX provides components for common Internet protocols, from direct socket access to TCP to FTP to HTTP. Write clients and servers, including Apache modules.
Because CLX is extensible, there will be a variety of components from third-parties. Several web sites (such as Delphi Super Page, and Torry's Delphi Pages ) host thousands of components that can be added to Delphi for Windows, and we can expect similar abundance of components after Kylix ships. Third-party tool and component vendors are already working with early releases of Kylix to get their components ready.
Components are convenient for many uses. For example, you can drop a POP3 Client component on a form, add a tree widget to display a hierarchy of folders, a list widget to display messages in a folder, and a text area to display a single message. To hook up these components, you add event handlers, which are just methods (member functions) declared in the form's class. Some event handlers are simple, such as the tree widget's OnChange handler, which looks up the selected folder, retrieves all the messages to display in the list widget. Because you have the full, object-oriented power of Delphi or C++ at your disposal, you can make the event handlers as simple or complicated as you want.
In less than a day, you can have a basic, but fully functional email client.
RAD has a bad rap in some circles because of tools that allow you to rapidly build extremely limited applications. The authors advertise that you can build applications with point-and-click ease without writing much code. We all know that real programming problems require real code.
What makes Kylix RAD especially powerful is that the CLX component framework simplifies the tedious aspects of application development, without hiding the power of the language and operating system. If you need to make system calls directly, you can.
Instead of wasting your time writing code to manage windows and widgets, you supply the guts of the application: business logic, computation, organization, or what have you. Kylix is designed for large and small applications. When writing code, the source editor helps you in many ways:
Color-coded syntax highlighting shows you reserved keywords, unbalanced strings or comments, and so on.
Can't remember a function name? Start typing, and the source editor shows you a list of names to choose from.
Can't remember the function parameters? The source editor tells you the names and types of the parameters.
Source file too big to find things? The Code Explorer shows all the classes, subroutines, types, and other declarations in the file, making it easier to navigate large files.
Where is this declared? Select an identifier and jump directly to its declaration, even if it is declared in a different file. You can also find all uses of a declaration within a project.
Even if the source editor is missing a feature that you want or need, you can extend the editor and other parts of the IDE.
Sometimes, though, you need more power than a component can provide. Kylix has an extensible IDE so you can add new design tools. For example, a menu bar is a component, as is a popup menu. These components, in turn, contain menu item components. Editing components is a poor way to design menus, so Kylix has an interactive menu editor that makes is easy to edit menus visually. Kylix also comes with wizards (as these tools are called) for designing database applications, web server modules, and more. Because the IDE is extensible, third-party developers are working on additional wizards, and you can write your own.
Some tools require you to learn a special extension language (such as Emacs Lisp). In Kylix, though, you can continue to use your everyday development language. Extend the Delphi IDE using Delphi or C++ Builder using C++. You can even extend Delphi with a wizard written in C++ Builder or vice versa, so third-party developers can use their language of choice and distribute their products to all Kylix users.
You can extend the IDE in several ways. You can:
add design windows, like the menu editor;
add menu items to the main menu bar and to the various popup menus in the source editor, form editor, and so on;
add items to the tool bars;
add form and project designers that build new forms, projects, or other files based on user-interaction;
customize key bindings (although this feature is more difficult than it should be);
interface with the debugger, form and source editors, and more.
On the other hand, if you prefer command line tools; if you don't want the convenience of a WYSIWYG form editor; if you like the challenge of locating and debugging buffer overruns; then by all means, continue to use your current tools. You wouldn't be happy with Delphi.
Real Programmers use Pascal, but sometimes you need or prefer C++, so Kylix will include C++ Builder for Linux. C++ Builder uses the same IDE and component framework as Delphi, but with the C++ language. To use the Delphi component framework, you must use Borland-specific extensions to the C++ language. Note that C++ Builder does not support GNU extensions, so don't try to recompile the Linux kernel with C++ Builder.
If you prefer standards, C++ Builder can compile ISO standard C++ and C, too. You can compile any application that adheres to the ANSI/ISO standards, and you will probably find that C++ Builder for Linux compiles faster than gcc or g++. You also get the advantage of an extensible syntax-directed editor and an integrated debugger, even if you don't take advantage of CLX and the interactive form builder, menu builder, and other RAD tools.
Linux and Cross-platform
Kylix will produce native x86 code, producing standard ELF binaries (programs and shared objects). No byte-code, no virtual machine, no runtime library, no Windows emulator needed.
The first release of Kylix will not support other hardware platforms. You will be able to link gcc-compiled object files into a Delphi project, but g++ classes are not binary compatible with Delphi or C++ Builder. Future releases will probably support additional hardware platforms, as the market dictates. Perhaps we will see Delphi and C++ Builder on other operating systems, too.
CLX is portable between Linux and Windows, and is designed to support other platforms in the future. Thus, Delphi 6 for Windows will also support CLX (in addition to its native Windows component library, the VCL). Your source code can be ported without change between Linux and Windows, provided you avoid system-specific functions (or you can use conditional compilation).
Borland is firmly committed to remaining neutral when it comes to desktops and distributions. Naturally, they want you to use Kylix regardless of whether you prefer Red Hat, Mandrake, Caldera, Slackware, SuSE, or what have you, or whether you use KDE , GNOME, or just plain old fvwm. The development tool should not dictate end-user decisions. That said, the first release will favor KDE slightly because Kylix and KDE both use Qt . Kylix applications will run on GNOME, but will not take full advantage of GNOME-specific features. You can expect future releases to provide better support for GNOME.
The core Delphi Pascal language will not change significantly in Kylix, nor will Borland's C++ extensions. Most of the reference material in Delphi in a Nutshell will apply equally to Windows and Linux, except for a few Windows-specific features. I will post any language changes posted to oreilly.com.
How Kylix Will Save the World
Or not. Linux currently faces three significant hurdles against wide-spread acceptance as a desktop operating system: ease of installation, ease of use, and availability of applications. Kylix can't help with the first, but it can with the next two.
Why do I use Windows to read my email? Why am I writing this column under Windows? The simple reality is that many applications are available only under Windows. I've tried many email and news clients on Linux, but I prefer my Windows-based application (Agent, if you must know). I've tried numerous HTML editors, but I prefer Visual Page for Windows. One of the difficulties facing Linux application developers is that Linux lacks tools for producing high quality desktop applications.
If you want to throw together a quick and dirty interface, you can use Tcl/tk. If you need more programming guts behind the interface, switch to Python and Tk. If you need the performance of a natively compiled application, though, you must resort to C or C++. Sure, you have some toolkits, such as Qt and Jx. These toolkits even have basic IDEs. Kylix has all that and more.
Borland expects to deliver Kylix sometime in 2000. When Kylix ships, its feature list will read like the to-do list for other Linux RAD tools. For professional developers and many others, Kylix will be a valuable addition to the suite of development tools on Linux. Not everyone will want to use Kylix, and not everyone should. But if you value your time, if you want to use cutting-edge tools, if you want to make your mark in the Linux application space, you should take a close look at Kylix.
Post your responses to this article here,
or read what others have to say!
Ray Lischner is well-known in the Delphi community as an author and speaker. He wrote Delphi in a Nutshell, Secrets of Delphi 2, Hidden Paths of Delphi3, and numerous articles for Delphi Informant, Dr. Dobb's Journal and other magazines. His conference appearances include the annual Borland/Inprise conference, and he has spoken to Delphi users' groups across the country. He also wrote Shakespeare for Dummies. You can reach Ray at email@example.com.