Uses for Dynamic Languages

前端 未结 13 1846
刺人心
刺人心 2021-01-02 11:14

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 wou

13条回答
  •  一整个雨季
    2021-01-02 11:27

    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.

提交回复
热议问题