VFPConversion Blog

This blog is dedicate to the adoption of technologies such as Microsoft .NET or SQL Server in addition to Visual FoxPro. Expect posts on this blog to be fairly technical, as this blog is geared towards developers, testers, and technical decision makers.

Content Area Footer

Sunday, November 09, 2008
Visual FoxPro: A Dynamic Language?

Over the recent months (or even years), a development paradigm has gained importance that has been around for a while, but hasn't been nearly as popular as it is now: Dynamic Languages.

What exactly is a dynamic language? DLs are languages that are not staticly typed. In most static languages, one creates an instance of an object and at that point, one knows the type of an object and what methods and properties it has. For instance, in C#, we could write this to create an instance of a form:

Form form = new Form();

The fact that form has a Show() method is clear based on the definition of the "form" variable to be of type (class) "Form" (Form form). In fact, the compiler can look up the definition of the "Form" class and verify that it indeed has a Show() method that takes no parameters. If so, the code compiles and runs fine. If such a method isn't found, the compiler refuses to compile the code. This is a great too to improve code and runtime quality of your application.

Dynamic languages approach the process a bit different. They simply allow calling methods on an instantiated object during runtime, with no check members during compile time. Conceptually, we could write this in pseudo-code like so:

form = new Form();
form.ShowNow(); // May or may not work during runtime

In some ways, this is actually similar to how Visual FoxPro works, where the same code could be written like so:

LOCAL oForm = CreateObject("Form")

No compile-time check is performed in VFP to see whether the Show() method exists or not. It simply invokes the method dynamically at runtime. If it exists: We are all smiles. Otherwise: Crash and burn!

So does that mean VFP is a dynamic language? Well, no, not really (or only partially). The question we need to ask ourselves is "why do dynamic languages make sense in some scenarios?". And the answer to that lies in the ability to add "stuff" dynamically. There certainly is no benefit in not knowing whether a method call will work or not when there is no way to add a method dynamically. Which could happen in the above scenario only if we instantiated a different object. We know Form objects in VFP have certain methods and there is no upside in the compiler not being able to check that, unless we have the ability to really add new things dynamically. In a true dynamic language, we should be able to do something like this (pseudo code again):

form = new Form(); // Has no ShowNow() method!!!
form.ShowNow();    // Crash and burn!
form.ShowNow = function {
                   this.Visible = true;
               }; // Now we have a ShowNow method!
form.ShowNow();   // Works

As you can see, this code doesn't really look like VFP and there is no support in VFP for things like function pointers, delegates, anonymous methods, or lambda expressions (these are all techniques that could be used to create something similar to the above example). VFP does have the ability to add properties dynamically and such, but it is a awkward approach and I have never seen an app that makes large scale use of it, or even bases its entire architecture on it, as would be the case in dynamic languages such as JavaScript, Ruby, or Python. (If you have an example where this is the case, I'd be interested to hear about it).

So is VFP a dynamic language then? Well, it is to a certain extent (examples include dynamic member invocation or eval and macro abilities), but in a lot of ways, VFP takes a static approach without static typing, rather than a true dynamic approach. Some of the basics are dynamic, but the VFP paradigm isn't and VFP lacks some core concepts of dynamic languages such as object alteration during runtime (changing the inheritance tree for instance, or adding lambda expressions).

In .NET, languages such as VB and C# fulfill some dynamic criteria (especially VB gets close in the technology it provides, although not necessarily in how it is used in the wild). C# 4.0 will offer explicit support for dynamic concepts that can co-exist perfectly with the static concepts C# is known for (this is something that gets me very excited). Also, IronPython and IronRuby, two new .NET languages from Microsoft are specifically designed to be dynamic languages only.  

Posted @ 3:56 PM by Egger, Markus ( -
Comments (14)








Syndication RSS 2.0 RSS 2.0

All My Blogs:
My personal blogs:
Dev and Publishing Dev and Publishing
Travel and Internat. Living Travel and Internat. Living
Other blogs I contribute to:
Milos Blog (US) Milos Blog (US)
VFPConv. Dev Blog (US) VFPConv. Dev Blog (US)
VFPConv. Dev Blog (DE) VFPConv. Dev Blog (DE)


Blog Archives
All Blog Posts

    February (1)
    November (1)
    October (2)
    April (1)
    March (1)
    August (1)
    July (1)
    June (2)
    March (1)
    January (1)
    December (1)
    November (2)
    October (1)
    September (1)
    August (1)
    April (3)
    March (2)
    February (1)
    January (1)
    December (2)
    November (3)
    October (2)
    September (7)
    August (3)
    July (4)
    June (12)




This Blog is powered by MilosTM Collaboration Components.