Saturday, September 16, 2006

I probably should mention that IronPython is probably the ultimate example of alternative languages for the .NET framework.  It was developed first independently then in cooperation with Microsoft.  Microsoft made IronPython team member Jim Hugunin part of the CLR team.  Not a bad recruitment strategy, how many people can claim to have worked on porting a language to the .NET framework successfully.  IronPython seems to have all of the major .NET 2.0 features which Boo is still missing but Nemerle is way ahead on because Nemerle also has the C# 3.0 features. 

So IronPython looks pretty good if you're a Python fan.  I myself don't care for Python.  There is no particular reason to dislike Python, I'm sure it's a perfectly fine language.  I've played around with it a little bit but didn't find anything that convinced me that I needed to make Python part of my arsenal.  It's a nice enough scripting language along the lines of Ruby.  Which brings me to another point that I didn't mean to get to:  Languages seem to pick off the most converts from languages that are very similar.  For example, C# is about 95# Java and so someone who knows Java would feel at home in C#.  I think the same can be said very generally about Perl and Ruby but not to the same degree.  I think Python and Ruby are going to compete in the same niche but I don't really see the difference between them besides the syntactic niceties and some miscellaneous differences. 

I wonder if there is a biological law or principle about this?  I thought I remember learning about this at some point.  The principle is something like the individuals most like you will compete for the same resources.  Nursing kittens with compete with their litter mates for the limited resource of their mother's milk.  I think this is true for languages.  I come across some language projects that make me wonder why someone would want to do that.  What is reason someone would need another scripting language let alone another general purpose language (C, C++, Java --> C#,J#,J++,Visual Basic)?  One valid reason I can see is that it targets another platform like Unix or Windows or a mobile device or perhaps it offers some powerful language feature that can only be accomplished in a new language.  Or perhaps the old language is controlled by a competitor or some similar entity and simply extending it is not possible nor feasible. 

Many people complain (wrongly IMHO) about JavaScript.  I think it is a very elegant language once you understand how it works and what you want to do with it.  JavaScript (ECMAScript) was built for a new platform, the browser.  It also makes a fairly decent and powerful replacement for VBScript for Windows scripting using Windows Script Host (WSH).  So I see the point of that language.  But WTF is up with JScript.NET?  What is the point of this bastardization and castration of a perfectly good language?

Some languages like Java and Ruby had the intent of making Lispy features available to the Average Joe.  This may be blasphemy but I don't think Lisp is all that difficult to comprehend.  What is difficult to comprehend is all the hoops you have to jump through in Java, C#, etc to get quasi-Lispy stuff (see Reflection). 

So with IronPython we have another example of bringing an existing language to the framework instead of using that effort to get a better language for the .NET framework.  The more I think about it the more I think that Nemerle is a LFSP whereas something like C# is more of a safety language. 

The .NET framework and the CLR are powerful tools and a language like Nemerle shows us what is possible.  IronPython shows us what was possible ten years ago. 

Disclaimer:  I make my living writing mostly C# code at this point.  I have also made money with Java and Visual Basic in the past.  I have not made any money or with non-average languages...yet.

Saturday, September 16, 2006 2:52:03 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Friday, September 15, 2006

I think when Microsoft introduced .NET and the declared that you where free to write in any language most people focused on bringing old crusty languages like COBOL to the modern .NET framework.  I'm not sure how successful this has been.  I'm not being critical, I simply do not know because I use C#, arguably the most mainstream of the .NET language families.  For the past few years I have flirted with languages like Ruby and Lisp and found some of the features of these languages to be intriguing.  C# is fairly powerful and is still being extended by Hejlsberg and company and is even starting to stretch into some Lispy areas with features like LINQ.  What I miss most in almost every language is the Lisp style macro.  These things are powerful, if you don't know what I'm talking about you need to check out Peter Seibel's Practical Common Lisp book.  Once you implement the MP3 database in Chapter 3 you should have a good idea what macros can do for you and your coding, especially if you write a lot of repetitive code (hint: database access, DAL, etc). 

