TweetFollow Us on Twitter

January 92 - Postcard from Windows Land - Is Windows object-oriented?

Postcard from Windows Land - Is Windows object-oriented?

James Plamondon

When the Microsoft gang started writing Windows back in the mid-eighties, they were all excited about object programming. They, like Apple, toured Xerox PARC and saw what Xerox was doing with bit-mapped displays, windows, mice, and so on. Microsoft, like Apple, thought this stuff was going to be the wave of the future-so they went home and started working on a cool object-oriented operating system.

Then reality hit. Their target platform, the standard IBM PC of their day, was totally unable to handle the strain of a truly object-oriented system. So, like Apple, Microsoft compromised, and wrote a procedural operating system with an object-oriented flavor.

For whatever reason, however, Windows was unsuccessful throughout its development-until around the time Microsoft's OS/2 deal with IBM fell through-whereas the Mac OS was the star at Apple from soon after its inception. So the Windows operating system is only now beginning to flower, as the Mac OS did about four years ago.

What's amazing to me is how fast Windows is moving. Whereas Apple took ages to bring out System 7, Microsoft is bringing out Windows 3.1 just 18 months (roughly) after 3.0 hit the shelves. And Windows 3.1 should really be called Windows 4; it is a really big improvement over Windows 3.0 (which has sold over five million copies in the last year, so it's no slouch, either).

But is Windows object-oriented? Absolutely not-if, by "object-oriented," you mean written in an object programming language. Given Windows' origins and history, it couldn't be. Smalltalk and Simula were the only decent object programming languages available at the product's inception, and neither would give adequate performance on their target system. So Microsoft did the best it could under the restraints it was under at the time. And in at least one way, Microsoft did a better job than Apple.

Windows, true to its name, has a real windowing system; the Mac does not. This should come as no surprise to MacApp programmers; one of the most important benefits MacApp provides to Mac programmers is-you guessed it-a windowing system, in the form of MacApp views. [A Windows "window" is equivalent to a MacApp "view;" a MacApp "window" is equivalent to a Windows "frame window."] It is considerably easier to write an application framework for Windows than for the Mac, because a Windows framework could use the native windowing system. Zillions of lines of code could be saved.

On the Mac, when you create a window, you get a pointer to a data structure. This data structure is completely dumb. There's no way to call its methods or send it messages. In Windows, on the other hand, one can define a window class, and associate with this class a number of attributes and-importantly-a window procedure (WinProc). When you create a window, you must specify the class of the window. The window reference you get back is a unique window identifier, but it's completely "blind." You can't use it as a pointer to get at its data directly. Instead, you have to "send the window a message" to act on it.

"Sending the window a message" works just like "sending a message" to a Mac CDEF, WDEF, or other code resource. You call a procedure with an integer argument that indicates which message you're sending, and a couple of other arguments that can hold additional data. (Before you snort in disdain at the notion of using integral message discriminators, think about MacApp's use of command numbers in TEvtHandler.DoMenuCommand().)

So, Windows does a better job of data abstraction and encapsulation, at least with regard to window data structures. But is this abstraction and encapsulation enough to make it object-oriented?

Well, maybe not-but there's more. Having defined a window class, one can "subclass" the window class. Now, before you get all excited, let me admit that it's not "real" subclassing, using the definition used by object programming languages. But it's not a bad simulation.

Let's say you want to write a variation of the standard Windows "edit" control-to validate its entries as dates, perhaps. You would need to get a copy of the "edit" class' class info (by calling GetClassInfo()), and modify the resulting copy to use your new class name ("edit_date"). Also, you would save off the class info's pointer to the "edit" class' WinProc, and store the "edit_date" class' WinProc pointer in its place (in the copy). Then, you would call RegisterClass() to tell Windows that the window class existed.

Having done this, you can then create a window of class "edit_date" by telling Windows to do so. It will respond by handing you back a unique window identifier. From then on, both Windows and your application will interact with the window by sending it messages. Messages are sent to the window by calling the Windows function SendMessage() with the window ID as the first argument, or by calling other Windows functions that eventually call SendMessage().

SendMessage()'s prototype is roughly as follows:

long SendMessage(HWND hWnd, short wMsg, short wParam, long lParam);

[This prototype has been simplified for ease of understanding by the MacApp audience. The correct prototype is "LONG FAR PASCAL MyWinProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)."]

"hWnd" is the unique window ID. When SendMessage() is called on a given window, the window's WinProc is called. The WinProc's prototype is almost the same as that of SendMessage(); calling SendMessage() can be viewed as a polymorphic call to a window's message procedure.

