Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uses for Dynamic Languages

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?

like image 639
dsimcha Avatar asked Jan 29 '09 23:01

dsimcha


People also ask

What is the advantage of dynamic languages?

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.

Why do people use dynamically typed languages?

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.

What is the most commonly used language to describe dynamics?

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.

Where would you use a dynamically typed language over a statically typed language?

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.


2 Answers

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.

like image 75
Marcus Downing Avatar answered Sep 20 '22 14:09

Marcus Downing


Here's Steve Yegge on the subject.

Guido van Rossum also linked to that talk in his take of Scala.

like image 26
Nikhil Avatar answered Sep 19 '22 14:09

Nikhil