The problem is that even thought I enjoy Ruby and Lisp the implementations for these languages are hit and miss.  The open-source implementations all feel like second class citizens on Windows XP.  Using Emacs as a text editor for Lisp when you are used to Visual Studio 2005 is a little disappointing.  Using GVIM to edit Ruby on Rails files leaves me with a similar sense of dissatisfaction.  These are great languages without great tools and with hit and miss implementation issues.  I have to say however that I am fairly comfortable with some of the commercial Lisp Implementations with LispWorks being the best all around when you consider licensing. 

Back to my point, I did not set out to author a diatribe on Lisp and Ruby, and I will leave that to the Flamer and the Flaming Flamed.  My intent is to write about two rather new languages that give me a lot of hope for the direction and potential of CLR languages: Boo and Nermerle.  Both of these languages support cool syntactic macros and add their own little twist to CLR programming.  Boo is about agility and keeping the code lean and clean and uses macros to support this concept.  Nemerle is a hybrid functional language very similar to C# but with the cool functional stuff like Pattern Matching and also C# 3.0 features.  What is interesting is the C# 3.0 features are implemented in the C# compiler and does not require support from the CLR.   CAUTION GENERALIZATION AHEAD!  Lisp macros are simply code that runs at compile time instead of run time.  So we are doing things in C# that sounds like an area where macros could make a huge impact.  In fact this is how Boo and Nemerle implement many of their advanced features, they are simply using macros.  So Greenspun's 10th Rule plays out again this time inside the CLR.  In fact if we design a language with Lispy-ness in mind we know that we need very few constructs to develop a very powerful language and I think Nemerle especially takes advantage of this fact.

These languages are not designed by Microsoft.  They are independent languages targeting the CLR.  So yes even though we are coming back around to Lisp, I for one am not disappointed but rather quite pleased.  If I can get the power of Lisp on a framework like .NET then I will be a happy camper.  I'm waiting for the tools around these languages to mature a bit and at this point I'm leading more towards Nemerle because it seems to be farther along and very well documented.  Once a plug-in for Visual Studio 2005 becomes mature I will definitely spend more time playing with this Nautilus machine for the mind. 

So all I want is a great language and great tools and I will be happy.  Is that really so bad?

Friday, September 15, 2006 8:44:52 PM (Central Standard Time, UTC-06:00)  #    Comments [0]

You may have noticed that I have added Google Ads to the site.  This is more of an experiment than anything else as I wanted to see how AdSense works and the best way to learn about something is to try it.  Obviously this is not a high traffic site but it has been up for a while and there is some very (if I so say so myself) high quality content so I might get some search traffic now and then.  My goal is to make enough to pay the hosting bill of the site and hone my SEO abilities so that I can make my other sites better.

If you have a blog I would encourage you to try AdSense or the sponsored search and see if it can take the sting out of your hosting bills.  You never know, you may find a new source of revenew that you can introduce your clients to and thus enhance thier profits and yours. 

Friday, September 15, 2006 7:59:27 PM (Central Standard Time, UTC-06:00)  #    Comments [0]

In the upcoming articles I will showcase my new PC and how I went from a bulgin' beige box o' noise to a sleek powerful dual core system that is not only fast but also nearly silent.

For now I will tell you that I bought the main system from EndPCNoise.  I believe I came across them as I was checking out SPCR

Friday, September 15, 2006 7:41:39 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Wednesday, September 13, 2006

I have some large text files that I want to compress.  The key is that I want to keep them as separate files.  Let's use a little PowerShell scripting to keep this down to one line:

foreach ($file in ls *.txt ) {  & 'C:\Program Files\7-Zip\7z.exe' a ($file.name + '.zip') $file.name }

I'm using a simple foreach construct built into PowerShell.  I'm saying get all files in this directory that have a .txt extension and then iterate through those files executing whatever is between the curly brackets.  In this case it is the command to use 7Zip to compress the file into a new file named the same as the original file with the .zip extension tacked on the end.

 

Wednesday, September 13, 2006 12:08:23 PM (Central Standard Time, UTC-06:00)  #    Comments [0]