The WinProc typically contains a huge switch statement (in Pascal, case statement) that forwards the message to the appropriate message handler (much like TApplication.DispatchEvent()). And, since you carefully saved off the standard Windows "edit" window class' WinProc pointer before calling RegisterClass(), you can call it from within your "edit_date" window class' WinProc-much like calling the inherited implementation of a method in an OOP language. It ain't pretty, but it works.

So, maybe Windows is object-oriented, and maybe it's not. Maybe, as a friend of mine said recently, object-orientation is not a binary, yes-or-no quality, but rather a continuum. If so, then Windows is certainly "more object-oriented" than the Mac OS, while being "less object-oriented" than MacApp.

The answer to the question may be irrelevant. It is relevant, though, that your MacApp experience will put you way ahead of the game in Windows programming. MacApp software development tools are on the cutting edge, while those for Windows are still blunt instruments, suitable only for beating code into submission.

But the bottom line remains the same: Windows is selling at an incredible rate, and will be a significant force in the microcomputer industry for years to come. By learning to program in Windows, you will be assuring your financial security for at least the next decade.

As the old saying goes, in the land of the blind, the one-eyed man is King; and with Windows selling at an incredible rate, the Land of the Blind is expanding rapidly. We MacAppers know how to wring the most out of an even vaguely-object-oriented system; you can see the opportunity this presents to us, even with one eye shut.

 
AAPL
$100.58
Apple Inc.
+0.01
MSFT
$45.22
Microsoft Corpora
+0.27
GOOG
$583.37
Google Inc.
-1.12

MacTech Search:
Community Search:

Software Updates via MacUpdate

Pages 5.2.2 - Apple's word processo...
Apple Pages is a powerful word processor that gives you everything you need to create documents that look beautiful. And read beautifully. It lets you work seamlessly between Mac and iOS devices. And... Read more
Quicken 2015 2.0.1 - Complete personal f...
The new Quicken 2015 helps you manage all your personal finances in one place, so you can see where you're spending and where you can save. Quicken automatically categorizes your financial... Read more
CleanMyMac 2.2.7 - Delete files that was...
CleanMyMac makes space for the things you love. Sporting a range of ingenious new features, CleanMyMac 2 lets you safely and intelligently scan and clean your entire system, delete large, unused... Read more
MacFamilyTree 7.2.4 - Create and explore...
MacFamilyTree gives genealogy a facelift: it's modern, interactive, incredibly fast, and easy to use. We're convinced that generations of chroniclers would have loved to trade in their genealogy... Read more
Videobox 4.1.1 - Download Flash video th...
Videobox allows you to quickly and easily download Flash video from most all of the popular video sites on the internet. Videobox will convert the video into a native Quicktime format so it's ready... Read more
Web Snapper 3.3.5 - Capture entire Web p...
Web Snapper lets you capture Web pages exactly as they appear in your browser. You can send them to a file as images or vector-based, multi-page PDFs. It captures the whole Web page - eliminating... Read more
Picasa 3.9.138 - Organize, edit, and sha...
Picasa and Picasa Web Albums allows you to organize, edit, and upload your photos to the Web from your computer in quick, simple steps. Arrange your photos into folders and albums and erase their... Read more
Tidy Up 3.0.15.0 - Find duplicate files...
Tidy Up is a complete duplicate finder and disk-tidiness utility. With Tidy Up you can search for duplicate files and packages by the owner application, content, type, creator, extension, time... Read more
Parallels Desktop 10.0 - Run Windows app...
Parallels Desktop is simply the world's bestselling, top-rated, and most trusted solution for running Windows applications on your Mac. With Parallels Desktop for Mac, you can seamlessly run both... Read more
Apple Final Cut Pro X 10.1.3 - Professio...
Apple Final Cut Pro X is a professional video editing solution.Completely redesigned from the ground up, Final Cut Pro adds extraordinary speed, quality, and flexibility to every part of the post-... Read more

Latest Forum Discussions

See All

