May 15, 2001 spout

Object-Orientation is Over

Tuesday, 5/15/01

Java, and Java 2.0 (aka .NET), have brought with them the end of object-orientation. Of course, by that I mean that object-orientation is no longer a question — it’s just how we program. Even our scripting languages have classes and objects now. That fight is over, as are the advances in that area. Object-oriented programming, with inheritance, polymorphism and encapsulation, is just the way we do things now and Java and .NET represent the end of that line and the beginning of several others:

Generic Programming

Generic programming (aka generics”) provides the ability to write a partial type or function and let the compiler or runtime environment fill in the details based on client usage. Of course, C++ templates have provided generics via templates for a long time. Unfortunately, no modern object-oriented languages, i.e. Java and C#, have generics as yet, but they’re coming. My favorite research paper in this area describes how generics can be added to  .NET languages, using C# as an example, written by Microsoft’s own researchers, Andrew Kennedy and Don Syme.

Generics have been around for a long, long time, so if you aren’t already familiar with them, you’re behind. Only C++ programmers do this now, but very soon, everyone will be.

Component-based Programming

Components differ from objects in that they are binary objects, often callable from languages other than that in which they were written. COM, Java and .NET are popular modern component development environments, but even DLLs have provided component-like features since Windows. Components provide a degree of encapsulation that often exceeds that of source-based OO environments, often at the expense of ease of use (although both Java and .NET work real hard to make components look and feel like objects).

Aspect-Oriented Programming

Aspect-oriented programming (AOP) provides the ability to define a set of characteristics of an object or a component that are actually implemented by the hosting runtime. The benefit, of course, is that it’s much easier to declare the need for some feature, e.g. method tracing or the need for a component to be part of a transaction, than it is to write the code. To date, we’ve had pretty primitive support of AOP in the popular programming environments, but it’s been there, e.g.

  • COM+ catalog attributes that describe services provided by the COM+ runtime to components or groups of components (called applications”), e.g. transactions, object pooling or role-based security.
  • Keywords in Java, e.g. the transient keyword that signals to the serialization engine whether to serialize an object’s member variable or not.
  •  .NET attributes that extend a component’s metadata, which is available via .NET reflection to clients, some of which are built into the .NET runtime and some of which that are custom to your particular application.
  • And my personal favorite, as pointed out to me by Don Box, is the PE attribute that marks an EXE as a Win32 Console application. This is primitive, but this attribute tells the OS to set up a console window for routing of stdio.

The .NET attribute mechanism represents a giant step forward in AOP. It’s the first popular environment that provides a convenient, extensible mechanism for not only declaring attributes, but also implementing custom attribute provides, i.e. those bits of code that are activated when an attribute is encountered. Extensible .NET metadata is replacing the COM+ catalog and providing exactly what the Java serialization keywords provide and I expect most language to converge on the AOP style that .NET provides.

Generative Programming

Generative programming is the newest of these new programming styles. The term itself was boasted into popular usage by the book of the same name by Krzysztof Czarnecki and Ulrich Eisenecker. Generative programming is about representing your system’s design requirements in some computer-readable form, e.g. SQL schemas, XML, UML, etc, and feeding it to some kind of metaprogram that will generate your program. The main benefit of generative programming is that as the design requirements change, your programs can be regenerated, saving you from manually replicating design changes into the code. Likewise, as the implementation choices need to change, e.g. from Java to C# or from Linux to Windows, the metaprograms can change and your programs can be regenerated, saving you from doing the porting work.

Macro languages, e.g. the C preprocessor, are generative languages for generating code within files. ASP and PHP are both generative languages for building web pages. Of course, DevelopMentor’s own Gen<X>, was built from the ground up to be a generative programming tool (although we designed and built it long before we’d heard the term). Generative programming has a vast potential, I think (although I’m biased), because it encourages you to specify your design requirements and keep them up to date with the code, but also because of the potential for generating large parts of a system’s code, testing data and even documentation. In fact, in building Gen<X> itself, we find ourselves generating more and more of the next version using the previous version. We don’t use it for unique code, but we use it for the repetitive horizontal or hierarchical code as well as reference docs and test data. Highly recommended.