If you've ever wanted to BCP from inside a stored procedure here's how:

DECLARE @FileName varchar(50)
   ,@bcpCommand varchar(2000)
   ,@YearMonth char(7)

set @YearMonth = '2006-04'
SET @FileName = '\\server\share\folder\'+ @YearMonth +'.txt'

SET @bcpCommand = 'bcp "SELECT * FROM Northwind..tblSomeTable where SomeField like ''' + @YearMonth + '%''" queryout "'
SET @bcpCommand = @bcpCommand + @FileName + '" -U sa -P password -c'

print @bcpCommand
Exec master..xp_cmdshell @bcpCommand


Notice that in this example the BCP is using an sql query to filter the exported records.  Also notice that I am using the same filter as the name of the exported file.

Wednesday, September 13, 2006 11:43:15 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Thursday, August 24, 2006

Filed under WTF?, this one is a goody.  I recently bought a new PC (which is really quiet and I need to write about it) and I installed Windows XP with SP2 and got it all patched up with something like 50-60 downloads from Windows Update and everything was good.  I thought so anyway.  I went to run something using the windows key + R combination and the trusty Run dialog popped up but I couldn't access it instead I had to click on it to gain focus.  What the hell?  So I tried to google on this phenomenon but no joy.  I finally recalled that this seemed to be an issues with Windows not allowing windows to grab focus.  So I downloade good ol' tweakUI and fixed it right up.

 

Sometimes the little things make all the difference.

Thursday, August 24, 2006 9:11:05 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Wednesday, August 23, 2006

I was testing a new caching implementation for the 20 when I noticed that items I placed in the cache were not staying in the cache.

I ran into this yesterday and luckily I realized what was happening before I did something drastic.  The ASP.NET caching facility automagically dumps items out of the cache when roughly 90% of your physical memory is in use.  So a laptop with 1 Gig of memory has a pretty good chance of seeing this happen.  Load up Visual Studio 2005, Firefox, IE6, the ASP.NET development server and have SQL server running and you are going to get pretty close especially after you've been running all day without restarting any programs or the computer.  The two biggest offenders are typically Visual Studio and Firefox in that order.  In the defense of Firefox I usually have about 15 to 20 tabs open and I have about 15 extensions installed.  Visual Studio can chew up about 400K on its own with all of its child processes running around checking code, looking up help topics etc.

The moral of the story is to shut everything down and then bring it back up so that you have some room cleared out in memory for the obects you want to cache in memory.  Seems like a no  brainer when you think about it.  This is also a good reason to have at least 2GB of memory in your development machine.  That's right TWO Gigabytes of memory.  Someone at work thought I was crazy when I bought my new home machine with 2GB already installed but after using Visual Studio for a while I knew it would come in handy.

 

 |  |  | 
Wednesday, August 23, 2006 11:35:21 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Friday, August 18, 2006

Here's a piece of JavaScript code that allows you to format strings in a style similar to C#.

String.prototype.format = function() {
   var params = String.prototype.format.arguments;
   var toReturn = this;

   for (var i = 0; i < params.length; i++) {
      var regex = new RegExp("\{" + i + "\}", "g");
      toReturn = toReturn.replace(regex, params[i]);
   }

   return toReturn;
}

Original Source:  http://chapnickman.com/2006/02/10/string-formatting-in-javascript/

I love this because I can program in a style in which I am familiar.  However does this reduce portability or can it lead to a collision?  If we all add our own little extensions to the built in objects will we end up with a uncooperative mess?  This comes to mind because of the way the very popular prototype javascript library extends the build in JavaScript objects.  Some people people criticize prototype.js pointing out that is monolithic or bloated and lacks documentation.  While it is rather large it is also very powerful and everthing works together.  I don't have to include 5 different libraries from 5 different authors and hope that they work and play together nicely.  The documentation criticism is certainly legitimate as the author provides very little documenation.  However many sites have posted articles and even whole user guides that have come in very handy. 

