Wednesday, October 17, 2007
Michael Feathers asks if syntax is important.

I think the answer is maybe.  Certainly a language with a familiar syntax will allow you to pick it up faster if you have already learned a language with similar syntax.  For example, I found Java very easy to understand since I had a background in C#.  

Of course, there are the countless winers who complain about lisp's syntax or lack thereof. 

One tricky point is syntax that is legal in one language but not so in another.  I constantly found myself typing foreach in java just to be kicked in the head by the compiler.

I think syntax really matters for the first month or so of learning a new language.  Once you get beyond that you are able to "think" in the new language and your ideas start showing up in your new language.

Wednesday, October 17, 2007 12:35:21 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Monday, October 15, 2007
Technically its more like a few hours spread over a week but so for so good.  I've come to begin to understand functional concepts.  Currying and partial application now seem to be rather easy to understand but hard to explain to someone else. 

However, what I really love is not necessarily the functional aspects, rather the terseness of the language.  I especially like type inference.  I'm not sure why we couldn't have had that sooner in C#.  In languages like C# you expect an IDE to be present so it works really well in situations where you have a toolset to back you up.  It also works really well in scripting languages (Ruby, Python, etc).  However, with F# (and OCaml) you get the benefits of strong static typing with the benefits of less typing.  I really like it.

It seems that many concepts are just simpler in F# rather than C#.  I also see cases where it is easier to define a smaller single use type (like when you query a small set of data from a database) than to declare a full blown class.  I think many times I've found it a pain to create a whole class when I really don't need to reuse it.

Again, these are just first impressions.  Things may change as I get farther into the tutorials and learning processes.  I find F#/OCaml very easy to learn.  As I was working on Scheme/Lisp it syntax always felt alien.  I was learning a lot but it didn't fell quite right.  F# just seems to feel good.  Probably because it is close to C# in some ways.

I really need to get into a small project with it to see if I really like it.  Once I have a real world application under my belt I can usually tell if I'm going to keep a language in my toolbelt or put it back on the shelf for another time.

I also think I have a solution for the ASP.NET development.  I'm going to use ASP.NET without ASP.NET...  (I'll explain more in the future, but if you read some of my previous posts, you can probably figure out what I'm going to use.)

Monday, October 15, 2007 7:39:46 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Friday, October 12, 2007

ProMesh is too immature at this point to complete the project I am working on. I think given a few weeks or months this framework will be top notch.

Right now however I am constantly getting the latest version to get around some bug only to discover another bug. I don't want to come across as negative about ProMesh.Net, again I think it will be one of the best frameworks out there once its matured a bit.

-- Update --
Again, to make it clear I think ProMesh is a good framework.  I have released a small project with it and it workds great.  My problems are with the validation scheme that changed and a looming deadline.  I am still using it for other projects.  My rants below are about me screwing around too much and finding myself short on time and having to use WebForms.
-- End Update --

Back to the present, I need to get work done. I have spent a little too much time playing with ProMesh and some various other languages and frameworks. I neeed to get some work done. So I'm back to ASP.NET WebForms.

It's telling how poor WebForms are as I can barely get a simple form working correctly. Control postbacks and the whole business is absolutely frustrating. I want to make a form that changes which controls are displayed based on the value in a drop down box. Simple right? Wrong. I'm once again battling the stupid page lifecycle. Is this really the best we have?

I'm looking forward to seeing Microsoft's MVC for ASP.NET. I hope that takes .NET web development in the right direction.

Many people compare WebForms to WinForms. Something about WEbForms being VB6 on the web. Well I can tell you VB6 was never this unecessarily complicated. Good grief.

I think it's a bad sign when you spend 80 percent of your development time working around your framework instead of with it.

Friday, October 12, 2007 1:02:04 PM (Central Standard Time, UTC-06:00)  #    Comments [0]

My latest language is F#. After considering PLT Scheme for my latest side project I thought I should do some more investigation first. I had briefly considered Factor. While Factor is coming along quite well, It's not quite ready for prime time.

