Execute this: managing configuration in programming languages
Sean hones in on an aspect of GMail's use of Javascript:
There are more trivial but not to be underestimated uses to such an ability. Configuration is one such use. In Python/Jython, you can define your configuration files using plain code and import the configuration file for use. For example:
minute=60 session_timeout=minute*30
is a perfectly good and clear way of doing things - the intepreter will assign to session_timeout without the need for the programmer to write any tedious setup code (try doing that in a Java properties file). And given that more and more developer time is spent in configuration and declaration (be it setting things up or writing tools to read and write things to set up) this is good thing. Being able to define configuration in terms of functions and inbuilt data structures such as lists and dictionaries rather than string literals is not only useful and powerful, it also lowers the burden on developers by reducing the number of config languages in the system.
Of course you could do this in Java with a configuration object. But hardly anyone does this - most would consider it hard coding of data, the wrong thing to do. Perhaps this is because there is sufficient effort in compiling and packaging Java that we have always preferred to use XML or .properties files as being less work. That's worth some emphasis - it's considered less work to write XML configuration files for Java than use Java itself for configuration. Languages like Javascript, Ruby and Python having managed to avoid placing that level of obstacle in front of developers. Some might consider that a wakeup call, given how despised "configuration hell" is by Java developers. I imagine some of this argument holds for C# assemblies as well.
Another example comes from trying to distribute and manage system configurations - HP have been developing such a system, or 'fabric', under a OSS licence called SmartFrog. They considered the options, such as XML, but the language they came up looks something like a scripting one.
A significant argument against moving code over the wire and running it is security - eval() will no doubt make some people nervous. Consider this from the SmartFrog FAQ
Update: Steve Loughran pointed out in comments that SmartFrog is not a scripting language..
...which dents my argument a bit. Oh well :)
Others will point out that having a static type system allows for secure runtimes in ways that a dynamic type systems does not. Thankfully there has been significant research, practice and experience to draw from (ranging from Perl's strict mode, to the Java sandbox, to web browsers running code securely, even agent programming arcana such as Telescript) It's not as though data for execution is not being sent around already today. It is, but it's not normally talked about as such. Consider that a huge amount of forms based traffic going over the web is ultimately obfuscated SQL, or that you are probably downloading Javascript every day onto your computer for execution - GMail is taking this a few notches higher. Security concerns notwithstanding, there is a clear need to move behaviour over the wire in ways that are not as well-supported as we might like.
The point seem to be this: it is beneficial to lower the distinction between declarative data and code. Lisp hackers have known the value of blurring the distinction for decades; only now is it becoming an imperative to consider the idea in mainstream distributed programming.
Having discussed Java, it should be mentioned that Java's designers are aware of this benefit. In the past, Bill Joy has argued to the limits of XML by claiming that passing around static data is not enough; you always end up needing to pass behaviour around, even if it's only a stylesheet. Joy was involved in Java's Jini framework which features code mobility and then JXTA. Java itself has always allowed for mobile code, going back as far as Applets and the JVM sandbox model. Ironically it may turn out that Joy was right all along, but due to Java's compilation and packaging mechanisms lost out on flexibility.