Dynamic typing does not come close to closing it. For one great example, Ruby simplifies metaprogramming in many cases. In Java, metaprogramming is either painful or impossible.
For example, take Ruby the usual way of declaring properties:
class SoftDrink
attr_accessor :name, :sugar_content
end
can = SoftDrink.new
can.name = 'Coke'
can.sugar_content = 9001
This is not some special language syntax - it is a method of the Module class, and it is easy to implement. Here's an example implementation attr_accessor:
class Module
def attr_accessor(*symbols)
symbols.each do |symbol|
define_method(symbol) {instance_variable_get "@#{symbol}"}
define_method("#{symbol}=") {|val| instance_varible_set("@#{symbol}", val)}
end
end
end
This functionality allows you a lot, yes, flexibility in how you express your programs.
, ( ), Ruby. , :
dependencies = %w(yaml haml hpricot sinatra couchfoo)
block_list %w(couchfoo)
dependencies.each {|mod| require mod unless block_list.include? mod}