" /> Primordial Ooze: December 2003 Archives

« November 2003 | Main | January 2004 »

December 17, 2003

Musings on the Semantic Web

People who regularly develop web services will not find much of interest in this post since, in all likelihood, they have already "seen the light". I wanted to explore a few concepts here after reading an article on "Publicly available Web Services at Microsoft":http://msdn.microsoft.com/msdnmag/issues/03/12/XMLFiles/default.aspx . Tim Berners-Lee (you may recognize him as the inventor of the Web) once said that, "The Semantic Web is not a separate Web but an extension of the current one, in which information is given well-defined meaning, better enabling computers and people to work in cooperation." Before I knew what the potential for "Publicly Available Web Servers" meant, I thought he was simply referring to XML markup, where the current generation of "dumb" web pages (based on plain HTML) would be enriched with context. The potential I saw back then was simply additional context to existing pages. Say, a news site marked all of their headline copy ("President's dog is found") with special markup such as a "headline" XML element. Local features, entertainment news bites, moview reviews, etc., would all be similarly marked. The wishful part of me was hoping ads would be marked up, but we all know this will never happen. Once the markup was in place, one would be able to write a spider to troll over a site and extract the types of information they wanted. XML markup, as I originally conceived the "semantic web", is somewhat trite when seen in the light of full-blown Web Services. Still, XML markup has it's advantages. For instance, the developer may use the XML markup in ways not originally conceived by the Web Service designers. Now, more on that... I can't remember the first time I heard of the phrase "Web Service", but it was surely before the turn of the millenium. A whole industry was erected on top of the Web Service idea while I was sleeping in ActiveX land. Tools like Weblogic, J2EE, WebSphere, etc. (I've never actually used these technologies so please don't be too critical at my ignorance if you comment on this post!) Companies started using the paradigm to further the reach of their empires, for it's a very empowering technology. My point is not so much the details behind these technologies, which ones are better, nor even what they are capable of. My point is that these technologies seem to be used primarily for proprietary development. Whether a company is facilitating Intranet development or dividing their public-storefront into multiple tiers, the majority of Web Services developed seem to be largely unavailable to the general public (i.e. the average application developer with a compiler and a dream). Lots of signs are pointing to a change in this area. The MSDN article mentioned above kicked off this post so let me explore for a bit what it means to me. The MSDN article talks about four publicly available web services on their site. One service allows you to write a standalone program to get satellite images, another allows you to write your own MapQuest clone, another allows you to manage alerts, etc. The article goes on to say that Amazon and Google have started exposing some services to the public as well. That's the trend I'm hopeful for and for which I see a huge potential. As a developer, I'm used to an entire market of off-the-shelf components that I can use to build a user interface, access a new database technology, or even to access Web Services. However, power will truly be realized when a true public Web Service market is available for Internet-enabled applications. Is the state of the industry beyond infancy? I did a search on google for "Publicly available web services" and didn't find much. Am I missing something? In my head, the industry will have moved beyond infancy when there are as many public Web Service providers as their are tool and library vendors. Here are some ideas: * An application that leverages public recipe services, nutritional services, shopping services, and restaurant services to create diet plans and dining out recommendations that keep people in a healthy lifestyle. * An application that can leverage farms of computers for calculations that the application defines. You buy time on a massive matrix of machines and use them as you wish. The application can gather data on the Internet, possibly from other Web Services and use that data to provide a solution. There's lots of proprietary activity in the grid computing sector, but I personally haven't seen anything as generic and publicly available as I'm talking about here. * An application that combines "live" celestial data collected from the Hubble Space telescope, Chandra, GLAST or whatever, to create an educational space exploration program for students. Currently, this data is purchased in database form, packaged in CD-ROM, and shipped out as a snapshot. If a new celestial event is recorded in the news, the current generation of programs have no real ability to present the new data in ways the user is able to view their snapshot data. * An application that combines mortgage rate information, home availability, broker fees, neighborhood statistics, and lifestyle data on a regional or national level. Lots of small proprietary solutions exist in this area, but there is no opportunity for a third party to create a best-of-breed solution with user-defined algorithms. * Same thing for investments. A Financial Consultant might want to have a developer write her an application which combined publicly available financial data in ways that is unique to her style and not currently available anywhere else. * Etc. Many services will never appear unless there is a business model to support them. I can't see that being too huge a problem since tool and library vendors currently have a pay-for-use market that works. I'd be interested in hearing about any roadblocks in this area.

December 11, 2003

NewsGator Post Test

This is a test. If you see this, I was able to post a blog entry from within NewsGator. Source Code test. Probably won't work since TextTile is not used...
public class foo {
    public static int bar = 10;
}
This is a monospace test.

December 9, 2003

Learning C#