[new] Comment from Mickey Williams [mickey.williams@codevtech.com], Mon 7/2/2001 10:54 AM:

I’d like to remind you that Eiffel has had generics longer than C++, and Eiffel’s generics work on .NET. So there.

Best regards from the Eiffel bigot,
Mickey”

That’s true, Mickey. I knew that Eiffel supported templates, but I didn’t know that Eiffel# (the .NET version of Eiffel) did, so that’s really cool.

April 21, 2001 spout

From COM to .NET

Saturday, 4/21/01

Enough people have asked me what I think about the transition from COM to .NET that I thought I’d publish my thoughts instead of responding to each individual email. This is the question that finally lead to me publishing this page in the first place.

In the early days of C, ASM was much more efficient, but C was much easier to use and as machines got faster, and C compilers got better, ASM was relegated to use by only a few. During the transition, ASM programmers were valuable and continue to be so for very targeted tasks, but they grow increasingly unnecessary. For example, in all the time that I’ve developed software (17 years), I’ve needed ASM exactly *once* (and then I just used Keith Brown : ). To this day, I have to admit that I can neither write nor even read x86 assembly. I’ve always meant to learn and I admit to being embarrassed that I can’t, but I’ve never needed it. Each platform I programmed for, I started after the platform had moved away from ASM being the dominant programming environment.

As Microsoft ships increasingly stable betas of .NET towards a final release, we’re nearing the end of a long and messy transition from processor-specific low-level programming to programming at a higher level on the Windows platform. To be honest, most Windows programmers are already there and have been for a while. They’re the forward-thinking Visual Basic programmers. They recognized that they had no need to learn Win32 or COM. They could program at a comfortable level and make their C++ programmer friends do the grunge work for them. C++ programmers that haven’t moved to VB yet had two reasons: the programs run too slowly and VB doesn’t let me do what I want. With each successive release of VB, the efficiency argument has gotten weaker and weaker. Now that VB6 uses the same intermediate language and backend compiler that VC6 does, speed’s really no longer an issue. The 2nd reason, VB doesn’t let me do what I want,” is real and continues through VB6. The problem is really the language. There is one feature that no C++ programmer can live without: implementation inheritance. It’s so useful for day-to-day programming chores that we can’t give it up.

This one fatal flaw in VB6 was made very clear to me the other day when I was doing .NET programming using C#. Before we go any further, let me make one thing perfectly clear: VB.NET *is* C#. The only difference is the syntax. The language features are all the same but one: you can write unsafe” code in C#, but not in VB.NET. Unsafe code in C# is the equivalent of  inline ASM: when you need it, you can’t live without it, but you probably won’t need it. So, when I’m programming C#, I could as easily be programming VB.NET. And the beauty of my experience of programming C# caused me to examine the difference between my previous VB6 experience and my current C# experience. I had a form-based drag-n-drop environment in both. I had IntelliSense in both. I had a programming model that was much simpler than raw Win32 in both. In short, C# and .NET gave me everything that VB6 gave me, but with one addition: implementation inheritance. When I needed to model the data for my application, it was so easy because I had inheritance but would’ve been so much harder without it. That feature made all the difference to me and is the reason that C++ programmers will finally feel free to move into the VB-like environment that .NET provides.

Will everyone abandon the Win32 API when .NET ships? No. Will everyone eventually move their code over to .NET? No. Will most folks spend most of their time programming .NET within 18-24 months of ship? Absolutely, yes. It’s too compelling a platform with too many real advantages to ignore.

Does that mean you should stop all development and wait for .NET to ship? Absolutely, no. Build you components in COM today and you’ll be able to move them over to .NET when the time is right (which may be never). The .NET backwards compatibility story is a good one. You’ll be able to continue to make use of most of your COM components and DLLs in .NET, which means that the code you’re working on today will continue to be useful long after you’ve moved your day-to-day programming activities to .NET. To ease the transition, I recommend marking your COM interfaces with [oleautomation] if possible. This limits your method parameters to types and attributes that .NET is particularly good at marshaling.

 .NET via C# and VB.NET is the future of programming for Windows, leaving Win32 and COM as the ASM of .NET.

