My primary language right now is D, and I'm in the process of learning Python because it's required for a course I'm taking. While I understand why dynamic languages would be a breath of fresh air for people programming in static languages without type inference or templates (IMHO templates are to a large extent compile-time duck typing), I'm curious what the benefits are of dynamic languages even when you have those.
The bottom line is that, if I'm going to learn Python, I want to learn it in a way that really changes my thinking about programming, rather than just writing D in Python. I have not used dynamic languages since I was a fairly novice programmer and unable to appreciate the flexibility they supposedly offer, and want to learn to take full advantage of them now. What can be done easily/elegantly in a dynamically typed, interpreted language that's awkward or impossible in a static language, even with templates, polymorphism, static type inference, and maybe runtime reflection?
Benefits of Dynamically Typed Languages Generally speaking, dynamic languages are more succinct than their statically typed counterparts. Type annotations, generics etc. all add to the verbosity of the syntax. Languages like C# & Java require quite a bit of code before you can write any useful code.
Advantages of dynamically-typed languages:The absence of a separate compilation step (which is much more common) means that you don't have to wait for the compiler to finish before you can test changes that you've made to your code. This makes the debug cycle much shorter and less cumbersome.
Dynamics. Dynamics indicate the loudness of music. In Western musical notation, we often use italicized Italian words, which can be abbreviated, to describe dynamics. The dynamic marking forte means loud, while piano means quiet.
There are two main differences between dynamic typing and static typing that you should be aware of when writing transformation scripts. First, dynamically-typed languages perform type checking at runtime, while statically typed languages perform type checking at compile time.
In theory, there's nothing that dynamic languages can do and static languages can't. Smart people put a lot of work into making very good dynamic languages, leading to a perception at the moment that dynamic languages are ahead while static ones need to catch up.
In time, this will swing the other way. Already various static languages have:
Generics, which make static types less stupid by letting it select the right type when objects are passed around, saving the programmer from having to cast it themselves
Type inference, which saves having to waste time on writing the stuff that should be obvious
Closures, which among many other things help to separate mechanism from intention, letting you pull together complicated algorithms from mostly existing ingredients.
Implicit conversions, which lets you simulate "monkey patching" without the risks it usually involves.
Code loading and easy programmatic access to the compiler, so users and third parties can script your program. Use with caution!
Syntaxes that are more conducive to the creation of Domain Specific Languages within them.
...and no doubt more to come. The dynamic movement has spawned some interesting developments in static language design, and we all benefit from the competition. I only hope more of these features make it to the mainstream.
There's one place where I don't see the dominant dynamic language being replaced, and that's Javascript in the browser. There's just too much of an existing market to replace, so the emphasis seems to be towards making Javascript itself better instead.
Here's Steve Yegge on the subject.
Guido van Rossum also linked to that talk in his take of Scala.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With