Arc Forumnew | comments | leaders | submitlogin
4 points by pg 6126 days ago | link | parent

If you're comparing for length, at least use dot notation.


6 points by steadicat 6126 days ago | link

I think the key point is that Ruby's power can be achieved with less syntax forms without compromises.

The fact that Python's way also happens to be shorter is not the main point, just an added plus.

-----

2 points by jules 6126 days ago | link

Are you aware that x..y and x...y notation is a Range literal in Ruby? I like Pythons syntax better but range notation isn't special syntax for slices.

obj[a,b,...] is sugar for a method call in Ruby (you can define a [] method for your own classes). So there's really only two syntactic forms here, and arguably no special syntax for slices.

-----

1 point by mdemare 6126 days ago | link

I'm counting each occurrence of i,j and x, each occurrence of 1, and each occurrence of len, + and (binary) -.

That yields the following scores: Python : 1 1 1 1 1 4 2 4 2 4 => 21 Ruby : 1 1 2 2 2 2 2 2 2 2 => 18 Arc : 1 3 2 3 1 4 2 4 4 8 => 32

15 is the best possible score. This is meant as succinctness benchmark for the index and slice/cut operations, which are extremely common.

-----