April 15, 2001 fun

College Fun

I spoke at a college last week for a friend of mine who’s an adjunct professor (Cal Caldwell). During the talk, one of the male attendees bolted <sigh>, but on his way out, trusted sources say that, when sighting a young coed whom our our bolter was clearly interested in engaging with in some way, he said, Hey! Do you know who’s in there? Chris Sells!” Clearly this young man was misguided in his attempt, but I’m glad to hear that someone thinks that using my name will help in attracting members of the opposite sex. It’s never worked for me… : )

February 28, 2001 fun

College Fun

In Japan, it is said, the impersonal and sometimes unhelpful Microsoft error messages have been replaced with Japanese haiku poetry. Maybe in the next upgrade to our Windows…

Your file was so big.
It might be very useful.
But now it is gone.

The website you seek
Cannot be located, but
Countless more exist.

Chaos reigns within.
Reflect, repent and reboot.
Order shall return.

Aborted effort.
Close all that you have worked on.
You ask far too much.

Windows NT crashed.
I am the Blue Screen of Death.
No-one hears your screams.

Yesterday it worked.
Today it is not working.
Windows is like that.

Stay the patient course.
Of little worth is your ire.
The network is down.

A crash reduces
Your expensive computer
To a simple stone.

Three things are certain:
Death, taxes and lost data.
Guess which has occurred.

You step in the stream,
But the water has moved on.
This page is not here.

Out of memory.
We wish to hold the whole sky,
But we never will.

Having been erased,
The document you’re seeking
Must now be retyped.

I ate your Web page.
Forgive me; it was tasty
And tart on my tongue.

First snow then silence
This thousand dollar screen dies
So beautifully.

The Tao that is seen
Is not the true Tao, until
You bring fresh toner.

With searching comes loss
and the presence of absence:
My Novel” not found.

See how in Haiku
All error messages are
Somehow more peaceful

Richard Blewett
Ian Griffiths
George Shepherd
Internal Mailing List

February 22, 2001 tools

TZ Data to XML Project

These are the outputs of my attempts to translate the native tz data into XML for easier parsing for applications other than implementations of the standard C routines related to time.

This is the first step in a project to merge time zone and map data by the Time Zone Map Group, lead by Chuck Ellis.

Done

  • tz2xml.zip: A VC++ program to translate native tz data files into XML. Warning: This requires a certain directory structure and a few modified files from the tz code to export shared functions. I’m working to fix that.
  • /tools/tz/tzxml.zip: Native tz data files translated to XML, including comments. Suitable for replacement as the native format. Generated by running tz2xml on the tz data files.

Yet To Do

  • Namespace support.
  • XSD support.
  • An XSLT to translate back to native tz data format.
  • An XSLT to output popular data needs, e.g. all the zones, all the rules, etc.
  • An updated zic to use the new XML format instead of the existing format.
  • Unix port of tz2data (I’ll need help on that one).

Help!

Unfortunately, I’m but one man. If you’d like to help on any of these projects, let me know.

License

Copyright © 2001 by Chris Sells. All rights reserved. No warrantees extended. Use at your own risk. You may not distribute any portion of the tz2xml source code without express written consent. You may, however, use the source with no fee or redistribute the sample XML data at will.
February 16, 2001 tools

Genghis

November 21, 2000 fun

a poem

Dear MFC::CString
You were such a beautiful thing
I miss you so much
CComBSTR is painful to touch
WTL may restore my churning (out string manipulating code).

Phil Beck
ATL Mailing List

August 25, 2000 fun

These Days its only COM COM COM (Am I Crying)

There is no vacation when I am doing COM.
Some go through very well, but stuck are some.

I don’t go to parties, so I feel I am IUnknown.
People talking to me, those days are gone.

Brother has a complaint, that I don’t callback.
Which kind of apartment he has, I don’t check

Everyone stares me through those windows.
I live in ATL* and that is what I chose.

*(short for Atlanta)

Sandeep  Chawla
Private Email


← Newer Entries Older Entries →