Since the performance of applications is pretty important on the BeBox, here are some hints that can save you time both during execution and when writing code.
The first thing you can do to slow the machine to a crawl is to use the View system. The application server keeps the exact clipping region for every view in a window up to date. When the number of views gets large, the clipping region for the view hierarchies can become very complex to maintain! Furthermore, when part of a window needs to be redrawn, the protocol between the server and the client for view redraw is synchronous, meaning that there is a substantial fixed overhead for view redrawing.
Need I say more? Many views cause poor performance; fewer views containing simple user views are often faster and aren't much harder to implement. The Browser offers a good example, using its own simple view system to represent icons.
Most of the communication between a client window and the application
server is done using buffered messages. This means that multiple graphic
requests are queued in a buffer before being sent to the app_server. This
dramatically reduces the overhead of a client-server architecture by
reducing the number of context switches. However, there are a number of
calls that can't be buffered due to some synchronization issues or the
need for an immediate result from the server. The best example is
probably
StringWidth()
.
If you do some timing using bitmap fonts (such as
Erich and Kate), you'll find that drawing the string is much faster than
measuring it. Be cautious with
StringWidth()
.
Consider caching the width of
certain strings locally, or creating your own width table for a given
size of typeface.
Some other calls that use a synchronous protocol include:
ConvertToScreen()
,
ConvertFromScreen()
,
ConvertToParent()
and so on
Many "Get" calls
(GetMouse()
,
GetKeys()
and so on)
PenSize()
,
StringWidth()
and other font measuring calls
CopyBits()
,
DrawBitmap()
(since the bitmap can be modified by another thread!)
A common mistake is to use the
Bounds()
method of
BView
inside a drawing
loop each time you need the bounds of the view. This is a perfect case
for caching, since the bounds won't change while drawing. In fact, most
of the synchronous calls can be cached before using them in a loop, with
the obvious exception of
GetMouse()
,
GetKeys()
, and so on, which are used to
poll changing information.
When redrawing the content of a window, the application server rejects
any view that doesn't intersect the update area. Of course, you're still
responsible for rejecting within your view, since you know exactly what
needs to be drawn. The first stage is to use the rectangle passed to
Draw()
;
the difference can be amazing. The second stage is to ask for the
clipping region, using the
GetClippingRegion()
call.
The
BeginLineArray()
...
AddLine()
...
EndLineArray()
system is another good
technique for squeezing more drawing speed out of the system. This
technique is quite a bit faster than the regular
MovePenTo()
...
StrokeLine()
...,
often by a factor of 10! When combined with a thick pen size,
LineArray()
can be used for some strange purposes, like drawing a color palette.
At this point, Bitmap fonts are an order of magnitude faster than TrueType™ fonts. This will improve in the future, but using bitmap fonts for common user interface items will make things much smoother!
These are just a few little tips for improving the performance and efficiency of your applications.
Dan Schwarz, founder of Brookline Software, specializes in utility software—so far, primarily for the Macintosh. He sees his role as "finding gaps in the software where Apple didn't supply something useful, and leaping in to fill that niche." He's hoping to do similar things for the BeBox.
Not that he expects the Be Operating System to have a lot of gaps. On the contrary, he says, "I know that the Be folks have learned a lot from Apple's mistakes. But the system is still very immature, and it seems like it's ripe for small developers to jump in and do this kind of thing."
Brookline Software has two major Mac products. The first, SerialSpeed 230, addresses the fact that Mac serial ports are faster than most software can handle. It "brings the software up to speed," Schwarz explains. The second, the brand-new PrinterSwitch, fills "a longtime gap. It's very inconvenient on the Mac to switch between printers," Schwarz says. "The Chooser has been there since 1984, and no one's done anything with it. Finally, I just got fed up and said, here's a better way to do this." The products are distributed over the Internet as shareware, a practice Schwarz expects to continue "for the foreseeable future."
Schwarz was attracted to the BeBox because he feels that, as a small developer, he has a good chance to establish himself with it. "It's a new platform, and the big players have not established a foothold as far as killer applications and utilities go," he says. "I'm not hoping to compete effectively against Symantec or Microsoft. But in a field where it's all new, it's a much more level playing field, and there are more opportunities to be exploited."
He compares the BeBox now to the Macintosh in 1984. "There were a couple of players who jumped in with software that filled a need and became a de facto standard," he says, pointing to Aladdin's StuffIt SpaceSaver as an example. "They were able to come out with a quality product early, and no one's been able to knock off their lead since then. I'm hoping to replicate that sort of success."
Schwarz has high hopes for the future of the BeBox—and for Brookline Software. "Assuming [Be] really hits a market, and really makes an impact on it, I could see them shipping a lot of units, expanding over a decade," he says. "And the people that get in first, with products that make a difference, are going to be the ones that benefit disproportionately. And that's where I'd like to be."
You can learn more about Brookline Software's products at Schwarz's web site: http://www.cs.brandeis.edu/~dan/home.html.
Here at Be, we've been talking with many (many, many) people and companies about how best to distribute the Be System—both hardware and software. There has certainly been no shortage of ideas and suggestions from other players in the industry. But when we think about this question, we think more in customer-oriented terms. Where do customers purchase hardware and software today? Where are they likely to do so in the future? And what are the most convenient and cost-effective channels, since customers are constantly on the lookout for better value?
If you think of it from the customer's point of view, the problem becomes simpler. Customers should be able to learn about and order your products via any of three methods: Through the Internet, by turning to a local reseller or VAR, or by picking up the phone.
Over the last year the Internet has burst onto the scene, bringing millions of personal computer users with it. This has been especially true in the United States, where it is safe to say that the most influential customers in the market all have Internet access and use it regularly.
But the impact of the Internet isn't limited to changes in product and technology design—it's causing a revolution in how computing products are marketed and sold.
Not so many years ago, Dell Computer started a business in a dorm room, selling personal computers over the phone. Dell built its business through this innovation—making it easy for customers to order custom-configured PCs and have them delivered directly for a great price. What Dell knew that other industry players didn't was that customers were becoming more knowledgeable, and better able to make product decisions themselves.
Looking out onto today's marketplace, it doesn't take much to draw the parallels between this innovation over the phone lines and the Internet. But more important, the Internet can provide more customer service than the phone can provide. The Internet can deliver words, pictures, and other product information. It can provide links to related products from any company—a critically important concept in the PC industry. It can be interactive, working with the user to configure a system, for example. It can deliver bits directly to the customer's machine, meaning it can deliver software. And to top it all off, the Internet provides all of this at a fraction of the cost of any other distribution method.
Because of all of this, it's not a question of whether the Internet will be used to market and sell PC gear, it's only a question of when. The answer is today. Expect to see an explosion in this area of the Internet in 1996, and expect to see Be participating.
There are many configuration and marketing problems that can't be solved over the phone or the Internet. The latter methods assume that you already know what you're planning to purchase. But what if you need expert advice about how to solve problems in a more complex environment than simply a home or small office?
That's where value-added dealers and resellers (VADs and VARs) come in. Overall, computer resellers have experienced hard times over the last few years, as customers have shifted to low-cost channels for single-purchase and commodity equipment sales—from small resellers, to computer superstores, and now to the phone and the Internet. But the fact is, the base of VARs in the US is stronger today than ever and they're solidly delivering to a wide number of markets.
Why? Because these resellers have focused on specific customer segments and developed expertise in a wide array of vertical applications. If you're a growing graphic design firm, for example, it makes sense to turn to a value-added reseller to gain advice about how to set up an entire office and to make sure you purchase the right amount of the right equipment. Avoiding a single purchase mistake can easily overcome any price difference between a VAR and direct channels—not to mention the time you can save getting everything up and running. As long as this is true, there will always be a strong reseller presence in the market.
Last, customers should be able to pick up the phone to order products. Customer can call a company directly, or they can call a national reseller (commonly referred to as "mail order").
Phone ordering has no equal in accessibility and convenience. It's often the least expensive channel as well, matched only by Internet ordering. The main disadvantage to this channel is its inability to deliver information—you need to know pretty much exactly what you want before you call. Don't expect a lot of detailed advice from the operator at the other end of the line.
So where will Be play? Over the long term we plan to make it easy for customers to purchase Be products through any of these three avenues. You'll see some differences in our implementation between countries -- the level of channel development differs among nations. But our general philosophy in distribution is customer-oriented—we should be where our customers expect to be able to purchase personal computer equipment. It would be arrogant to make customers come to us.
In the United States, expect to see Be develop the Internet channels and value-added resellers first. We'll be moving on both fronts in 1996. This means you'll be able to order directly via the Internet, configuring your BeBox to your own specs. And you'll be able to purchase a Be System from a knowledgeable reseller who can provide integration and software expertise. Be resellers will have full access to Be and our configuration systems, so they can deliver a high level of service, and get customers up and running quickly. As we complete these channels, we'll then implement phone ordering, likely in partnership with our reseller network.
Will you see BeBoxes in your local consumer electronics store or computer superstore? In the US, these high-tech supermarkets have business models that depend on high inventory turnover and they're very sensitive to changes in volume. For this reason, the rise of lower-cost channels such as phone-ordering and the Internet present a significant challenge. In addition, the resurgence of competitive VARs in specialized markets blocks a retreat into customer niches. Needless to say, these distribution players have many issues to solve in the near future that may distract them from focusing on emerging players such as Be. I'm sure some of my colleagues within these superstores will disagree with me (and can tell me so at markg@be.com). If so we may see some of these outlets carrying Be products in the future.
Just as Be is taking advantage of changes in the technology landscape, we're using changes in the business of selling personal computer hardware and software to help define a new—and hopefully more customer-aligned —way of distributing products. Stay tuned as we make announcements throughout 1996 about distribution partnerships.