I was asked today to recommend a good book on C#. Harking back to my Windows and COM/ActiveX days, I always heed the words of Jeffrey Richter and Charles Petzold. These two pioneers authored such seminal works as "Advanced Windows":http://www.amazon.com/exec/obidos/tg/detail/-/1572315482/ref=pd_sim_books_3/104-4160386-0064736?v=glance&s=books and "Programming Windows":http://www.amazon.com/exec/obidos/tg/detail/-/157231995X/qid=1070973876/sr=1-1/ref=sr_1_1/104-4160386-0064736?v=glance&s=books, respectively. Recently, they've authored new works on .NET and C#. Jeffrey Richter wrote "Applied .NET Framework Programming":http://www.amazon.com/exec/obidos/tg/detail/-/0735614229/qid=1070973763/sr=1-1/ref=sr_1_1/104-4160386-0064736?v=glance&s=books" and Charles Petzold wrote "Programming Windows with C#":http://www.amazon.com/exec/obidos/ASIN/0735613702/qid=1070973876/sr=2-1/ref=sr_2_1/104-4160386-0064736. Neither of these sources is really meant to teach you C#. One suggestion would be to start at the source, Microsoft has the "C# Langauge Reference":http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cscon/html/vclrfGettingStarted_PG.asp online. Another suggestion is to look at "O'Reilly Associates":http://oreilly.com. O'Reilly has proved an excellent source of quality books for many years. I haven't read any of their books, but I'm seriously considering "Programming C#, 3rd Edition":http://www.oreilly.com/catalog/progcsharp3/index.html by Jesse Liberty and "C# in a Nutshell, 2nd Edition":http://www.oreilly.com/catalog/csharpnut2 by Peter Drayton, Ben Albahari, Ted Neward. O'Reilly has an "entire section":http://dotnet.oreilly.com/ dedicated to .NET. They also sponsor an interesting "C# Learning Lab":http://oreilly.useractive.com/courses/csharp/. Other books on C# include "C# Cookbook":http://www.oreilly.com/catalog/csharpckbk by Stephen Teilhet and Jay Hilyard, "C# Essentials 2nd Edition":http://www.oreilly.com/catalog/csharpess2 by Ben Albahari, Peter Drayton, and Brad Merrill. O'Reilly has an excellent resource for evaluating and reading books on line in their "Safari Bookshelf":http://safari.oreilly.com/ . I have an account and I recommend looking into this great service. I'd love to hear about some personal recommendations. Aside from the "Microsoft Developer Network Web Site":http://msdn.microsoft.com and Applied .NET Framework Programming, I haven't read any of these books. I'm just as curious as anyone on where to start reading next...

December 8, 2003

C# Patterns

There has been a lot of discussion on applying "Design Patterns":http://hillside.net/patterns/gang_of_four.html to the C# language. I found many useful links on the C2 Wiki entitled "CsharpPatterns":http://www.c2.com/cgi/wiki?CsharpPatterns . The point of this article is to explore how C# langauge features can be leveraged when implementing patterns. I'll start with a few examples in C++ and Java before I describe some of the advances available in C#. The "Singleton Pattern":http://www.c2.com/cgi/wiki?SingletonPattern , for instance, is commonly implemented C++ as: == class Singleton { public: Singleton() {} Singleton& getInstance() { static Singleton singleton; return singleton; } protected: Singleton() {} }; == The approach is very explicit in it's aim to create the first instance of the singleton with it's first use (a call to getInstance()). This approach could have serious problems in a multithreaded environment as two pieces of code on two different threads might be able to create two instances of the singleton. A simple workaround would be to instantiate your singletons before your threads start up... In Java, many applications choose to use the double-checked locking mechanism as illustrated by the following example: == // Broken multithreaded version // "Double-Checked Locking" idiom class Foo { private Helper helper = null; public Helper getHelper() { if (helper == null) synchronized(this) { if (helper == null) helper = new Helper(); } return helper; } // other functions and members... } == You can plainly see that Java enables synchronization with the synchronized keyword. However, the "article":http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html that the code was copied from explains how this approach is flawed. Read the article for the full discussion. Consider this almost trivial implementation of the Singleton Pattern in C#: == // .NET Singleton sealed class Singleton { private Singleton() {} public static readonly Singleton Instance = new Singleton(); } == This approach is also possible in Java, but there is a subtle difference in the two implementations. In Java, the singleton gets instantiated when the class is loaded. In C#, the singleton gets instantiated the first time the Singleton member is accessed (much like static allocation in C++), lazy instantiation. In addition, the .NET Framework guarantees the thread-safe initialization of static members. This is a common task that's finally automated and enforced by powers other than our own diligence. I welcome that. The sealed class modifier is used to prevent Singleton subclassing, something the "GoF":http://hillside.net/patterns/DPBook/GOF.html describe as dubious and prone to error. Credits: "Exploring the Singleton Design Pattern":http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/singletondespatt.asp by Mark Townsend "The C2 Wiki":http://www.c2.com/cgi/wiki

December 2, 2003

Feel the code

I decided to do all of my work using command-line tools and the "TextPad":http://www.textpad.com editor. I came into programming using command-line tools and I suppose old habits die hard. Granted, the Visual Studio .NET IDE is terrific. I plan on using it once I've felt enough code, but naked code seems the best way to learn how everything works. The first step was to get syntax highlighting for C# source working in TextPad. Although I've been aiming at naked coding without the IDE, a little lipstick goes a long way. TextPad has syntax highlighters for most languages. You can get a "C# Syntax File":http://www.textpad.com/add-ons/syna2g.html on the TextPad web site. Once you download the file, you simply need to copy the file to a Sample subdirectory off your TextPad installation directory. Launching the command-line tools from within TextPad was next on my list of required amenities. The main impetus for my effort in this area was the ability to double-click on a compiler error and be brought to the offending line of source. Yeh, my efforts are beginning to sound like I really miss the IDE. I could compile in a command-prompt, but I'm not a barbarian for pete's sake. I learned quite a bit about assemblies and the way they're loaded by the C# compiler. My initial programs were simple, so the default core assemblies were all I needed to compile and go. However, as I started requiring the various managed DirectX components, I needed to find these on my hard drive. I did find them, but they were buried deep within my C:\Windows directory. I found the ones I needed and copied them to C:\SharedAssemblies. This made my command-line simple. I added the
/lib:C:\SharedAssemblies
option to the C# compiler and I was able to refer to the managed DirectX components via a simpler syntax: /r:DirectX.Drawing (or whatever), without re-specifying the entire path. I suppose I could have utilized the GAC (Global Assembly Cache) but since the default install didn't already install these there, I got scared and punted on the issue for now.