Skip to main content

Added bits and pieces

Posted by daniel on October 29, 2003 at 11:22 AM PST

C++ designer Bjarne Stroustrup explains in his interview The C++ Style Sweet Spot "A lot of people see C++ as C with a few bits and pieces added. They write code with a lot of arrays and pointers. They tend to use new the way they used malloc. Basically, the abstraction level is low. Writing C-style code is one way to get into C++, but it's not using C++ really well."

He says, "The problem with the C way is that if you write code C-style, you get C-style problems. You will get buffer overflows. You will get pointer problems. And you will get hard to maintain code, because you're working at a very low level. So the cost is in development time and maintenance time."

Stroustrup complains that there is a perception "that if it is elegant, if it is higher level, it must be slow. It could be slow in a few cases, so deal with those few cases at the lower level, but start at a higher level. In some cases, you simply don't have the overhead. For example, vectors really are as fast as arrays."

He takes his standard shot at Java saying that others get in trouble because

They believe that C++ should be an extremely high level language, and everything should be object-oriented. They believe that you should do everything by creating a class as part of a class hierarchy with lots of virtual functions. This is the kind of thinking that's reflected in a language like Java for instance, but a lot of things don't fit into class hierarchies. An integer shouldn't be part of a class hierarchy. It doesn't need to. It costs you to put it there. And it's very hard to do elegantly.

He says that the problem with "the big class hierarchy is again, you write more code than you need to, and you get too much connection between different parts. I particularly dislike classes with a lot of get and set functions. That is often an indication that it shouldn't have been a class in the first place. It's just a data structure. And if it really is a data structure, make it a data structure."

Our other link in Also in Java Today is to John Zukowski's latest Core Java Tech Tip Choosers outside dialogs . John shows you "two ways of working with JColorChooser that don't involve a modal JDialog. A modal dialog is one that blocks input to the main program. If you don't want to block input to the main program, you can manage the JDialog yourself with the static createDialog method ofJColorChooser. Alternatively, don't put the JColorChooser in a JDialog, and include it as part of your own window."

In today's featured Weblogs , two of the entries talk about Java on the Mac. Simon Brown notes that Panther ships with Ant, XDoclet, and JBoss. Brown writes "In Apple's inevitable way, running JBoss is as simple as navigating to the bin directory of the JBoss installation and running the script. No need to even set up environment variables such as JAVA_HOME. Okay, getting JBoss running on any platform is easy, but you have to admire Apple for making it even easier."

Scott Ellsworth submits his first blog entry Mac OS X is my Java development environment. Scott takes issue with Cay Horstmann's complaint about the platform as a Java development environment. On some issues the two men are in agreement but Ellsworth clarifies a complaint that one of Horstman's apps doesn't render on the Mac the way it does on other platforms. " The specific problem Cay mentioned with his UML editor Violet have been fixed in Panther, but the overall problem of having a different vendor on Apple than on Windows and Linux is real. Deficiencies are fixed over time, but as long as Sun is the sole vendor for Java on Linux, Windows, and Solaris, they form the baseline of how the system should perform. Even when Sun violates the contract of its APIs, there will be people who will find any other behavior wrong, and when the alternative behavior is clearly inferior, the people complaining about Apple's implementation have a strong case."

Meanwhile, Mac using Java programmer James Gosling checks in from the JPL. He reports that " The big excitement there is the two MERs (Mars Exploration Rovers) that are on their way to Mars now. Check it out at "

Also in Projects and Communities , the Java Web Services and XML community features the Struts EJB project which "provides base classes and patterns to build a Web application with Struts, EJB andJSTL." The JavaDesktop community has a Java WebStart version of the current state of the Mu project which is intended to be an "all-encompassing, networked audio player and image browser. With Mu, you can access your music and photos anytime, anywhere. JReceiver web service or locally on your hard drive. Your collection is presented to you in one well-organized, hierarchical list. You can currently browse by artist and album, and future versions will allow for more complex queries."

In today's News Headlines :

Registered users can submit news items for the href=""> News Page using our
news submission form.
All submissions go through an editorial review by news director Steve
Mallet before being posted to the site. You can also subscribe to the href=""> News RSS

Current and upcoming Java Events:

Registered users can submit event listings for the href=""> Events Page using our href=""> events submission form.
All submissions go through an editorial review before being posted to the

This blog is delivered weekdays as the href="">Java Today RSS
feed. Once this page is no longer featured as the front page of href=""> Java Today it will be archived at href=""> You can
access other past issues in the href=""> Archive.