Recently I have been developing web sites and web apps using Visual Basic in Visual Studio 2008. This isn’t a huge leap for me since I have training in C# in VS 2005. I think there have been plenty of comparisons between C# and VB, so I thought I would take the other road of comparing VB to PHP for those who are wondering.
First of all, to be clear, the architecture I have chosen on both sides is in line with the MVC philosophy of separation of presentation and business logic. I am using ASP MVC in Visual Basic. I am not using Webforms. Why? Because they don’t seem to be meant for high traffic, highly customized web sites. If you have used them before, even if you take the time to configure them properly, they are still heavy on the download. Also, if you want to customize them, even with CSS you need to cut open the welded hood to get to the engine so to speak.
Some have expressed envy in the PHP community for drag and drop programming. Hopefully they have found satisfaction in either using Delphi for PHP, Flex Builder, or actually moving to Visual Studio. As I have said before, DND “programming” does not satisfy my requirements of fitting my chosen methodologies. In addition, I chose the ASP.NET MVC that comes with .NET 3.5 SP1 (aka 3.5.1) as my framework for Visual Basic ASP.NET development. This precludes even having the option of using Webforms controls due to the fact that it does not support the method of state storage required for such controls. The ASP.NET MVC tends toward a more Restful nature, and so the two frameworks do not work together well.
To continue this MVC tangent, it is a respectable project. It seems to be developing in a linear manner making breaks only where it makes sense, and versioning appropriately. Since I started using 1.x, the API has only grown. I hear there are some differences in 2.x although minor.
I wont get into comparing ASP.NET MVC to any PHP MVC frameworks, but it compares relatively directly to most with the addition of some elaborate (some times daunting) routing.
You may think it foolhardy to compare a dynamic language to a strongly typed language. It is interesting how both languages lean toward each other. PHP is the dynamic language that lets you type hint. VB is the strongly typed language that tries to let you get away with being dynamic. VB 2008 has many feature that are new to .NET land. Features that C# doesn’t even have. Although C# wont be left out for long since the .NET Framework team has pledged to bring them parallel in the 4.0 series.
As language stability and consistency goes, .NET has seen some turbulent times through 3.x. This is similar to what PHP5 saw around the 5.1 time frame. Both have seemed to level out with those rocking boat looking to the next versions. VB on .NET 3.5sp1 wont be the time lasting version though. It seems to me that the 4.0 series is going to settle down for maturity a bit. At least that is my hope, and what I gather from what I read. We will see. PHP 5.3 feels like a click off center too, like 4.3 of old it has the feature set, but we seem to be waiting for a security release. Or, maybe that is the 90’s Linux Kernel hacker in me.
The one thing I like about PHP above all others is the clean sensible style one can achieve. The object structure allows you restrict where you need, and permit where you want. If you want to lock down your classes so you only get exactly what you need, you can type hint on the objects you want. If you want to build a uber smart method that takes anything you can throw at it, you can. The syntax is fundamentally clear. Statements end in semi-colons, curly braces delimit blocks without getting in your way. If you have seen very much C# you can see how curly braces can be taken to the extreme.
VB on the other hand is a ambiguous pile of goo. You can quote me on that. Why do I say that? If I were using VB what does the following statement do?
Return (A = B)
That is right, this is were the rant starts. VB uses the equal sign (=) for both comparisons and assignment. You may be thinking that this can be dealt with, for the most part you are correct. Usually when you are doing comparisons you accompany it with ‘IF’ or the like. Also, in both VB and PHP there is a function that is like EmptyOrNull(). However, VB ALSO calls Null, “Nothing”. On top of that it doesn’t allow the ‘=’ operator during comparisons all the time. Usually it requires the use of ‘is Nothing’ similar to the SQL operator of ‘IS NULL’.
That brings us to scope. Scope in PHP is a rule that some like to blatantly violate. Newcomers to the language sometimes decide to forgo learning the rules and start shoving data in global vars. As with my over all feeling of VB, the use of ‘Me’ in self referencing is cute. It is not really an issue, but rarely do programmers use it. The scope within a class is so that it encourages you not to. The use of name spaces can also cause issues. I know PHP just added this feature, and I see little use for it. When abused though it can cause further ambiguity. A referenced function or class may be found in multiple places, and only visiting the “Imports” section can clarify, but not always.
There is wide diversity in the PHP community over which IDE they use, and some advocate an editor over an IDE. The VB community for the most part uses Visual Studio or Visual Web Developer. I have found that most of what I actually use is present in Visual Web Developer 2008 Express, one of the free (as in beer) versions from Microsoft. There are several things completely amiss in all the variants of Visual Studio. Editing of Javascript is a nightmare. The IDE is incapable of editing Javascript. It tries to format it as you type while actually shoving your cursor around to different locations. It is sad to think that Microsoft cant handle such a simple task as leaving things alone that it doesn’t understand. If you have a Javascript file open when you run the debugger it tries to debug your javascript as jscript. The second is that it violates Microsoft’s standard keyboard shortcuts out of the box. Then there is the lack of version control support.
.NET throws exceptions that sometimes have what they call “inner exceptions”. While this adds flexibility to your exceptions, the IDE nearly fails to handle them. When halted on the exception, the common dialog tells you to view the inner exception. When you view the exception it comes up in an archaic grid that does not even let you scroll to read the whole error. You are forced to use the mouse tool tip to read it, which only stays on the screen for a couple seconds. If your debugging doesn’t work, why use it at all. Further, if your debugger doesn’t work, what good is your IDE. You should drop back to an editor that you didn’t pay $1,200 for.
That being said, there are some other tools that can shield you from programming in VB. VS is relatively adept at code generation using the T4 templating engine. If you get adept at scripting your code generation, it can be a quite satisfying practice. Also the Entity Framework is a nice ORM for use with a supported RDMS. Although it suffers from the common ORM code generation problems it offers a respectable interface to your business logic. This is especially the case when combined with Linq queries. Things get a little hairy when you start to get sophisticated with your business logic though. A highly flexible platform VB ASP.NET may not be.
Although I do concede I have 10+ years experience with PHP and about a total of two with VB .NET, you cant overlook the fundamental issues of ambiguous syntax in Visual Basic .NET and a poor web integrated development environment.
Since I have learned both languages by using the web on my own, in the next few posts I will try to impart my experiences in both languages and gift you my learning resources.







