Wednesday, June 17, 2009

Dynamic Languages, Revisited

Hey, shock of shocks! A few programmers are reading my blog! These are guys I don't even know. How wonderful for me! But there was a bit of discord on the definition of just what is a dynamic language and what isn't.

So, for the record, I will quote the wikipedia.org article on Dynamic Languages:

The definition of a dynamic language is ambiguous because it attempts to make distinctions between code and data as well as between compilation and runtime which are not universal. Virtual machines, just-in-time compilation, and the ability of many programming languages on some systems to directly modify machine code make the distinction abstract. In general, the assertion that a language is dynamic is more an assertion about the ease of use of dynamic features than it is a clear statement of the capabilities of the language.
There you go! Wikipedia clearly acknowledges that there is big old nasty mess where a nice precise definition aught to be. Everybody (except me) would like to lay claim to the Dynamic tag because it is considered a hot buzzword right now... especially for the resume. In the process the real meaning of the term is absolutely lost.

The long list of languages at the bottom of the Wikipedia article include everything under the sun, including such preposterous inclusions as Forth, D, C#, Lisp, VB9 and REALBasic. HOLY SHIT! I want to make it clear that Spanish, Hungarian and Mandarin also qualify as a dynamic computer language under the catch-all basket definition presented in this wikipedia article.

Alas, such is the case with all hot buzzwords. They all become polluted and corrupted until the very last shred of meaning is lost. Such was the case with the term Light-Weight. Everything is now Light-Weight. Every last group claims to have a light-weight application stack or frame work. Such was the case with RISC. Everyone not manufacturing an explicit x86 chip tried to lay claim to the RISC title. When IBM claimed the PowerPC was a RISC design, the very last vestige of the original meaning of RISC died.

Therefore, allow me to clean up the fucking mess:
A Dynamic language is an object oriented programming language which provides a metaprogramming model that allow a runtime engine of some sort to construct new and modify existing classes in any application. These systems are capable of both creating and modifying classes without intervention or explicit programmatic effort by the original developer.

The emphasis is on the terms object oriented and classes. This eliminates languages such as JavaScript and VBScript. Why? Because they are not object oriented, that is why. I have heard protests on this subject before. Some think the existence of JSON implies that JavaScript is an example of OOPS. Not so. JSON is basically open data container format, mailable into many formats. It is no more object oriented than XML is. You cannot encapsulate public or private methods in JSON, nor can you redistrict visibility or access to data elements.

Weak typing has nothing to do with the subject of dynamics, although it is a necessary step along the way. There have been a vast array of languages which implement weak typing. The overwhelming majority of them are not dynamic. As I mentioned briefly in my prior piece, this is the greatest point of confusion for the masses. Many know that their favorite language is weakly typed, and believe (ergo) a dynamic language also. Perish the thought! Not even close to being true.

So what if I am a great lover of JavaScript and I desperately covet the buzzword Dynamic? JavaScript still has an undeserved bad rep in many places. I am trying to rehab my favorite language's image in the court of public opinion. I want people to think highly of JavaScript. I want to lay claim to the title Dynamic to help forward this end goal. Can't you just bend the rules a bit to let my baby in the club?

Nope. The end.

On the question of just how fast IronPython is, you might be surprised. Have a look at this little piece right here. That article is essentially a soft retraction piece, where a good benchmark artist discovered something very interesting about IronPython vs. CPython performance. The future looks very nice for IronPython.

As to whether Python is a static language or dynamic... Well, fortunately more ink than blood has been shed over this subject. Python types are never stated in variable declaration. Data types are inferred from arguments passed or assignments made. Variable types are immutable, within scope. There is nothing that would prevent one well written Python function from handling three different binary types in three consecutive calls. This is very dynamic, my friends. Finally, and most importantly, you can mutate a class definition at runtime. This is the absolutely crucial key to dynamics.

Anyhow, I appreciate the readership! Thanks for bumping up my ad campaign. :D Hope I can help clarify somethings. One famous wag said "It is better to insulted than ignored... but only in passing." Not that I was insulted, mind you.