I haven't even discussed Scriptaculous yet.  Scriptaculous is a visual JavaScript framework that uses Prototype for a foundation.  I have used this library for several sites and it works well and that is the whole point.  Both of these frameworks Just Plain Work!  I don't have to cobble something together each time I need a visual effect or an AJAX updater I can just use something in this toolkit. 

There is something to be said for re-using the same set of tools.  You become very proficient with those tools over time and you can use them more effectively as your experience grows.  I find this especially true of using the .NET framework also. 

You can't get anywhere by reinventing the wheel each time you need to build a cart.  Use other people's experience and work as a foundation for your own and become more productive. 

Friday, August 18, 2006 9:51:05 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Sunday, July 23, 2006

I've noticed a habit of mine recently.  I have a tendancy to open up a web browser and/or and email client when I first log into my home or work computer.  I do this out of habit, just like a check the mailbox for new mail when I get home from work.  The email thing is not such a big deal because I usually just delete the junk mail and take care of the few items that actually need my attention.  The web browser on the other hand can be quite the menace.  The web browser coupled with and RSS aggregator such as www.netvibes.com can be a real productivity killer.  Before I'm really aware of it, I'm reading some blog on libertarian economic thought or browsing through www.techbargains.com drooling over a new piece of hardware.

So What can I/you do about this?

Open up the IDE first.  I'm assuming you're using an IDE (Integrated Development Environment) but you could also be using VI or Emacs or Excel.  The point is that you should open up the IDE first and just start working on something or anything really just to get started.  I find that once I get started on a task I've won half the battle.  Once I'm really working on a task I slip into concentration mode and can focus on a problem and I'm usally very stalwart in searching for the solution.

Have your essentials near at hand.  You want to have your cup of water|joe|soda full and within reach before you put on your headphones and slip into the zone.  Once I've got my glass of water and my headphones are on I'm safe.  I can usually code for at least a few hours like this before I need a bathroom break.

Make sure to read Part 2 about staying in the zone which is almost more difficult, especially if you have non-coders in your work environment.

Sunday, July 23, 2006 7:41:42 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Wednesday, July 12, 2006
Here's one that I've used several times in the past.  Microsoft has a virtual CD Control Panel that let's you mount an ISO image as a drive letter.  This is really handy if you have an MSDN subscription and are constantly downloading ISO's from the MSDN site.  Instead of burning each ISO to a CD you can keep it on a local or network drive and simply mount it as needed.  This will save the cost of a CD and the clutter of having a bunch of CD's laying around.

I've tested this only under Windows XP.

Here's the link:
Virtual CD-ROM Control Panel

This one is destined for the Pragmatic SDK.

Wednesday, July 12, 2006 8:44:05 AM (Central Standard Time, UTC-06:00)  #    Comments [1]
 Monday, July 03, 2006

Visual Studio 2005 is pretty useable on its own.  MS has really done a good job and the studio is one of the reasons I stay on the MS platform.  I've used Java, Ruby etc and I ended up using eclipse for my IDE and while it does a decent job it also seems to have heavy system requirements and theres the feeling that everything is kind of duct taped together  But I digress, the reason for this post is to highlight tools that make Visual Studio even more useable.  So Here they are:

1. Cool Commands

Everything except (including?) the kitchen sink

Adds context menu commands like open project folder etc.  It just keeps getting bigger and better.  You have to try it to get the full effect.

Most Recent version of Cool Commands

2.   CopySourceAsHTML

Ultimate Blogger Tool

If you have a blog and who doesn't these days, you should look into this one.  It lets you copy souce out of Visual Studio and keep the code formatted as HTML which is very helpful if you are trying to post code to a blog.

CopySourceAsHtml

3.  Smart Paster

The easy way to embedded SQL, JavaScript, etc

This one gives you multiple Paste As... options in the context menu.  Helpful for pasting inline SQL (oh my), JavaScript, XSLT, etc.

Smart Paster

 

 

Additional resource for Visual Studio 2005 Add-Ins

Monday, July 03, 2006 9:26:57 AM (Central Standard Time, UTC-06:00)  #    Comments [0]