DotEmu Summer Sale Cuts Several Games’ P...
DotEmu Summer Sale Cuts Several Games’ Prices to $0.99 Posted by Ellis Spice on August 21st, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
King Announces its Newest “Saga” – Diamo...
King Announces its Newest “Saga” – Diamond Digger Saga Posted by Jessica Fisher on August 21st, 2014 [ permalink ] Diamond Digger Saga, by King Digital Entertainment, promises to be another addictive, adorable game in the “Saga” | Read more »
Spacetime Studios’ Greg Mueller Tells Al...
| Read more »
TourStar Review
TourStar Review By Rob Thomas on August 21st, 2014 Our Rating: :: BORING TOURINGUniversal App - Designed for iPhone and iPad When The Ramones sang “Touring, touring/It’s never boring,” they clearly weren’t referring to TourStar.... | Read more »
Track Your Pregnancy with Glow Nurture
Track Your Pregnancy with Glow Nurture Posted by Jessica Fisher on August 21st, 2014 [ permalink ] iPhone App - Designed for the iPhone, compatible with the iPad | Read more »
Outcast Odyssey – An Interview with the...
At this year’s San Diego Comic-Con, fans got the chance to meet and mingle with several of the artists behind Magic Pixel Games and Namco Bandai’s upcoming card battler, Outcast Odyssey. Considering many of these artists have worked on comics in the... | Read more »
BoxPop Review
BoxPop Review By Jennifer Allen on August 21st, 2014 Our Rating: :: UNTAXING PUZZLESUniversal App - Designed for iPhone and iPad Move from tile to tile to clear the board in this slightly too simple and easy puzzle game.   | Read more »
Breakdown Buddy Review
Breakdown Buddy Review By Jennifer Allen on August 21st, 2014 Our Rating: :: FLAWED CONCEPTiPhone App - Designed for the iPhone, compatible with the iPad There’s a good idea here, but Breakdown Buddy isn’t as useful as it tries to... | Read more »
jamstik, the Guitar You Can Take Everywh...
jamstik, the Guitar You Can Take Everywhere, is Now Available for Purchase Posted by Jessica Fisher on August 21st, 2014 [ permalink ] Zivix has announced that their guitar-in-your-pocket, | Read more »
Star Walk 2 - Guide to the Sky Day and N...
Star Walk 2 - Guide to the Sky Day and Night 1.0.0 Device: iOS Universal Category: Education Price: $2.99, Version: 1.0.0 (iTunes) Description: The next generation of the best-selling Star Walk, winner of Apple Design Award, used by... | Read more »

Price Scanner via MacPrices.net

21-inch iMacs on sale for up to $150 off MSRP
B&H Photo has 21″ iMacs on sale for up to $150 off MSRP including free shipping plus NY sales tax only. B&H will also include a free copy of Parallels Desktop software: - 21″ 2.7GHz iMac: $... Read more
27-inch 3.2GHz iMac on sale for $1698, save $...
Abt has the 27″ 3.2GHz iMac on sale for $1698 including free shipping. Their price is $101 off MSRP. Read more
Mac Backup Guru 2.0 Drive Backup/Cloneing Uti...
Mac Backup Guru developer MacDaddy has released Mac Backup Guru 2.0, offering new and enhanced advanced features, such as bootable backups, synchronised volumes and folders, and a Snapshot mode that... Read more
Operate GE’s New Free-Standing KItchen Range...
Think you accidentally left the oven on? Switch it off while on the go. The new free-standing Profile™ Series gas and electric ranges are GE’s second cooking appliances, following their wall oven, to... Read more
Parallels Announces Parallels Desktop 10 for...
The no. 1-selling software for running Windows applications on a Mac becomes an even easier choice for millions of consumers and IT professionals worldwide with the launch of the most powerful... Read more
Apple now offering certified refurbished 2014...
 The Apple Store is now offering Apple Certified Refurbished 2014 MacBook Airs for up to $180 off the cost of new models. An Apple one-year warranty is included with each MacBook, and shipping is... Read more
Best Buy’s College Student Deals: $100 off Ma...
Take an additional $100 off all MacBooks and iMacs, $50 off iPad Airs and iPad minis, at Best Buy Online with their College Students Deals Savings, valid through September 6th. Anyone with a valid .... Read more
MacBook Airs on sale for $100 off MSRP, free...
B&H Photo has three 2014 MacBook Airs on sale for $100 off MSRP. Shipping is free, and B&H charges NY sales tax only. They also include free copies of Parallels Desktop and LoJack for Laptops... Read more
Razer Taipan Mouse For Gamers And Non-Gamers...
If you’re a serious gamer on either Mac or Windows PCs, a serious gaming mouse is a necessity for first-tier performance. However, even if like me you’re not much of a gamer, there’s still a strong... Read more
15-inch 2.2GHz MacBook Pro on sale for $1899,...
Adorama has the new 15″ 2.2GHz Retina MacBook Pro on sale for $1899 including free shipping plus NY & NJ sales tax only. Their price is $100 off MSRP, and it’s the lowest price available for this... Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
Position Opening at *Apple* - Apple (United...
**Job Summary** As more and more people discover Apple , they visit our stores seeking ways to incorporate our products into their lives. It's your job, as a Store Read more
Position Opening at *Apple* - Apple (United...
…Summary** As a Specialist, you help create the energy and excitement around Apple products, providing the right solutions and getting products into customers' hands. You Read more
Project Manager, *Apple* Financial Services...
**Job Summary** Apple Financial Services (AFS) offers consumers, businesses and educational institutions ways to finance Apple purchases. We work with national and Read more
*Apple* Solutions Consultant (ASC)- Retail S...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.