Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
programming: Google TechTalk: Matz on Ruby 1.9
[go: Go Back, main page]

programming
 
recover password

reddit is a source for what's new and popular online. vote on links that you like or dislike and help decide what's popular, or submit your own!

45 points posted 3 days ago by damg 52 comments
Smallpaul 1 point 14 hours ago * [-]

In the video, Guido asks a question at the end about working with strings in a random-access manner (e.g. back-to-front). I stumbled upon the fact that negative indexing is insanely slow:

$ time ruby -v -e 'x=0;s="x"*(1500*(2**10)); (0...s.size).each{|i|x=s[-i]}'
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1]

real    0m1.217s
user    0m1.204s
sys 0m0.006s

time ./ruby -v -e 'x=0;s="x"*(1500*(2**10)); (0...s.size).each{|i|x=s[-i]}'
ruby 1.9.0 (2008-02-24 revision 15594) [i686-darwin9.2.0]

real    3m27.686s
user    3m19.653s
sys 0m2.478s

The strange thing is that negative indexing can be mathematically converted to positive indexes which are much faster.

 time ./ruby -v -e 'x=0;s="x"*(1500*(2**10)); (0...s.size).each{|i|x=s[i]}'
ruby 1.9.0 (2008-02-24 revision 15594) [i686-darwin9.2.0]

real    0m5.930s
user    0m4.078s
sys 0m1.846s

But even the positive indexes are much slower than Ruby 1.8.

time ruby -v -e 'x=0;s="x"*(1500*(2**10)); (0...s.size).each{|i|x=s[-i]}'
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1]

real    0m1.223s
user    0m1.204s
sys 0m0.017s

It is a matter for debate how often this will bite people in the real world, but it is a dramatic slowdown!

jfedor 10 points 2 days ago [-]

Hey, Matz, disable your screensaver when doing a public talk. :)

sjs 5 points 2 days ago * [-]

Heh, I kept touching my trackpad thinking my screen was dimmed.

tom101  comment score below threshold (0 children) [+]
ipeev 9 points 3 days ago [-]

So that is why Python is more popular, because Guido speaks better English.

dbenhur 18 points 2 days ago [-]

Perhaps. Python had decent English documentation at least five years sooner than Ruby did.

kaens 3 points 1 day ago [-]

I can attest that that is a large part of the reason that I'm more familiar with python than ruby.

marike 3 points 2 days ago [-]

Ruby has gained a ton of mindshare since Ruby on Rails was released.

But if more popular meant better, I would probably be using VB instead of Ruby.

sigzero 3 points 2 days ago [-]

Mindshare doesn't translate into tons of new programmers using it.

marike 1 point 1 day ago [-]

Oh really? Look at many startups using Ruby on Rails (Engine Yard, Thoughtbot, Errfree, etc). Do you think there existed the many programmers proficient in Ruby needed to staff all of these startups before Ruby on Rails?

malcontent 2 points 2 days ago [-]

Where would you get reliable statistics about which language was more popular?

I don't think job listing are reliable BTW.

Hobel -4 points 2 days ago [-]

Hmmm, but Matz wears magical underwear, shouldn't that count, too?

sofal 5 points 2 days ago [-]

Take your LDS hate elsewhere, please.

jbellis 5 points 2 days ago [-]

ah, now that's the kind of maturity and respect for others I'm coming to expect from reddit these days. :-|

sjs 3 points 3 days ago * [-]

I don't really mind the new -> lambda syntax but why do we need the parens around the arg list? I think -> x {x+2} looks cleaner than ->(x) {x+2}. Is there a reason that would be hard/impossible to parse? Default values for lambda params is cool, and it's great to see blocks bind their params in a new lexical env instead of snarfing existing local vars.

I wonder if there's a way to use the new lambda syntax for blocks so that we can shadow a local var in a block but still pass the value of that var as the default for the block param.

ie.

x = :frob
needs_a_block { |x=x| munge x}    # => doesn't work, but should return a munged :frob

