On 2012-09-05 09:14, Nick Sabalausky wrote:

Totally agree. Although the odd thing with Ruby though is any time
I use it I feel like I have no idea what's *really* going on. Maybe
it's the lax parsing rules, or maybe I just need to learn it better, I
dunno. But yea, I'll agree AS2/PHP are to dynamic typing what C++/Java
are to static typing: Bad examples ;)

As with all things: that's the beauty, but can also a problem. The fact that you can call a method without parentheses is one of the things making it possible to create so nice looking DSL in Ruby.

But if you don't know the rules or every detail of the syntax that can cause problems. Example:

a = { :b => 3, :c => 4 } # associative array
b = :b => 3, :c => 4 # syntax error

def foo (arg)
end

foo(3) # ok
foo 3 # ok
foo { :b => 3, :c => 4 } # syntax error, conflicts with the block syntax
foo :b => 3, :c => 4 # ok
foo({ :b => 3, :c => 4 }) # ok

Then, as with all languages, you can do stupid things. For example, in Ruby it's possible to overwrite the whole standard library:

class String
  # overwrite the upcase method to return lower case
  def upcase
    downcase
  end
end

This can also be really useful. You can fix a bug in a library, but put the fix in your own project. No need for recompilation or distributing patched versions of libraries. The fix is distributed with the rest of your project.

But you can do just as stupid things in C or D. For example, you can write to arbitrary memory address.

--
/Jacob Carlborg

Reply via email to