views:

199

answers:

4

I'm trying to get a better handle on what it really means for a language to be "dynamic". I have quite a bit of experience with Lingo, which is the scripting language for the Adobe (formerly Macromedia) Director product line, and I'm just wondering if it would be considered a "dynamic language".

The way variables and lists are handled seems very "dynamic language"-ish to me.

With variables, you would just write foo = 3 or bar = "Hello World". You don't declare a variable as an int or string--it figures that out as is goes.

With lists, you can just write something like miscCollection = [3, "Hello World", #helloWorld, ["Embedded List", "Goes Here", 3], [#phrase: "Property List goes here", #value: 3]]. Would this not be similar to a tuple?

Are these features enough to qualify for "dynamic language" status?

Interestingly, I've been using C# a lot more and Director/Lingo a lot less, but with all the excitement over dynamic languages these days, I wonder if I'm actually going against the grain.

EDIT

Regarding Mark Rushakoff answer, below, here's an attempt to analyze whether Lingo qualifies as "dynamic" using this Wikipedia article:

  1. Eval - Lingo has do and value keywords. do will execute an entire command, e.g., do "foo = 23" or do "foo = sum(20, 3)". value attempts to convert a string into a numeric, but it is more than just a parsing operator--it can actually convert a string representation of a variable into its number, e.g., assuming foo = 23, the statement value("foo") will evaluate to 23.

  2. Higher-Order Functions - If I'm understanding this right, this is basically what I would be called a "delegate" in C#. Lingo doesn't support this directly as far as I know, although you could create a type (called a "parent script") that has a function and pass an instance of the type.

  3. Closures - No support for this as far as I know.

  4. Continuation - No support for this as far as I know.

  5. Reflection - In a sense at least, yes. You actually create new instances of types using a string, e.g., fooInstance = script("Foo").new(bar). It is also possible to convert an instance of a type into a string that contains the name of the type (so you can sort of mimic c#'s GetType() functionality). You can also query the properties of a type without knowing the names of the properties (e.g., look up a property by index) and find out the names of the properties by index.

  6. Macros - The way the Wikipedia article describes a macro, I don't believe so. It is possible to edit scripts at runtime, however, so maybe that counts.

So, it seems that Lingo scores a 2 to 3 out of 6 on dynamic features, but I'm not clear enough on closures and continuations to know for sure that Lingo doesn't support them. I guess I'm not sure what to conclude. Comments welcome.

+5  A: 

Type inferencing (such as your examples of foo = 3 and bar = "Hello World") does not imply a dynamic language. The var keyword in C# infers the variable type at compile-time, and Haskell also can use implicit typing for all variables, even in compiled programs.

"Dynamic programming language" is a pretty loosely defined term, but I think if you had to restrict it to one qualifier, it would be runtime reflection. If you can do reflection, you can probably do the other qualifiers listed in the Wikipedia article (eval, object runtime alteration, closures, macros...).

I don't know anything about the Lingo language, but I'd say it's generally easier to disqualify a language as being dynamic than it is to qualify a language. Can Lingo do any/all of the qualifiers in the Wikipedia article? If not, then it's probably just not dynamic. If it can do any, then it's probably at least "dynamic enough".

Mark Rushakoff
+1  A: 

When people talk about a programming language being "dynamic", they are usually referring to a dynamic type system. The best definition of what a dynamic type system is (and what it isn't) that I've ever read is Chris Smith's excellent article What to Know Before Debating Type Systems.

Once you've read that article, I think you should have your answer as to whether any given language qualifies as being statically or dynamically typed.

Daniel Pryden
Thanks for the pointer. Having read--and partially understood--the article, I can tell you that my example language, Lingo, doesn't have a type checker. If does make sure you don't try to use a variable that was never assigned to, but that's about it. That said, I don't think I really came away understanding what a dynamic type system *is*. I have some feeling for what it is not, what it is good at, and what it isn't good at, but I guess I need something a little less abstract to really get my head around it.
DanM
@DanThMan: I'm not familiar with Lingo, but I'm certain that it *does* have a type system. It just sounds that it is very loose (that is, it does a large number of implicit conversions). A loose type system is often associated with "dynamic" languages, but is by no means a requirement. Python, for example, has a fairly strict type system, but is very dynamically typed. In my opinion, dynamically typed languages are useful for many things, but loosely typed languages are just a good way to get you into trouble. YMMV.
Daniel Pryden
+2  A: 
andrew cooke
-1 - calling a dynamically typed language "untyped" is a flagrant misuse of accepted terminology. What you are calling a "typed" language is a "statically typed" language. http://en.wikipedia.org/wiki/Programming_language#Typed_versus_untyped_languages
Stephen C
A: 

Hello

I would like to show that Lingo is a dynamic language. I've developed LingoF a Functional Programming Framework for Lingo. This Framework is entirely written in Lingo, no xtra, no low level components used. So here is my evaluation for Lingo as Dynamic language:

1 - Eval - Lingo has do and value keywords. Plus you can compile a script in execution time. See LingoF's Feature "Lingo Expressions".

2 - Higher-Order Functions - LingoF shows how possible is to do extensive use of Higher order functions in Lingo.

3 - Closures - Again LingoF shows how is possible to work with Closures in Lingo.

4 - Continuation - LingoF syntax helpers are defined with continuation techniques. It is possible to write functions in Continuation Passing Style. Check this (taken from LingoF module):

on public_factorialCPS_2
on fac me, n,k
  x = LingoF().var()
  if ( n = 0 ) then return k [1] 
  else return me.factorialCPS[$(#-,n,1) ] [ LingoF().fun(x) [ k [ $(#*,n,x) ]  ] ]
end

5 - Reflection - Already answered yes and I agree. For example LingoF module manager is implemented using Lingo's Reflection features mentioned by DanM.

6 - Macros - I will have to do more research in this field. Since Director supports Linked Scripts (scripts stored in external text files) it is possible to implement some kind of macros. Maybe the macro manager can intercept some events like startMovie (to expand them) and stopMovie (to compress them again). Another posibility is to use fields as scripts and expand them in script members, I'm sure it will work fine.

So my score is 5 to 6 out of 6 on dynamic features.

Gustavo