I remember looking at Ocaml because of the speed and type safety of the language. However I was initially turned off by the syntax. I then moved onto Python. I think Python's syntax is clean but I miss compile time checking for errors.

So after seeing another post on F# on Reddit, I decided to check it out. At this point it all come back to me. F# has a Visual Studio plug in. You get intellisense and all kinds of nice features. There is even a top level REPL (Read Eval Print Loop) that lets you test out code very easily. I had decided against Boo because it lacked Visual Studio support and #Develop doesn't quite do it.

I dug into a few Ocaml tutorials (yes, these work very well for F#). I soon found myself loving the language as I began to understand the power that these ML derivatives have. All I can say is wow.

F# lets me use the years of built up C# libraries and expertise I have, yet also write powerful and elegant code. I do say I like the syntax quite a bit better than Scheme. I hate typing all those () as they tend to make your fingers hurt:-)

Now I just need to figure out the web story for F#. It appears that you can use it with ASP.NET but I need to do some more research.

Friday, October 12, 2007 12:50:03 PM (Central Standard Time, UTC-06:00)  #    Comments [1]
 Thursday, October 11, 2007

Everytime I try a new language or technology I eveluate it based on what it can do for me. Will it make more productive or will it teach me something. I'm not a big believer that learning language X will make you a better programmer in language Y. I think there is some truth in that but not as much as some would lead you to believe.

Above all else, I look for pragmatic solutions. What can technology do for me? I think Ruby on Rails is a decent example of pragmatic software. It has its flaws but in the right scenerio I think its a very practical solution.

So when I go down the rabbit hole with some new language/platform, etc, I'm looking for benefits. I know what C# and ASP.NET can do for me. I've used them long enough to know the ups and downs and i'm constantly looking for ways around those low points. ASP.NET webforms is a great example. I hate using them. In anything but the most simple situations, they break. They "leak" in that they are not the best way to abstract the web. They represent the underlying web server event cycle more then anything. And they are painful to use.

I've looked at Boo, Nemerle, F#, IronPython, L#, Cat and probably some that I can't remember JUST in the .NET realm. This doesn't include my research into Lisp, Scheme, Scala, Factor, Ruby, etc. These .NET technologies have other benefits like cross platform abilities that make them attractive. With the .NET languages/tech, I'm looking for ways to solve or alleviate my C#/ASP.NET pain.

Boo seems to be a good language. It lacks good Visual Studio support though. This means I lose productivity to gain a cool language.

IronPython has a sweet spot in scripts and possibly web pages. I like the quick turnaround of editing a script and seeing the results without the long compile time.

On the framework/library front there is ProMesh.NET and MVC framework that replaces WebForms. It's pretty good but it still has some bugs. There is also MonoRail but I haven't gotten the courage and the time to test it out. It looks massive and I don't really get Inversion of Control and Dependency Injection yet. However, they sound odd and a bit scary. Do I really need them just to have a decent web framework? I don't need these in PHP.

A solid win on the ORM front is CoolStorage.NET. This thing blows the doors off of anything else I've used bar none. It is the optimal combination of light weight yet powerful features. I think CoolStorage wins by being a C# first project. It is not a clone of a Java project. CoolStorage takes advangtage of attributes and generics to produce a terribly productive product.

So with one win and so many that qualify as so close yet so far, what is a practical programmer supposed to do? The only thing I can do is spend hours testing out new languages and frameworks to see if there is anything out there. At least at the end of the day, if I don't find anything, I know that C# is king and I'm not left wondering.

So I must continue my crusade for the best even though most days its a big pain. I've recently found F# and it looks very nice. Visual Studio support, a real REPL and syntax and conciseness like a scripting language yet with a typing system more powerful than the one in C#.

So yes, these little discoveries are worth all the pain of downloading, installing, and compiling countless new programs. I can put my mind at ease and keep up on the latest developments. In the end there is something to be said for intellectual stimulation and if there is practical use then all the better.

Thursday, October 11, 2007 8:49:30 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Saturday, September 22, 2007

Talk about a word until it makes no sense.  Why would you do this?  This is much of what philosophy seems to consist of, attempting to reach the absolute definition of a word with zero ambiguity.  While a neat intellectual exercise, there exists a threshold where this ceases to be useful for most humans.  Typically most words can be defined in a short phrase.  This suffices to give us a mental picture of what a word is meant to convey.  In fact passing this mental threshold might be somewhat harmful.  There be dragons there. 

We can draw a parallel to programming or to program design.  Consider a database schema or a UML diagram of a painstakingly designed class hierarchy.  Each quantum of information neatly defined in terms of other types, just as a word1 is defined by other words.  Each word defined to the point of lowest ambiguity.  At least this is the intention of the designer if one follows the typical methodologies for such things.

However, is there a need to leave ambiguity in the system?  Can we equate ambiguity to abstraction?  On some level abstraction and ambiguity are linked. 

Consider the need the most organisms have for ambiguity in their perception of their environment.  Humans do night see all spectrums of light.  We do not hear all frequencies of sound.  The human eye cannot distinguish every possible shade of color.  If you say a restroom is for woman, your brain can picture the type of person that may enter that room.  The general class of woman is sufficient for the needs of blocking males from entering the females restroom.  Our brains have the ability to remove unneeded information so that we can concentrate on what is important.  

This is the crux of the issue.  This is abstraction.  Instead of dealing with the billions of women on the planet, we can deal with the one class of women.  We abstract away the complexity and gain ambiguity.  If we say that all women have long hair, we over specify the general case of women and lose the power of abstraction. 

What information is important in our system and how much do we really have to specify it.  Is it enough that we know that something is a series of characters forming a string?  Is a person’s name a series of fields like prefix, first name, middle name, last name, and another series of suffixes?  Or is it simply one string of characters?  

Let’s examine the first case.  In a large organization there is often a design or architecture team.  This team is typically obligated to define an organizations data.  The team most likely will tend to choose the multi field very explicit representation of a person’s name.  After all, what is there job but to minimize ambiguity and maximize specificity? 

In the second case a lone hacker with a deadline may decide that one long database field is enough to store the name.  This is most expedient and it gets the job done. 

Why does the lone hacker’s system survive longer and cause fewer problems?  Consider the first case again.  Most likely we will have to define a suffix table where every known suffix (Jr, Sr, MD, CPA) is defined.  After all a user must now choose this from a dropdown.  Also the prefix must be entered.  We will need another table to define these.  What happens with a person who has two middle names?  Do we define another column?

It appears that even in the simplest data point definition we have run head first into mushrooming complexity.  How long do you think the design meetings will take JUST to determine how to define a name?  I’ve been in on this and it can take a surprisingly long.

The lone hacker has written most of his system by the time the committee has determine the proper representation of each data point in the system. 

The fact is that ambiguity or rather the ability to handle ambiguity is a feature of a system not a flaw.  Many times the ability to handle ambiguous data from a user or external system saves a monumental amount of redesign and rework.  An example would be a company that decides to open a foreign branch and now must handle names in a different format.  Do we need to redesign our system or does it just work?

A caveat here is the interfacing to other (broken) systems that require the data to be split into small pieces and fed in.  A partners system requires first and last names.  Is this a problem?

It can be.  One solution is to parse the name field.  Ninety percent of the names will probably be first and last name only.  This is because most users are lazy and only want to enter the minimum amount of data.  Some self absorbed types are going to enter every credential in the list including their Boy Scout merit badges.  Now we may have to kick back this data to a human to look and correct.  Last I checked data entry was cheap, programming was expensive.  A great solution?  Maybe, maybe not.  How much money did your design team burn by arguing over what should be in the prefix and suffix table? 

In the age of search, ambiguity becomes more useful.  If we can search on any field in the database than I no longer have to use last name to organize a list of people.  Searching for them may work much better.  Or it may not and you find that you want a separate first and last name field.  

Of course if your requirements call for separate fields because they must be fed to another legacy system, then by all means specify two fields.  You have a valid reason to do so this increases the coherency of the system.   My point is about over specification in the absence of requirements.  

In the absence of requirements, don’t over specify.  Creating unneeded complexity in a system does not benefit anyone.  Ambiguity, as a facet of abstraction, provides the designer a way to deal with complexity or at least to mitigate it.

 

1-In fact languages like Forth or Factor call the smallest unit of execution a “word.”  The word in such a language is equivalent to a function in the more “mainstream” languages.

Saturday, September 22, 2007 9:52:04 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
    Discuss how the addition of attributes can be seen as adding adverbs or adjectives to a language. 

Saturday, September 22, 2007 8:51:39 PM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Thursday, July 19, 2007

Joel on Software's admin dude wrote a post about how they are doing db backups. 

http://www.michaelgorsuch.org/wordpress/2007/07/11/some-times-you-have-to-roll-your-own/

Funny thing is that this is how all databases fundamentally perform backups.  Just makes me think that once you get X years under your belt you come to the conclusion that you've seen it / know it all.  Fundamentally, this stuff is simple, the problem comes into play when MS (or vendor of choice) tries to layer multiple extra layers of shite on top of a simple concept.

Html, javascript, css are easy (compared to multi-threaded servers and C++).  ASP.NET makes them much more complicated then the have to be.  I'm currently in the process of removing all of the ASP.NET AJAX CRAZY framework out of the whatsyour20.com as it's just too damned complicated for what you get.  Also I think the ASP.NET page life cycle is ridiculous.  We stopped teaching ASP.NET for web development at the college I used to teach at because it was just too hard for students to figure out.  Ironically, MS made ASP.NET follow the desktop paradigm to get the Windows Forms dudes (like myself) to buy in, which caused ASP.NET to become almost incomprehensible for those that wanted to learn web development without having any desktop experience. 

There is a reason PHP and MySQL are so popular.  Simplicity has a place and that place is HUUUUUGE.  It's a big house on the hill overlooking the lake with a great view. 

The point of this rant is that sometimes we make things so complex by trying to make them simple.  Instead are we perhaps better off if we let the complexity stay were it needs too. 

ASP.NET missed being one of the best pieces of software ever designed.  Why?  Page lifecycle (why must i figure out if i need init, load, pre init, pre load after load, after init, and the if (postback == false) { madness).  The dirty little secret about ASP.NET is that nobody needs a freakin' data grid!  They are completely useless.  Html tables are easy to make.  Grids are ridiculous and bloated and don't support Ajax worth a damn. 

Why I'm at it I should rant about how SQL Server 2005 leaves out features already in 2000.  But this post is getting too long as it is.

ASP.NET needs a sane alternative implementation that works with the web instead of against it.

 |  | 
Thursday, July 19, 2007 9:52:46 PM (Central Standard Time, UTC-06:00)  #    Comments [1]
 Wednesday, May 23, 2007
There is a discussion over at Scott Hanselman's site about URL Rewriting in ASP.NET.  I found a similar article about URL Rewriting in ASP.NET on Coding Horror


Synopsis:

Here is a brief synopsis of the problem.  In order to have an http module or handler take care of your url rewriting you must have all requests sent to aspnet_isapi.dll via application extension mapping in IIS 6.

Here is an example:

I want http://whatyour20.com/modules/view-location.aspx?locid=1234

to instead look like:

http://whatyour20.com/locations/yellowstone-national-park/

I do this for several reasons.  The number one reason is SEO.  We want google to give google a good idea of what this page is about.  Obviously the latter url does the much better.  It also gives the users an idea of what the link is about.  Number two, it makes our links hackable.  Number 3, it makes our links more aesthetically pleasing.  I think that is very important.  If I see a url that is meant for people instead of machines, I know the web site creator took some time to dot every i and cross every t.  Number four is the less likely option that I will switch technologies and I don't want to lose all my links and there associated page rank if I switch to a new technology or if Microsoft changes thier extension in the future when the next great thing comes out (Silverlight Foundation Server Pages Advanced with SteelRuby, LOL). 

At whatsyour20.com we use UrlRewritingNet.UrlRewrite to handle all url rewriting duties.  UrlRewrite is an asp.net http module that can rewrite any incoming url and it can handle redirects (301, 302).  This works great but it doesn't get rid of the aspx extension by itself.  In fact no http module or handler can do that because iis uses the file extension to determine which program should handle the request. 

So we need to have IIS route all requests for the domain (http://whatsyour20.com) to the aspnet_isapi.dll as stated above.  The problem with this is that now ALL request will go through asp.net.  We may not need this for all requests.  In fact this can be a problem as it can hurt performance.  I've seen the a claim of 30% performance decrease someplace but I don't remember where right now.  However, it's safe to assume that routing static content through asp.net is just not the best solution.

Solution:

The solution?  After the background information we are finally at the payoff.  This is how we get the goodness of using asp.net url rewriting via http modules and the associated debugging and high level of control this brings us WITHOUT the downside of routing static content through asp.net. 

We access all the static content via a sub-domain.  We use static.whatsyour20.com to server all the static content on the site (Right now this is mostly images).  This is very easy to accomplish.  You simply create another web site in IIS, with the path to the same location as your main domain but using the sub domain.  On this domain you DO NOT route the requests to asp.net.  So on this sub domain all content is handled by IIS because it is static.  You could even take that a step farther and put it on a separate server or use another web server that is optimized for static content. 

Our solution works in a share hosting environment because usually you can set up sub domains on shared hosting.  Also you can usually get all requests routed to asp.net if you put in a ticket and simply ask for it.

A nice side effect of using sub domains is improved performance on the client side.  By increasing the number of hostnames (within reason) we can increase the speed at which the page loads.

Here are a few reference articles on multiple domains names to speed up downloads:
http://yuiblog.com/blog/2007/04/11/performance-research-part-4/
http://www.ajaxperformance.com/?p=33
http://www.die.net/musings/page_load_time/

Conclusion:

Using the presented solution we get a urlrewriting solution that is easy to use and configure (all configuration in web.config), transfers easily between hosting providers (again its all provided by asp.net and web.config) and it improves performance.  I'm still looking for any possible downsides.  Please let me know if you know of any.


Wednesday, May 23, 2007 7:29:14 PM (Central Standard Time, UTC-06:00)  #    Comments [1]
 Wednesday, January 03, 2007
How many times has your database servers hard drives filled up and you want to find the culprit?  Probably not many but for me it happens all the time.  Here is a simple command to get a list of all sql server databases and their file size:

use master
go

exec sp_databases
go

Need to find out where the files are on disk?

SELECT [name] [Database], [filename] [File Path]
FROM master..sysdatabases

Wednesday, January 03, 2007 9:34:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0]
 Wednesday, December 27, 2006

If you have been struggling like me to make your sites XHMTL compliant you realize that it’s not an easy task.  Most of the changes are straight forward if you have a validation tool.  I code a lot of sites in Visual Studio 2005 and it will complain like crazy if you have invalid XHTML.  Hence I try not to write invalid XHMTL because I hate errors and warnings and will compulsively try to make my pages as valid as humanly possible.

 

One of the areas where I’ve had the most trouble with this is create bookmarks with anchor tags.  Most of the examples I’ve seen use the name tag on an anchor so that you can link to it using something like http://example.com/test/#somebookmark.  I think this is an underused feature of html as it makes navigation much better and faster, plus it is much easier to link into a page at just the right point with something like this.

 

When using XHTML you should not use the name attribute as it has been deprecated.  Instead you should use the handy id attribute.  The id attribute will work exactly the same way and has the benefit of being compliant.  Plus you get additional validation of making sure each element has a distinct id.  This was a problem with some sites I’ve seen that use name.  I see the same name used all over the place.  This makes linking to the element somewhat difficult and error prone.

 

On a related note, did you know that most modern browsers can link directly to any element that has a valid id attribute?  This is very handy as you want have to include anchor tags all over you html just to get convenient linking.

 

Bad:  <a name="bookmarkid">Test</a>

Better: <a id="bookmarkid">Test</a>

Best: <p id="bookmarkid">the element i actually want bookmarked can be linked to directly</p>

Wednesday, December 27, 2006 1:47:20 PM (Central Standard Time, UTC-06:00)  #    Comments [0]