The Best of Comp.Lang.Smalltalk: Two New Smalltalks
Total Page:16
File Type:pdf, Size:1020Kb
The Best of comp.lang.smalltalk Alan Knight Two New Smalltalks malltalk is a very loose term. While there are some still won’t run as quickly as compiled code (you have to clear, defining characteristics, there are also many spend CPU cycles to translate, and you can’t afford to think Svariations as well. This is important because software too hard about optimization). Finally, it requires a VM to development is a large field, with different solutions do the translating, which makes it more difficult to create appropriate to different problems. This article will discuss standalone executables, DLLs, and callback functions. some of these possible variations, with reference to two Smalltalk MT is fully compiled, and has “an optimizing promising new implementations. compiler that generates fast, compact code.” Full compi- The first of these new implementations is Object lation should give significantly better performance than Connect’s “Smalltalk MT,” a high-performance imple- existing implementations, and the absence of a VM allows mentation for Windows NT 4.0, with full compilation and simple programs to be very small indeed. MT claims to be true multithreading. The second is Intuitive Systems’ able to make DLLs (which, to my knowledge, no existing “Dolphin Smalltalk,” which boasts a low cost and a very Smalltalk can do), and to fit a trivial windows application low memory footprint. into a 100K executable (their runtime-support DLL adds Neither one has been officially released yet, but free only 52K). prerelease copies are available for download from their Dolphin Smalltalk is bytecode interpreted. I would Web sites (see contact information at the end). Even if expect this to offer significantly slower performance than you’ve missed the free periods, both companies are aiming current implementations, but with much lower space at product prices in the low hundreds (of U.S.) dollars. consumption, even for significant-sized applications. The Note that I looked at prerelease versions, and that I’ve company states that it “will be producing an optional JIT only played with them, so all I can do is relay first impres- in future.” When space is more important than speed, this sions and generalities about their implementation choic- is a very reasonable option, and this is often true in es. I hope you’ll see a full review in these pages once they applets. The firm also says it will shortly have its VM are officially released. encapsulated as an ActiveX downloadable. COMPILATION SIZE Most current Smalltalks use dynamic compilation, now Both companies advertise their ability to make very small commonly referred to as Just-In-Time (JIT) compilation. executables. Traditionally this has been a weak area for This is an example of a process I call “cross-domain buzz- Smalltalk. In many of the application areas for which word hybridization.” In this process, a recognized buzz- Smalltalk is used, one can argue that size doesn’t matter as word from one domain crosses over to another, where it long as it does the job. But with the growing importance of attaches to a concept almost, but not quite, entirely small applets over monolithic applications, size is becom- unlike the original. If you don’t like it, think of it as pay- ing more significant. back for the term “object-oriented.” Dolphin’s approach to minimizing size uses bytecod- In dynamic compilation, the methods are stored in ing and a very small interpreter (I counted 155K including bytecode form. At runtime, some (or all) of these byte- all the DLLs) with a relatively standard (but small) image. codes are translated into machine code. This can provide Their prerelease packaging support wasn’t very sophisti- most of the speed of machine code with a much smaller cated, but when a development image starts at only 1.4 executable size, comparable to that of bytecodes. MB a good stripper is more of a luxury. Although this is a good approach, it’s not a perfect solu- Smalltalk MT can provide extremely small sizes for tion for every circumstance. It takes more space than byte- simple programs, but for larger programs the space cost codes (you now have to store both compiled forms) and of full compilation becomes significant. The firm tries to combat this through modular class libraries and a mini- Alan Knight is a Smalltalk guru with The Object People. He can be malist framework. reached by email as [email protected], or at 613. 225. 8812. The typical Smalltalk programmer doesn’t think too 22 http://www.sigs.com The Smalltalk Report much before using something that’s in the development THREADS image. This is nice for development but bad for packag- One of the most innovative features of Smalltalk MT is its ing. Everything depends on everything else, and all you full support for operating system threads (“true” multi- can do is remove the compiler and development tools. threading). Making a decent compiler isn’t that hard, but MT claims to have kept the base classes small and mod- there are many issues involved in making Smalltalk use ular, so if you don’t use a particular class or subsystem it OS threads. The only other implementation I know of is can easily be removed. They also claim to have a sophis- OTI’s embedded systems implementation, and it only ticated packager, though I’m skeptical. Packaging is a dif- supports threads for real-time operating systems. ficult problem. I figure their base image, including the I believe OS threads are often given too much impor- compiler and development DLLs, is 1.3 MB. “Image gen- tance. For 90% of applications, the standard Smalltalk eration is largely automatic. An Image Builder com- process model will suffice, along with the ability to make putes the set of referenced classes and methods, start- system calls without blocking. The critical issue is that ing with the image-entry point.” when one Smalltalk process waits on a system service, the MT has also minimized the size of the runtime by stick- entire Smalltalk system should not wait. Given this capa- ing very close to the OS functionality. bility, which most implementations provide, it’s not diffi- “All GUI and operating system-related classes present cult to render demanding applications like Web or termi- a Win32-like protocol. This ensures that applications nal servers, and you don’t have to deal with the addition- run with minimum overhead on the Windows family of al complexities of OS threads. With the Smalltalk model operating systems, and leverage you can even have thread-manipu- on existing know-how.” Smalltalk is a very loose term. lating code that’s portable between operating systems. FRAMEWORKS While there are some clear, That’s a very good solution when it A Win32-like protocol for window- defining characteristics, there works, but there are times when you ing is definitely a two-edged feature. really need OS threads. One example is It makes Windows programmers are also many variations as symmetric multiprocessing (SMP). who have programmed in other well. Operating systems that support multi- languages feel right at home, and it ple CPUs in one machine can map OS minimizes the amount of code you need to map a threads to different processors, but not Smalltalk processes. Smalltalk framework onto the operating system. I think Presently, this affects only very high-end machines, but it will there’s no question that this reduces the amount of code in become more and more important in the future. the image. Given that there are lots of implementations out there On the other hand, frameworks that are written with with the standard threading model, the choice of using OS C or C++ in mind look really ugly compared to those threads in Smalltalk MT is a very welcome one indeed. designed for Smalltalk. Look at Visual Smalltalk vs. IBM. Visual Smalltalk has tight integration with Windows, to PLATFORMS AND PRICE the point where you can implement your own wm:what- By now I ‘ll bet you are impatient to get your own copy of ever: messages, but provides a very clean, simple, either or both of these implementations for your favorite Smalltalk-like framework above that. IBM has its platform. Unless you’re a Microsoft fan you’re out of luck. X/Motif layer, which translates into calls to the real OS. It Both of these implementations have opted away from works very well, and it’s extremely portable, but it’s way portability in favor of close integration with Win32. In fact, too close to C programming for my taste. IBM’s saving the first version of Smalltalk MT runs only on Windows NT grace is that with VisualAge or WindowBuilder you rarely 4.0 due to problems with Win95’s threads, but they expect have to descend to that level. Smalltalk MT doesn’t to have a Windows 95 version soon . appear to have a GUI builder. On the other hand, I’m Dolphin Smalltalk has gotten more attention on the sure there are lots of people using C/C++ for whom a Net, because it can also run on older versions of NT and Win32-like framework in Smalltalk (especially a Windows 95. Don’t expect them to expand their list of Smalltalk that can produce fast, compact executables) platforms too much. In response to a number of calls for would be a big step up. an OS/2 version, Andy Bower of Dolphin’s support group Dolphin Smalltalk, in contrast, uses MVC. This is the ([email protected]) wrote: oldest and best known of the Smalltalk frameworks, and “The initial design aims for Dolphin were firmly has been passed down from PARC into VisualWorks.