- 浏览: 60767 次
最近访客 更多访客>>
最新评论
-
healer_kx:
Reading~healer.kx~~~~~~~
编译器的书 -
yawl:
"SVM are some of the most ...
classifier算法优缺点 -
coderplay:
SVM有啥优点? 没整过, 只是知道算法是咋回事. 依算法描述 ...
classifier算法优缺点 -
yawl:
我现在在做sentiment analysis的,看这方面的p ...
classifier算法优缺点 -
luven:
好看不重要,关键看创意!
Rails Rumble -- 48小时内完成的131个 application
[Update 03/12/2007 If you know how to implement Interge#times in pure ruby and make it have the same behavior as Ruby 1.8.5, please let me know. Thank you!]
One of the best things I love about rubinius project is: their developers try to keep the dependency on system language (C in their case) minimal, and they take it seriously. Take a look of http://code.fallingsnow.net/svn/rubinius/trunk/kernel/core/, you will find out lots of buitlin libraries are implemented in pure ruby, even lots of string functions.
Pure ruby builtin has some drawbacks, though. One is performance penalty, the other is potential side effects. For example, basically Integer#times can be implemented as simple as this in pure ruby:
But this version of Integer#times does not work exactly the same as Ruby 1.8.5. If an user want to override Fixnum#+ (this may never happen in real life):
Our Integer#times's behavior will change, while Ruby 1.8.5 won't. That is because Ruby 1.8.5's implementation (int_dotimes() in Numeric.c) optimizes for Fixnum: it does not call '+' method dynamically for Fixnum, instead, it just increases the integer directly. If you want to implement this method as same as Ruby 1.8.5 then you have to write code in system language.
This kind of optimization is all over the place in c ruby. I am not clear about its motivation, but I guess performance is one of the reasons. For example, "30000000.times {|x|}" is about twice faster than "i = 0; while i < 30000000; i +=1; end" in Ruby 1.8.5.
Difference people may have different opinions on what the 'right' behavior should be. As for me, I like the behavior of the pure ruby implementation better.
One of the best things I love about rubinius project is: their developers try to keep the dependency on system language (C in their case) minimal, and they take it seriously. Take a look of http://code.fallingsnow.net/svn/rubinius/trunk/kernel/core/, you will find out lots of buitlin libraries are implemented in pure ruby, even lots of string functions.
Pure ruby builtin has some drawbacks, though. One is performance penalty, the other is potential side effects. For example, basically Integer#times can be implemented as simple as this in pure ruby:
class Integer
def times
i = 0
while i < self
yield i
i += 1;
end
self
end
end
But this version of Integer#times does not work exactly the same as Ruby 1.8.5. If an user want to override Fixnum#+ (this may never happen in real life):
class Fixnum
def + x
return 9999
end
end
Our Integer#times's behavior will change, while Ruby 1.8.5 won't. That is because Ruby 1.8.5's implementation (int_dotimes() in Numeric.c) optimizes for Fixnum: it does not call '+' method dynamically for Fixnum, instead, it just increases the integer directly. If you want to implement this method as same as Ruby 1.8.5 then you have to write code in system language.
This kind of optimization is all over the place in c ruby. I am not clear about its motivation, but I guess performance is one of the reasons. For example, "30000000.times {|x|}" is about twice faster than "i = 0; while i < 30000000; i +=1; end" in Ruby 1.8.5.
Difference people may have different opinions on what the 'right' behavior should be. As for me, I like the behavior of the pure ruby implementation better.
发表评论
-
编译器的书
2008-01-04 01:12 2821有关编译器的书中"Dragon Book" ... -
新的各种ruby实现的性能比较
2007-12-04 06:13 2282Antonio Cangiano今天在blog上更新了各种ru ... -
xruby 0.3.2发布了
2007-11-29 06:00 1563基本和上一个版本(0.3.1)相比变化不大, 大多数都是bug ... -
三周的假期结束了
2007-11-27 20:44 1094用年假回国了一趟。由于时间太短,只在北京和兰州各待了几天。家里 ... -
YAML也要没人维护了
2007-11-05 12:45 1414sishen在xruby mailist提到YAML项目很可能 ... -
Strongtalk项目将无人维护了
2007-11-01 02:05 1976Strongtalk项目的Dave Griswold几天前发了 ... -
和日期相关的库
2007-10-29 22:52 1088上周加入了三个和日期相关的库: time.rb parseda ... -
xruby.googlecode.com
2007-10-23 13:24 1311刚才发现google code最近做了不少改进,其中的就是一个 ... -
复杂的依赖关系
2007-10-19 13:48 1273支持ruby on rails是xruby最重要的目标.我最近 ... -
rails application和web server
2007-10-17 01:31 1419部署到apache/lighthttpd的rails appl ... -
singleton.rb
2007-10-16 00:01 1150上一周的时间,基本上都在争取让xruby能支持singleto ... -
用Jakarta-ORO重写了Regexp
2007-10-10 00:36 2299这个javaeye上的blog本来是利用rss导入做的在国内的 ... -
xruby 0.3.0 released
2007-08-08 05:02 1690I am pleased to announce that X ... -
ruby -y
2007-06-12 15:14 1245For people who are interested i ... -
XRuby 0.2.0 released
2007-05-15 15:15 1171I am glad to announce that XRub ... -
InfoQ article on XRuby
2007-04-17 11:16 907Werner Schuster from InfoQ has ... -
XRuby 0.1.0 released
2007-01-29 22:32 1264[Link of this article: http://x ... -
On-Ruby interview
2007-02-19 03:33 1164Pat Eyler recently interviewed ... -
XRuby 0.1.2 released
2007-03-02 05:58 1242XRuby 0.1.2 is now available fo ... -
XRuby is faster than Ruby 1.8.5 in most benchmarks
2007-03-12 03:02 1733Two weeks ago, Antonio Cangiano ...
相关推荐
TStarBots Defeating the Cheating Level Builtin AI in StarCraft in the full game
unity_builtin_extra
内置着色器(Builtin Shaders)是Unity3D引擎的重要组成部分,它们为开发者提供了预设的图形效果,用于渲染游戏场景中的物体。在"builtin_shaders-2021.1.15f1.zip"这个压缩包中,包含了Unity 2021版本的内置着色器...
:FOR ${i} IN RANGE 1 10 \ Run Keyword If ${i} > 5 Exit For Loop \ Log To Console ${i} ``` #### 七、WaitUntilKeywordSucceeds关键字 **WaitUntilKeywordSucceeds** 关键字可以用来等待某个关键字成功执行...
`builtin_shaders-4.1.5.zip`这个压缩包包含了Unity 4.1.5版本的内置着色器源码,这对于开发者深入理解Unity渲染管线和优化图形性能具有极大的价值。 Unity的着色器系统基于ShaderLab语言,这是一种简化版的编程...
Unity内置着色器源码 版本:builtin_shaders-2018.4.22f1.zip Unity内置着色器源码 版本:builtin_shaders-2018.4.22f1.zip
本资源包"unity_builtin_shaders"包含了Unity引擎自带的着色器源码,这对于深入理解Unity渲染管道以及优化图形性能具有极大的价值。 首先,我们来谈谈什么是着色器。在图形编程中,着色器是一种程序,它运行在图形...
Unity引擎是全球广泛使用的3D游戏开发平台,其内置着色器(builtin shaders)是开发者进行视觉效果创作的重要工具。"builtin_shaders-2021.1.12f1.zip" 文件包含了Unity在2021年1月12日版本中的内置着色器资源,这些...
《Unity Shader深度解析:以“builtin_shaders-2018.4.1f1.zip”为例》 Unity是一款强大的游戏开发引擎,其强大的图形渲染能力离不开Shader的支撑。Shader,简单来说,就是控制计算机图形如何在屏幕上显示的程序。...
"builtin_shaders-4.6.5"是一个与Unity 4.6.5版本相关的压缩包,其中包含了该版本的官方着色器库。这个资源对于想要深入理解和学习Unity着色器的人来说是非常宝贵的。 Unity的着色器(Shader)是编程实体,用于控制...
这个名为"builtin_shaders-5.0.4f1.zip"的压缩包包含了Unity 5.0.4f1版本的内置着色器源码,这对于开发者深入理解Unity渲染机制、定制和优化着色器是非常宝贵的资源。 Unity Shader标签表明这个资源主要与Unity的...
在这个"builtin_shaders-2019.1.14f1.zip"压缩包中,包含了Unity 2019.1.14f1版本的内置着色器源代码,这对于学习和研究Unity的图形系统非常有价值。 "license.txt"文件通常包含软件的许可协议,对于Unity的内置...
builtin命令用于执行指定的bash内建命令, builtin命令调用的bash内建命令优先于同名的外部命令及同名的shell函数。 返回该内建命令执行的返回值,除非传递的不是bash内建命令或该内建命令被禁用。 语法格式: ...
$ npm install builtin-modules 用法 const builtinModules = require ( 'builtin-modules' ) ; console . log ( builtinModules ) ; //=> ['assert', 'buffer', ...] 原料药 返回从运行的Node.js版本获取的内置...
[Electron][JS][教學]_Nodejs基礎#03._require_函數介紹(二),_Builtin_modules
这个名为"builtin_shaders-4.3.4.zip"的压缩包包含了Unity 4.3.4版本的默认着色器源代码,这对于开发者来说是一个宝贵的参考资料,可以帮助他们深入学习和定制自己的着色器。 Unity的Shader系统基于Cg/HLSL语言,这...
Unity是一款广泛应用于游戏开发、虚拟现实、增强现实等领域的3D引擎,它的内置着色器(builtin shaders)是实现各种视觉效果的关键。源码分析能够帮助开发者深入理解Unity的渲染机制,提高自定义着色器的能力。在...
在C编程语言中,内置(Builtin)函数是编译器提供的一种特殊功能,可以直接在编译时进行优化,提高程序的效率。标题提到的`__builtin_add_overflow`,`__builtin_sub_overflow`和`__builtin_mul_overflow`是Clang...
Unity引擎是全球广泛使用的跨平台游戏开发工具,其内置着色器(builtin_shaders)是开发者在创建3D图形和视觉效果时不可或缺的一部分。"builtin_shaders-2019.4.10f1.zip" 是Unity的一个版本更新,包含了2019.4.10f1...