If a trailing lambda were the same as a block that would be nice. (Semantically they should be same, not sure about Ruby's implementation).

x = :frob
needs_a_block -> (x=x) {munge x}

I hope that the internal string encoding stuff is intelligent in that it only processes what it needs. ie. if I call "cat in the hat"[3, 3] only the first 7 chars are translated/read/whatever-you-call-it. Unless you're doing intensive string processing I think it sounds like an ok way to do things.

Freeky 12 points 3 days ago [-]

I don't really mind the new -> lambda syntax but why do we need the parens around the arg list? I think -> x {x+2} looks cleaner than ->(x) {x+2}. Is there a reason that would be hard/impossible to parse?

Doesn't seem so:

irb(main):001:0> RUBY_VERSION
=> "1.9.0"
irb(main):002:0> ->(x) { p x }
=> #<Proc:0x000008013ab7a0@(irb):2 (lambda)>
irb(main):003:0> -> x { p x }
=> #<Proc:0x000008013a3348@(irb):3 (lambda)>
breach_of_etiquette 3 points 3 days ago * [-]

That's one sharp Japanese man. Needs to work on his English though.

UncleOxidant 34 points 3 days ago [-]

His English is a whole lot better than most American's Japanese.

chucker 7 points 2 days ago [-]

His English is a whole lot better than many Americans' English. ;-)

netzdamon 0 points 2 days ago [-]

It's better than mine and I am american

sjs 12 points 3 days ago * [-]

You're right, but most Americans aren't giving talks to Japanese people in Japanese so it's quite a different situation.

UncleOxidant 1 point 3 days ago [-]

Yeah, well maybe that's because there are much fewer Americans who can speak Japanese vs. Japanese who can speak English?

sjs 0 points 13 hours ago * [-]

You seem to have missed my point. The fact that his English is better than many Americans' Japanese is totally irrelevant. Just as it's irrelevant that his English is better than many British people's Japanese, or many Canadians' Japanese, etc.

Your point could have been relevant if it was: "Japanese-speaking Americans that talk in Japan have worse Japanese than Matz' English."

But it wasn't, hence it isn't. Anyway, I don't think it is a useful comparison regardless of its relevance.

ido 2 points 2 days ago [-]

Japanese isn't the de facto international language, though.

epvcu 3 points 3 days ago * [-]

your ability to speak Japanese doesn't make it a lie

earthboundkid 3 points 2 days ago [-]

そうかもね。

anonymous_hero 1 point 2 days ago [-]

わたしもかんじおぜんぜんよめません。ちょっとなさけないかもね。

earthboundkid 2 points 2 days ago [-]

へぇ?うそって漢字でも仮名でも書けるよ。そうかもって漢字で書けない。でも、仮名で書いても「かんじお」を書くのが変です。「かんじを」なんですよ。

anonymous_hero 1 point 1 day ago * [-]

I just thought you didn't know kanji either because you didn't use them with your "uso" and "usokamone".

Of course, it's still possible that you don't actually know kanji, but just used whatever kanjis popped up when typing that.

It's a bit peculiar that you should use kanjis though, when talking to someone who just said he doesn't know them.

Those bastards are a nasty impediment to learning Japanese, and I've heard that even some Japanese people find them bothersome/difficult.

( btw, I've spent all of 3.5 weeks in Japan and English is not my first language )

earthboundkid 1 point 1 day ago [-]

I didn't say uso kamo ne; I said sou kamo ne.

anonymous_hero 1 point 1 day ago * [-]

Oh, my bad. I'm blind.

But you did use kanjis, right?

theydonothing 0 points 2 days ago [-]

✡♐⌧♓✇ ✍⌨ॐ♑ ✵➲⌫⌦➢✗

tpdo  comment score below threshold (4 children) [+]
earthboundkid 7 points 3 days ago [-]

I taught in a Japanese high school for two years. His English is about as good as most of the Japanese people teaching English. It's not the best, but it's certainly not bad.

astrange 10 points 3 days ago [-]

Matz's spoken English is really good for a Japanese man, actually. They don't exactly get much chance to work on it.

Hobel 3 points 2 days ago [-]

Oh please, who does get a chance to work on their English if they aren't English-speaking?

In the computer business we have to deal a lot with English anyway, and besides that, anybody can learn, watch English movies / shows, and so on... (I'm German, btw.)

chucker 8 points 2 days ago * [-]

I'm German as well. If you want to attain and maintain a good command of English, you can. Just spend significant amounts of time abroad, watch English movies and shows like you suggested, read English magazines (e.g. Newsweek), read news articles in English rather than in your local newspaper (the Web makes this one ridiculously easy) and have a group of native English speakers you regularly talk to.

If Matz wanted to, he could. Instead, he chooses to focus on other things — such as maintaining an excellent programming language — , and he deserves respect for that as well. At the same time, he did decide to present in front of an English-speaking audience, so it is fair to criticize his lacking English skills.

I frequently see the excuse "but I'm not a native English speaker!", which is really another way of saying "improving my command of English is not exactly one of my top priorities", and I wish people were honest enough to put it like that.

Hobel 6 points 2 days ago [-]

Oh absolutely. I found his English to have quite an accent, but otherwise I don't know why people here complain. It's really not that bad.

I spent a year in US college, and I once had a class with an ex-Indian teacher. I quit after two weeks because I just couldn't understand a word he was saying. That was bad.

And I don't think you have to apologize for talking to an English audience if your English isn't that great. they don't have to listen to you, or even be there. So if you're at least trying, I think that's good (even though I hate bad accents, especially the German one).

JW_00000 1 point 2 days ago * [-]

Of course, there's still a difference between a German and a Japanese learning English. I speak Dutch, and I suppose that Germans, like Dutch-speaking people, can learn at least some English by just looking at subtitled movies. Dutch and German share a lot of words with English, use a similar grammar, and use the same alphabet. If someone Japanese wants to learn English, they have to build the whole thing up from the bottom. They need to learn the alphabet, the pronunciation, the vocabulary, the grammar and all its exceptions...

So, (and you probably agree with me here) I'm glad Matz decided to put his time into developing a great progamming language, instead of wasting his time and talent by learning perfect English first.

chucker 2 points 2 days ago [-]

I speak Dutch, and I suppose that Germans, like Dutch-speaking people, can learn at least some English by just looking at subtitled movies.

Actually, unlike in the Netherlands, the vast majority of movies in Germany are dubbed to German; there are no subtitles. Sure, you can often manually get them, e.g. by using DVD features, but you simply aren't exposed to spoken English while watching movies in the same way as you are in NL.

Dutch and German share a lot of words with English, use a similar grammar, and use the same alphabet.

Quite valid. The Japanese language is obviously starkly different.

So, (and you probably agree with me here) I'm glad Matz decided to put his time into developing a great progamming language, instead of wasting his time and talent by learning perfect English first.

I absolutely agree. I also agree with Hobel that Matz's English was quite comprehensible and effective in getting his points across.

cc81 1 point 2 days ago [-]

For example Swedes, even if I kind of suck. We don't have those dubbed movies or tv-series for example.

tom101  comment score below threshold (1 child) [+]