今天突然发现有一个叫Jython的脚本语言,他是一个用Java实现的Python。

咱们来看看他们之间有什么不同。

原文参考地址http://wiki.python.org/jython/WhyJython

为什么要 Jython

现在有许多语言实现了 Java VM. 下面的这些介绍将 Jython 其他的语言实现中区分开来:

  • 动态地编译成 Java 字节码
  • 扩展Java原有Class的能力
  • 能创建多中类型的程序
  • 具有Bean的属性
  • Python 的语法

为什么 Jython 做得非常好?

  • Prototyping
  • Java investigation
    •     >>> from java.util import Date
      >>> d = Date()
      >>> print d
      Sat Jan 08 16:26:16 CST 2005
      >>> from java.util import Random
      >>> print dir(Random)
      ['__init__', 'nextBoolean', 'nextBytes', 'nextDouble', 'nextFloat',
      'nextGaussian', 'nextInt', 'nextLong', 'seed', 'setSeed']
      >>>
  • Making bean properties accessible
    •     >>> print Date().time
      1105500911121
  • Glues together libraries already written in Java
  • Excellent embedded scripting language

Python & Jython 的区别

Python

  • C
  • Multi-platform
  • Compiles to .pyc
  • Extend with C
  • GIL 1

  • Python Garbage Collection

Jython

  • 100% Java
  • Any JVM (currently 1.1+)
  • Compiles to .class
  • Extend with Java
  • Truly multi-threaded
  • Java garbage collection
看到以上这些,我不禁要为这些为软件默默奉献的人感到敬佩。


相关文章:

  • 2022-12-23
  • 2021-12-01
  • 2021-09-16
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2021-06-30
  • 2021-10-25
猜你喜欢
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
  • 2022-02-19
  • 2021-09-10
相关资源
相似解决方案