My current plan is to write my text editor in REALbasic.
I like REALbasic. The language is easy to learn, easy to write, and easy to read. The REALbasic IDE provides lots of pre-built controls for building your program’s user interface, but you can also create your own controls from the ground up. If you have the Professional version of REALbasic, you can write your program once and use it to build executables for Windows, Mac OS X, and Linux all at once. And if some part of your program should prove to be unacceptably slow, you have the option of writing a REALbasic plugin in C++ to speed things up.
What’s good about REALbasic?
There is a lot to like about this language.
- The language is easy to pick up. It’s BASIC, after all.
- The language is object-oriented. You can create your own classes, or subclasses of existing classes. You can define interfaces as in Java and then create classes that implement those interfaces.
- Objects are reference-counted and are deallocated automatically when no other object points to them.
- Some of the features the language has include:
- Basic data types: Integer, Single, Double, Boolean, Color, Date, Currency, String, Array, Variant, Dictionary (actually a hash table), MemoryBlock. REALbasic has many functions for dealing with variables of each type.
- Low-level data types for working with binary files or C functions in a library or the operating system: Int8, Int16, Int32, Int64; UInt8 (Byte), UInt16, UInt32, UInt64; Ptr; CString, PString, WString.
- Literal syntax not only for hexadecimal (&hFF), binary (&b11101101), and octal (&o137) numbers, but also for colors (&cFF6F00 for orange) and Unicode codepoints (&u2014 for an em dash).
- Delegates are essentially typesafe function pointers. A Delegate can point at any function (or object method) with a specific list of argument types and a specific return type — for example, any function with a first argument “As Integer”, a second argument “As String”, and no other arguments, and that returns a Boolean. You can use these at runtime and change what your program does in response to a keystroke or a button press.
- Support for exceptions. You can define your own exception classes, use the Raise statement to throw an exception, and Try…Catch…Finally to catch and handle exceptions.
- Declare lets you call subroutines or functions in DLLs (on Windows) or shared libraries (on Mac OS X or Linux).
- Assigns lets you set up a Sub to be called with “theSub(a, b) = c” instead of “theSub(a, b, c)”.
- Extends lets you set up a Sub or Function to be called with “a.theSub(b, c)” instead of theSub(a, b, c)”.
- #If…#Endif allows conditional compilation. This is most useful for allowing or “commenting out” code depending on whether (1) a constant is defined, or (2) the running within the IDE, or (3) the application is running on Windows or the Mac or Linux.
- The IDE lets you build your GUI by dragging controls onto a window and setting their properties, just as Visual Basic does.
- If the controls supplied with REALbasic don’t do what you want, you can subclass an existing control and write event handlers to change how it works, or you can even subclass the Canvas control and create your own custom control from the ground up.
- REALbasic comes with classes for all sorts of things — standard dialog boxes (for picking folders, files, or colors), regular expressions, XML, databases, shell commands, graphics (lines, shapes, text), networking (including sending data to and receiving data from websites), conversion between text encodings, cooperative (not pre-emptive) threads, sound, editing video (via QuickTime), etc.
- There is even a command to make the computer speak the text you pass to it. (This works on Windows and on the Mac, but not on Linux.)
- RBscript is a scaled-down version of REALbasic that you can compile into your application so that users can run scripts. Even better, these scripts are compiled, not interpreted, before being run.
- REALbasic (the Professional edition of it at any rate) is cross-platform — you can build applications for Windows, for Mac OS X, and for Linux from a single project file.
- REALbasic code is compiled into native machine code, not interpreted.
- You don’t have to pay any royalties for distributing your applications.
- REALbasic Personal Edition for Linux is free. If you have a Linux machine, you can write and test REALbasic code on it and not pay a cent to REAL Software until you’re ready to build executables for Windows or the Mac.
- If the code that REALbasic produces isn’t fast enough, you can write a plugin for REALbasic in C++ containing code to alter the contents of your REALbasic objects.
- Many developers have developed their own plugins and controls and offer them either for sale or free of charge.
What’s bad about REALbasic?
There are some drawbacks to REALbasic, though none of these are showstoppers for me personally.
- Every version of REALbasic other than the Personal Edition for Linux is commercial software. If you want to compile for any platform other than Linux, you have to pay up.
- REALbasic’s IDE can be constraining at times. You can only see one function or one class method in the IDE at a time. People accustomed to seeing two or more function definitions at once in a text editor may chafe at this.
- REALbasic’s controls reflect the lowest common denominator of the equivalent controls on the three platforms. For example, REALbasic offers a TextArea for letting the user edit styled text, but the TextArea does not have built-in undo; you have to supply that.
- REALbasic’s executables are large. A do-nothing GUI application is around 1.5MB because REALbasic compiles a large part of the runtime framework into the application. Even a do-nothing console application is about a megabyte in size.
- REALbasic does not support Cocoa (although a new release that does support Cocoa is supposed to be released by the end of the year), so any Mac OS X application built with REALbasic right now relies on Carbon. (This is one reason why developers who develop only for the Mac often prefer Objective-C and Xcode over REALbasic.)
- REALbasic currently produces only 32-bit code, not 64-bit code.
- Documentation for the plugin API is spotty, and actually writing the plugin appears to be something of a dark art. (I might try gathering this information and writing up a how-to on building a plugin with gcc in a later post.)
- REAL Software sometimes adds new features to REALbasic and releases them before they are ready. (The latest release, 2009R4, has new report-building functionality that is apparently not yet ready for prime time.)
Good enough
Every programming language and package involves tradeoffs. REALbasic, like every other programming language, has its good points and its bad points. I like its good points and I can live with its bad points, so I’m going with REALbasic.
Links
- Markus Winter gives his take on REALbasic.
- Thomas Tempelmann warns those new to REALbasic about some annoyances to watch for.
- Many developers who develop only for the Mac prefer Cocoa and XCode over REALbasic.