Wednesday, September 28, 2005

Graphics: Maths on Splines Bezier Curve

http://www.mat.ucsb.edu/~c.ramakr/articles/dls/nurbs.pdf

Monday, August 02, 2004

J2ME - Programming Language for the Portables

A Brief Look at Java 2 Micro Edition

J2ME:

Java now presents an incredible variety of platforms and APIs: J2ME, J2SE, J2EE, PersonalJava, EmbeddedJava, TV, Telephony, and the KVM (to name a few.) As Java moves off of the desktop, these diverse specifications accommodate the wide variety of device capabilities and features. For the programmer who already knows Java, this article will help put J2ME and its close relatives in their places.

The History of Small (and not-so-small) Java:

Java did not start out as a 20MB platform. (In fact, it didn't even start as "Java", but that is another story.) Java started small, aimed at television set top boxes and other interactive devices. Of course, once it got aimed toward web browsers and applets, the brakes were off. As a result, the platform got all kinds of amazing features like Swing, Java 2D, Java 3D, JDBC, EJB, and so on. With each new API, the size of the platform got bigger and bigger and bigger. So did the runtime footprint. These days, it is not uncommon to see Java virtual machines with a gigabyte or more of heap space. Whether you want to call this futurities, bloat, or customer responsiveness, the fact remains that the Java 1 platform was big, and the standard Java 2 platform is huge.

Obviously, the large size of the platform conflicts with the goal of WORA (write once, run anywhere). Not every device that needs programming can support a multi-megabyte process size. Sun first addressed this need in 1997 with the introduction of several Java platforms, aimed at different segments of the market. JavaCard would take the very smallest devices-smart cards. EmbeddedJava covered devices with no user interface. PersonalJava aimed at the "network appliance" market. Enterprise Java would handle entire corporations. These platforms differed mainly in the subset of the Java API they each supported.

Introducing J2ME:

As time and technology moved on, Sun recognized the need to collect the device-oriented platforms under one umbrella. At JavaOne in 1999, Sun introduces the Java 2 Micro Edition. J2ME is not a specific virtual machine, API, or specification. Instead, J2ME provides a modular, scalable architecture to support a flexible deployment of Java technology to devices with diverse features and functions. A J2ME "configuration" targets devices with a specific range of capabilities. A "profile" selects a configuration and a set of APIs to target a specific domain of applications. By selecting the best configuration and profile, a vendor can produce a wide range of flexible applications. Since lightweight appliances do not need to support the entire Java 2 platform, their resource requirements (and therefore cost) will be reduced. At the same time, by allowing modular extensions, J2ME allows vendors to differentiate themselves by producing innovative applications and incorporating value-added features.

J2ME Configurations:

A J2ME configuration defines an API and a virtual machine optimized to service devices that fall into a particular range of capabilities and resources.

Two configurations have been defined.
CLDC: the Connected, Limited Device Configuration
CDC : the Connected Device Configuration.

The CDC expects devices with substantial resources. In particular, it requires at least 512K ROM and 256K RAM, and a device that can support a complete JVM implementation.


The CLDC provides a platform for more resource constrained, but still network-connected devices.
  • 128K to 512K total memory available with <= 256K ROM/Flash and <= 256K RAM. In most cases devices will have more ROM than RAM or Flash memory.
  • Limited power, often battery operation.
  • Connectivity to some type of network, although with possibly limited (9600/bps or less) bandwidth.
  • User interfaces with varying degrees of sophistication down to and including none.
    This category of device includes cell phones, two-way pagers, and PDAs.

J2ME Profiles:

Profiles define additional class libraries and APIs needed to enable domain-specific applications on a particular configuration. Profiles provide the vertical specialization built upon the horizontal configurations. For instance, the Mobile Information Device Profile requires at least the Connected, Limited Device Configuration. It enables development of applications to provide wireless access to information.
The most basic profile is the Foundation Profile. The Foundation Profile requires the Connected Device Configuration. It explicitly supports devices with no user interface whatsoever, but which do have networking support.

What About All Those Other APIs?
So what happened to PersonalJava, EmbeddedJava, JavaPhone, and the others? In the future, they will be migrated to J2ME profiles. PersonalJava 1.3 is already moving in that direction.

The 'K' Virtual Machine:
Sun has introduced a new Java virtual machine to support J2ME on 16 or 32 bit microcontrollers. Aimed at the CLDC, the KVM is only 40K of object code and needs only "a few tens of kilobytes" at runtime. A KVM developer's release is available from the Java Developer's Connection (see Resources below.) This early release runs on 3Com's PalmOS v3.01 and higher. The distribution includes documentation, the KVM class library, and tools to package and install Java applications on PalmOS-based devices.

The Good
KVM is small. Really, really small. In its tightest configuration, it requires only about 40 kilobytes. It can also be customized. Several Java language and virtual machine features not required by most applications have been made optional. A particular J2ME configuration defines which of these optional features must be included in the KVM implementation.

The follow features are optional:

  • Long, float, and double
  • Multi-dimensional arrays
  • Class file verification
  • Recoverable handling of Error classes
  • Threads
  • Event Handling
  • JNI
  • Class loaders
  • Finalization

If you install the developer's release of the KVM, you will see that some of these optional features are included in this implementation. Future configurations are likely to support some of the rest. One of the goals of the KVM was to support incremental deployment of J2ME features, so a future KVM implementation should allow selection of these features.


The Bad

The KVM weaknesses are directly connected to its biggest strength. In order to make it so small, Sun made some compromises in the Java language and virtual machine. This seems to be the long-feared fragmentation of the Java hegemony. Programming Java for J2ME is not like programming desktop Java or enterprise Java. More than even, it will be practically impossible for a developer to keep current on "Java Technology" as a whole. Specialization will be more necessary in the future. (Remember this when hiring!)

Watch out for this one:
The KVM does not implement the Java Virtual Machine Specification!

It implements a subset of that specification. What does this mean? Well, first of all, do not expect WORA in all J2ME applications. A smart phone application will be extremely unlikely to work on a PalmPilot, or vice versa. This seems like it should be obvious, since the two devices have totally different capabilities, but since portability has been so much a part of the Java message, it pays to note its limitations under the J2ME. In general, J2ME applications will be portable across the profile they were designed for. In many cases, an application will also be portable from one profile to a more capable profile.

The Future of J2ME:J2ME is still very new and much of the platform is evolving. A lot of specifications remain to be written. Sun and its partners will define the future of J2ME together via the Java Community Process. Through the JCP, members will jointly define new profiles and configurations. One area of hot interest is real-time embedded Java.
Jini is conspicuously absent from J2ME at this point. Sun acknowledges that Jini is absolutely essential. Expect to see Jini support in a forthcoming version of the KVM. It is also likely that the Community Process will result in a new J2ME profile for a Jini-enabled device.
The future certainly has more J2ME devices in store. Obviously any PalmOS licensee will be able to use the KVM. Sun is also aggressively pursuing other partners, like Motorola and NTT DoCoMo.


Support for J2ME is widespread, but not universal. IBM has their own JVM for embedded devices, called J9, which does not support J2ME. There are other, non-J2ME embedded virtual machines available, such as CrEme from NSIcom. Nevertheless, it is likely that J2ME compliance will rapidly become a must-have feature for embedded Java.

Wednesday, July 07, 2004

BEDD - Make More Friends with Mobile

SINGAPORE (Reuters) - Student Gracinia Lim has made new friends thanks to mobile phone software that alerts her to compatible people nearby.
She is an early customer of a service in Singapore called BEDD that uses Bluetooth wireless communications to scan strangers' phones for their personal profiles.

The application joins a swelling number of Internet and mobile phone based services that offer to widen people's social networks.

Users download the BEDD software into a compatible phone, complete a short profile of themselves and include a description of who they want to befriend, or an item they want to buy or sell.

The software automatically searches for and exchanges profiles with other phones that come within a 20-meter (65 ft) radius. Matched users are given each other's contact details.

"I've become close with people that I've never known before, built up a close clique of friends whom I chill out with, sleep over at their homes and go for late suppers with," said Lim, 19.

The software, created by futures trader Stephen Carlton and Swedish engineer Olle Bliding about three years ago, was launched last month in Singapore and will be rolled out in most of Asia by year-end. It costs S$0.98 ($0.571) for 30 days of unlimited use.

BEDD differs from rival services in that it relies on phone-to-phone transmission, running on the short-range Bluetooth technology. Other mobile-based dating services in Asia -- such as Singapore Telecommunications Ltd.'s MyCupid and Bharti Airtel of India's TrackUrMate -- exchange information through a central database. Carlton said BEDD has over 1,000 users in the city state and hosts get-togethers in coffee bars where people let their phones make their introductions. As the number of customers grows, the chances of meeting a compatible person at random in the street or on a bus will grow.

"People spend tons of money at dating and matchmaking agencies or on personal ads -- for a small amount of money, this software could help change their lives," Carlton said.