Fog Creek Software
Discussion Board

Variant languages versus strongly-typed languages

Joel sayeth

" Today, when you have a strongly typed language, a good type library (IDL, WSDL, Java reflection) documenting your classes, and an IDE that knows how to show you that type library as you code (i.e. Intellisense), it's even easier to use types than variants, so the trend is away from variant-bound scripting languages (VBScript, PHP, perl) towards typed code (C#, JSP)."

but on (, it says

"Zend Technologies Ltd., the creators of PHP 4, and the Zend Engine, on which all PHP sites are run, today announced that as of April 2002, PHP, the open-source software phenomenon, has surpassed Microsoft's ASP as the most popular server-side Web scripting technology on the Internet. "

and on Zend's web site,

"According to a Netcraft survey published in April 2002, PHP is now being used by over 24% of the sites on the Internet. Of the 37.6 million web sites reported worldwide (, PHP is running on over 9 million sites and continues to grow at an explosive rate. Over the past two years PHP has averaged a 6.5% monthly growth rate."

and so I wonder about Joel's information.  Or am I missing something?

Chris Woodard
Sunday, June 16, 2002

Think VB (the classic varieties, not the newer programmer oriented versions) versus C++.  "Real programmers" like C++; they appreciate the value its advanced features provide.  The cynic in me suggests they also like the exlusivity of the fact they're harder to learn than VB.

All that J2EE stuff is great if you're a "real programmer", or an architect, or someone who will enjoy a more complex programming environment.  If you just want to slap up a simple dynamic site with some templating, forums, perhaps a shopping cart, why do you need an n-tier MVC architecture chewing cycles and a horde of high price programmers to implement, when PHP will give you everything you need?

The same applies for mod_perl, Aolserver/TCL, and other scripting languages in Web servers.  They've got lots of free extensions and apps, they let people throw things together quickly, and they don't require an understanding of more sophisticated CS concepts.

Rodger Donaldson
Sunday, June 16, 2002

Also remember that these statistics are most likely based on what is installed on the server rather than what is being used - my ISP has PHP on their web servers, thus every domain they host runs PHP. This does not mean that every site uses PHP, however to an automated bot, it may appear that way.

Sunday, June 16, 2002

Microsofts ASP (using either VBScript or Javascript) is heavily variant-oriented.  This becomes a comparison of apples to apples; and the sweetest juiciest apple is winning.

I develope (a) very large (2.5MB of source code) PHP application(s).  The lack of strong typing is a benefit to small programs but a hinderance to large programs.  I use a function called "type_check" which I apply liberally to the code.  Not only does it error on mismatched types, but also does regular (int to string) and complex (inter-object) type conversations.  This is a huge help to debugging (and coding for that matter).

Type errors occur regularily in PHP programs; they are raised by function library calls.  Performing an array_pop() operation on string will cause an error.  All you know is that on line 254 in file x $var should be an array and not a string.  Unfortunately, in a large program that is rarely good information.  If function foo_bar() is supposed to take an array and you pass it a string -- that's where you want the error to occur; not the first time you attempt to call a library function with that argument.

PHP is a good solid development platform easily supported by ISPs.  ASP is really only good when you have complete control over the webserver (and have alot of money to purchase all the components you need). 

ASP.NET helps with the server-control issue and includes alot of extras (reducing or eliminating the need for third-party components) but I doubt you'll see it gain popularity outside of the areas that ASP has traditionally been strong.

Wayne Venables
Monday, June 17, 2002

I have to say I agree with Roger about the exclusivity, and it squares with something I've long felt about Visual Basic.  Developing software is hard work, and tools like VB make it look too easy... especially to green-eyeshade mechanics bent on reducing costs.  Some years ago I actually heard this from a manager:

"I don't understand why you say this will take two months to do.  I installed Visual Basic on my computer at home and built the interface in three hours.  Visual Basic generated all the code I needed."

when I was trying to explain why it was going to take two months to write the back end of a reasonably sophisticated expense-reporting system.  It was as if this manager had seen the pretty pictures, and the ease of writing the canned code for the painted screens made the manager think that the rest of the development process could be similarly automated.

This kind of thinking is especially prevalent among MBA grads whose only exposure to actual development was in an introductory VB course they stayed awake through half of in college.  And those people are often in charge, and they influence (and sometimes make) technology decisions that the rest of us get stuck with.  (This is why there's so much Windows in coroprate America when the technologically literate among us would prefer Unix, or Linux, or OS/2.  We who know our way around the innards of a computer don't *need* training wheels or Teletubby interfaces to get our work done.)

Chris Woodard
Monday, June 17, 2002

I just wanted to point out that php surpassing asp as the most used web scripting language/environment, then deducing that coders are moving towards variant based languages like php because of that "fact" (and i use the term lightly given the source), is giving a false impression that all development happens within a web scripting environment. There is more to development than web scripting.

Ian Stallings
Monday, June 17, 2002

VB also leaves a lot of errors to be detected at runtime.  Such as parameter checking.  Writing code is only one part of a development effort, and I never will understand quickly writing code to only wind up extending your testing time.

Joe AA.
Monday, June 17, 2002

I infer that by "variant", people mean dynamic typing here.

Static/dynamic typing is orthogonal to strong/weak typing.

Strong typing means the type system is safe, and you
cannot treat arbitrary variables as variables of another type
("reinterpret" in c++ parlance).

Dynamic/static typing refers to whether the type checking
happens at run time or at compile time.

Anonymous Coward
Monday, June 17, 2002

Variant refers specifically to dynamic AND weak typing.  A variant variable can be any type.  A variant argument can accept any time.  In other words, no real type checking (weak) at all and fully dynamic.

var = "Bad"
var = 5
var = Array("15", "14", "13")
var = new Widget()

intval = "5"
result = intval + 5      // result will be 10.

VisualBasic (not VBScript) has support for variants along with regular types.  I find variants to be VERY useful when dealing with database APIs.  One argument fits all (this even includes NULL values).  But for regular programming, I prefer strong typing (not necessarily static).

Wayne Venables
Tuesday, June 18, 2002


A couple of things just don't add up.

First, comparing PHP vs. ASP (i.e. VBScript) is comparing one variant language to another variant language, as said above.  So I don't think it's reflective of what Joel stated in his article.

Second, per the same Netcraft survey, the number of sites running IIS has gone up slightly in the last year and the number of sites running Apache has gone down marginally. IIS sites predominantly run ASP and Apache sites can run PHP, Perl, Python, etc -- or -- JSP (also ASP, but I don't know if many actually do that).

So, I don't think PHP is "stealing" market share from ASP.  So I suspect the PHP rise is due to an increase in the # of scripted sites or a dropoff in JSP or Perl.  Who knows?  Joel could be wrong about a trend toward JSP, but from the steady level of Java job postings I seen (compared to other languages) I'd guess that JSP is holding its own.

Third, you now have strong typing in VB, VBScript, and C#.  What used to be <<Dim i>> in VBScript is now <<Dim i as Integer>>.  In VB6, <<Dim i>> would default to a Variant type but VS.Net did away with Variants.

Overall, in the MS realm, Joel's just stating the facts, not an opinion. In the Apache realm re JSP, it's probably more of an opinion, but I think it's the right one.

Nick Hebb
Tuesday, June 18, 2002

Joe AA. Wrote:

>VB also leaves a lot of errors to be detected at runtime. Such as parameter checking. Writing code is only one part of a development effort, and I never will understand quickly writing code to only wind up extending your testing time.

Huh? VB has full type checking at compile time. You try and pass the wrong param type...and the compiler will complain. If you are talking about vbscript..then yes..but then there is no compiler involved.

There is really no difference between VB and c++ on a instruction "speed" basis anyway. However, VB does do a lot of type casting for you. This auto casting defiantly speeds up the development process.

The pro/con arguments for type checking goes both ways. In VB many a times code will accept a different type and NOT produce a error (auto casts), and in fact just works just fine. This can actually reduce program errors.

Loose data typing is a doubled edged sword. I loved working in Pascal and how strongly it is typed. I then did a stint in the Pick system. The mv-basic language is extremely loose typed. Numbers, database records, and just about everything is actually treaded as a string. It is completely the wild west. Any structure to the data is really that of what the programmer wants.

After experiencing strong typed systems, and loose typed systems. I have to say that a good developer will probably prefer loose typed systems. This is because any data structures that the DEVLOPER makes can be easily extended to. (you can change a data structure type, but the rest of the design will still work with the old data structure).

Albert D. Kallal
Edmonton, Alberta Canada

Albert D. Kallal
Wednesday, June 19, 2002

Sorry Albert, but I have seen too many VB runtime error messages - invalid parameter and incorrect number of parameter messages to buy it.

Joe AA.
Thursday, June 20, 2002

Actually, Joe, it is very much like I said.

......The argument goes both ways.

If the Vb program was *more* loosely typed, then you might very not see an error of invalid type!

The Same goes for the number of parameters...when they are all optional...then you may never see a message with invalid number of parameters.

More lose data typing can reduce errors, and can also introduce errors. I suspect the advantage of one approach over the other probably depends on the type of software one is working with.

Less structure in code tends to equal more flexibility.  In addition, when those structures can be modified without regards to existing structures, again flexibility increases.

Years ago a good portion of pc based software actually had the data structures hard-coded into the application. In other words, the structure of the record was defined in code.

Dim      name        as string(25)
Dim      Address    as string(25)
Dim      Billamount  as Currenty(8)

Today, we have abstracted the data strictures OUT of the code. That means that the data stricture in code now must be a totally flexible and dynamic structure. (such as a ADO recordset). We could debate as to the fact that the “type” is a recordset, but that is really moot. The point here is now that each record is NOT strongly typed. The structure is totally Variant. In fact, we can go and change our data structure (our type) via the database design tools, and not even have to change our code (hence, we can change structures *outside* of the code). Hence, you can see where I am going with loosely typed data, or strongly typed data.  This also applies to any type of data structure that I can define in code. (for example, we need better tools to save a class object (and values) to disk, and to retrieve it).  Same goes for “collections” in VB.

Hence, right now the trend is certainly towards “structures” that are more flexible, and are less typed via the code. XML does give some structure to data, but it is all text and stuff like currency and numbers actually gets *converted* (cast) to the correct data type *only* when needed. This is text...and no data type is here!

As mentioned...I also suspect that the use and increase of loosely data typed objects probably depends on what one is trying to accomplish. It seems the trend is certainly moving towards loose typed systems. I suspect the net is partly responsible for this trend.

If I am writing some assembler code for a processor, then I think some good fixed strictures, and caution on the kind of data words I feed to the registers better be typed correctly!

Albert D. Kallal
Edmonton, Alberta Canada

Albert D. Kallal
Tuesday, June 25, 2002

*  Recent Topics

*  Fog Creek Home