论坛首页 编程语言技术论坛

我喜欢Ruby的原因

浏览 68485 次
精华帖 (0) :: 良好帖 (12) :: 新手帖 (0) :: 隐藏帖 (2)
作者 正文
   发表时间:2008-04-20  
gigix 写道
smilerain 写道
一点意义都没有,你把这个封装成一个函数,下次一句话就掉用了不更简单.
ruby 只是多提供几个方法,只能说明有足够的库,就能够更方便的实现.

呵呵,你写一个来看看。很简单,假设已经有map这个函数,它遍历一个数组(或者列表,都行),对其中每个元素做一个操作,得到一个新的列表,前后两个列表的元素个数一样。
比如:

def double(x) { x * 2 }
a_list = [1, 2, 3, 4]
map(a_list, double) # [2, 4, 6, 8]


Java一个大毛病就是函数不是一等公民,high order就得用一堆诸如annonymous inner class之类的丑恶语法才能实现。C#至少这一点就比Java看着漂亮。


难度java不能够计算出这个Ruby结果?表述不出这个结构。

我只是感觉Ruby的变化还不够吸引我。
0 请登录后投票
   发表时间:2008-04-22  
smilerain 写道
gigix 写道
smilerain 写道
一点意义都没有,你把这个封装成一个函数,下次一句话就掉用了不更简单.
ruby 只是多提供几个方法,只能说明有足够的库,就能够更方便的实现.

呵呵,你写一个来看看。很简单,假设已经有map这个函数,它遍历一个数组(或者列表,都行),对其中每个元素做一个操作,得到一个新的列表,前后两个列表的元素个数一样。
比如:

def double(x) { x * 2 }
a_list = [1, 2, 3, 4]
map(a_list, double) # [2, 4, 6, 8]


Java一个大毛病就是函数不是一等公民,high order就得用一堆诸如annonymous inner class之类的丑恶语法才能实现。C#至少这一点就比Java看着漂亮。


难度java不能够计算出这个Ruby结果?表述不出这个结构。

我只是感觉Ruby的变化还不够吸引我。


任意一种图灵完备的语言都能做这件事吧?(某位大佬说的)
对于结果,哪个语言都是一样的. 这可以看作收益是相同的. 不同的是成本,你费了老多脑细胞敲了N行代码出来的东西,人家轻轻一挥就完了,难道这没有价值吗?

Ruby的变化不够吸引你,或者你没有深入学习,或者是无可厚非的个人偏好。
0 请登录后投票
   发表时间:2008-04-22  
mimimi 写道
ruby是个玩具,java是个工具.
吹嘘Ruby/Rails的,只是某个自己顶个开源帽子,专赚顾问费的公司(大家心照,我就不点名了)在哪里吹呀吹.
为什么?因为java它吹不过IBM\Bea\Oracle,没有办法只能开辟新战场,正好见到
Rails,就拿来吹呀.可惜呀,吹了几年,还成不了气候.
其本质原因是脚本语言本身就是一个扶不起的阿斗!!!


你还是点名吧。我也是用ruby/rails的,受不起。

一个运输小百货的司机,很是瞧不起拉石头的货车司机,不知人家拉的是金矿石。


0 请登录后投票
   发表时间:2008-04-22  
mimimi 写道
ruby是个玩具,java是个工具.
吹嘘Ruby/Rails的,只是某个自己顶个开源帽子,专赚顾问费的公司(大家心照,我就不点名了)在哪里吹呀吹.
为什么?因为java它吹不过IBM\Bea\Oracle,没有办法只能开辟新战场,正好见到
Rails,就拿来吹呀.可惜呀,吹了几年,还成不了气候.
其本质原因是脚本语言本身就是一个扶不起的阿斗!!!

(吐舌条),逗死我了,搞笑贴?
0 请登录后投票
   发表时间:2008-04-23  
我不懂ruby,从楼主给出的例子只看出代码简洁多了。

smilerain 写道
你把这个封装成一个函数,下次一句话就掉用了不更简单.
ruby 只是多提供几个方法,只能说明有足够的库,就能够更方便的实现.


感觉挺赞同这种说法..呵呵
0 请登录后投票
   发表时间:2008-04-23  
有些东西是无法通过封装几个方法或库来替换的,比如closure, Java是无论如何也封装不出来的。

正如C++无法封装出GC一样。

或许你辨解说C++可以实现GC,但是那也无法象java那样用。

所以说,语言的特性,是无法通过“封装”来实现替换的。

0 请登录后投票
   发表时间:2008-04-23  
rubynroll 写道
有些东西是无法通过封装几个方法或库来替换的,比如closure, Java是无论如何也封装不出来的。

当然可以封装出来咯,匿名内部类嘛,Ruby一句话的事情写10行嘛。
不是每天写代码的人,或者每天写代码却从不动脑子去想的人,说起这些事情来总是轻描淡写的
0 请登录后投票
   发表时间:2008-04-23  
针对最后一点,请参看DHH最新的blog
引用

The silent majority
from Loud Thinking by David Heinemeier Hansson

I had a great time on the West coast recently with stops in Santa Barbara and Palo Alto. What always surprises me at events like these is the huge number of people I meet that are doing cool things with Rails that I've never heard of. The kind of people who are just really happy to be using Rails and happy to build businesses with it.

Most of them are not heavily involved with the community in the sense of always being in front of it. They're not the ones constantly commenting on the blogs. They're just enjoying working with the tools. That's a really refreshing sentiment.

It's easy for people to think that the interaction they witness on the web is a complete reflection of the world in general. Often it's quite the contrary. Which is why I so enjoy getting out of the web world and meeting people in the flesh. Hearing their stories, discussing their concerns, and sharing passions.

You can easily end up burning out on web participation because the loud minority twists your perception of what matters and who cares. But there's nothing like meeting people who tell you that working with Rails or listening to a talk or reading something you wrote either touched them, changed them, or made them move in a new direction. That's a big pay-off for getting involved with public sharing.

So thank you so very much to everyone who came up to me at any of the events out in California. It makes it all worth it to hear your stories. Keep on rocking with whatever it is that you're doing. Keep the passion and the optimism alive.
0 请登录后投票
   发表时间:2008-04-23  
另外就是动态对象扩展会造成设计无法形成清晰的接口和接口文档,阻碍编程人员的交流。动态特性不能乱用。
同意姜太公的说法
0 请登录后投票
   发表时间:2008-04-23  
删掉了。
经授权后再发吧。
0 请登录后投票
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics