Squeak 运行“位相同”是什么意思? 跨平台,而 Java 却没有?
Alan Kay 指出“与 Java 不同,[Squeak] 在每台机器上运行的位都是相同的——我们发明了这个20年前”。 维基百科页面也提到了这一点:
Squeak 可供许多人使用 平台以及在其上制作的程序 一个平台在所有平台上运行完全相同 其他平台。
由于具有不同指令集的机器显然无法在本机上运行位相同的程序,因此当有人说 Squeak 在不同的机器上运行位相同的程序(而 Java 则不然)时,这意味着什么?
我的印象是编译后的 Java 类在任何 JVM 上的任何机器上运行都是相同的,不是这样吗?
Alan Kay points out that "Unlike Java, [Squeak] runs bit-identical on every machine -- we invented this 20 years ago". The wikipedia page mentions this also:
Squeak is available for many
platforms, and programs produced on
one platform run bit-identical on all
other platforms.
Since machines with different instruction sets obviously can't run bit-identical programs natively, what does it mean when one says that Squeak runs bit-identical programs on different machines, in a way that Java doesn't?
I'm under the impression that compiled Java classes runs identically on any machine on any JVM, is that not so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
明显的解释是,在具有相同输入的不同机器上执行相同的图像将导致图像通过相同的位模式演变。 这篇关于 Squeak 浮点数学的文章 暗示浮点具有相同的表示形式在不同的平台上。 Java 要求平台之间的语义相同,但允许非规范化表示。 Squeak 用于确保跨平台位相同的浮点的库是 Sun 的库,Sun JVM 也使用该库,尽管他们提到通过编译器设置进一步限制它。
The obvious interpretation is that executing the same image on different machines with the same inputs will result in the image evolving through the same bit patterns. This post about Squeak's floating point math implies that the floating point has identical representation on different platforms. Java requires that semantics are the same between platforms, but permits denormalised representations. The library Squeak uses to ensure bit-identical floating point across platform is Sun's one, which the Sun JVM also uses, though they mention further restricting it with compiler settings.
术语“位相同”不仅可以指没有本机代码,还可以指数据操作的处理方式。 不同平台之间存在细微的差异,例如,由于浮点单元的硬件实现不同,浮点数的最低有效位也存在差异。
因此,位相同也可能意味着消除了此类差异,并且每条指令在每个硬件上都返回逐位相同的结果。 特别地,这会禁止使用某些硬件并且需要模拟。 我不确定这在可接受的成本下是否可行,或者是否有一个好的技巧来实现这一点。
The term bit-identical can not only refer to no native code, but also refer to how data operations are handled. From platform to platform there are subtile difference, for example in the least significant digits of floating point numbers due to diffrent hardware implementations of the floating point unit.
So bit-identical could also mean that such diffrences are removed and every single instruction returns bit by bit the same result on every hardware. Ad hoc this prohibts the usage of some hardware and would require emulation. I am not sure if thi is feasible at acceptable costs or if there is a good trick to achiev this.
位相同意味着 Squeak 镜像本身可以在许多平台上运行,而不仅仅是 Squeak 源代码。
Smalltalk 图像是代码(字节码格式)和活动对象的存储。 代码以中间字节码格式提供,然后 VM 即时编译为特定于平台的机器代码。
Bit identical means that Squeak image itself can run in many platforms, not only Squeak source code.
Smalltalk image is namely a store for both code (in bytecode format) and live objects. Code is available in intermediate bytecode format, which VM then compile to platform specific machine code on the fly.
来自 java.lang.Math:
From the documentation of java.lang.Math:
它在虚拟机上运行,如维基百科下一句所述。 :)
与 Java 相比,不确定“位相同”部分意味着什么。 我的印象是相同的类文件可以在不同的机器上运行,因为Java也运行在虚拟机上。
希望艾伦能够介入并为我们解决这个问题!
It runs on a virtual machine, as stated in the next sentence on Wikipedia. :)
Not sure what the "bit-identical" part means, as compared to Java. My impression is that the same class files can run on different machines, since Java too runs on a virtual machine.
Here's hoping Alan will jump into the thread and clear this up for us!
我唯一能想到的是,他指的是这样一个事实:Java 通常(C# 总是)在运行之前在目标机器上“即时”编译为本机代码。
The only thing I can think of is that he's referring to the fact the Java is often (and C# is always) "Just-in-time" compiled on the target machine to native code, before it's run.