最动态的动态编程语言 [英] Most dynamic dynamic programming language

查看:52
本文介绍了最动态的动态编程语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来我必须同意这个帖子 当它声明

It seems I've got to agree with this post when it states that

[...] 动态类型语言中的代码遵循静态类型约定

[...] code in dynamically typed languages follows static-typing conventions

我遇到的许多动态语言代码确实看起来很静态(想想 PHP),而动态方法看起来有些笨拙或不必要.

Much dynamic language code I encounter does indeed seem to be quite static (thinking of PHP) whereas dynamic approaches look somewhat clumsy or unnecessary instead.

大多数时候,它只是省略类型签名,在类型推断/结构类型的上下文中,它甚至根本不需要暗示动态类型.

Most of the time, it's just about omitting type signatures, which, in the context of type-inference/structural typing, doesn't even have to imply dynamic typing at all.

所以我的问题(并不是太主观)是,在哪些动态语言应用领域是所有这些更高级的动态语言功能(即不能在静态/编译语言中复制那么容易) 实际和惯用的使用.

So my question (and it's not meant to be too subjective) is, in which dynamic languages or fields of application are all these more advanced dynamic language features (that couln't be replicated in static/compiled languages that easily) actually and idomatically used.

示例:

  • 反思
  • 一流的延续
  • 运行时对象更改/生成
  • 元编程
  • 运行时代码评估
  • 不存在的成员行为

这些技术有哪些有用的应用?

What are useful applications for such techniques?

推荐答案

您列举的所有功能也可在静态类型语言中使用,其中一些带有约束.

All features you enumerate are also available in statically typed languages some with constraints.

  • 反射:存在于 Java、C# 中(非类型安全).
  • 一流的延续:Scala 中的有限支持(可能是其他)
  • 运行时对象更改:在 C# 中,使用扩展方法(将在 Java 7 中)和 Scala 中的隐式类型转换以受限形式支持更改对象的类型.尽管不支持开放类,但大多数用例都包含在类型转换中.
  • 元编程:我想说元编程是许多相关功能的标题,例如反射、运行时类型更改、AOP 等.

所以只剩下动态语言支持的讨论不多了.例如,对反射的支持绕过了类型系统,但它在需要这种灵活性的某些情况下很有用.在动态语言中也是如此.

So there is not a lot left that is supported only by dynamic languages to discuss. Support for example for Reflection circumvents the type system but it is useful in certain situations where this kind of flexibility is needed. The same is true in dynamic languages.

Ruby 支持的开放类特性是编译语言永远不会支持的.它是最灵活的元编程形式(具有所有含义:安全性、性能、可维护性).您可以更改平台的类.Ruby on Rails 使用它来动态地从元数据创建域对象的方法.在静态类型语言中,您至少需要创建(或生成代码)域对象的接口.

The open class feature supported by Ruby is something that compiled languages will never support. It is the most flexible form of Metaprogramming possible (with all the implications: security, performance, maintainability.) You can change classes of the platform. It's used by Ruby on Rails to create methods of domain objects from metadata on the fly. In a statically typed language you have at least to create (or generate the code of) the interface of your domain object.

如果您正在寻找最动态的语言",所有同音语言,如 LISP和 Prolog 是不错的选择.有趣的是,C# 与 LINQ 中的表达式树有些相似.

If you're looking for the "most dymanic languages" all homoiconic languages like LISP and Prolog are good candidates. Interestingly, C# is somewhat homoiconic with the expression trees in LINQ.

这篇关于最动态的动态编程语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