The language seems to do nothing but encourage questionable behaviour. And tooling is just gross!
I'm learning Ruby at the moment and find the syntax very readable but I haven't ventured into more complex topics and I certainly want to avoid 'magic' methods.
Ruby is the only language where I've accidentally copy-pasted unicode whitespace and the language decided that that character must be an undefined function:
puts "hello"
<main>': undefined method ` ' for main:Object (NoMethodError).
An example of magic. In our chef helper methods, you might see "company_app_helper_verify_app_started myApp". Naturally curious, you look for that function. It exists no where in your entire organization. Why? Because it is actually defined in two different files, one function is "company_app_helper" and the other is "verify_app_started," but because Ruby is amazeballs, you can create new functions on the fly and so something somewhere is conjoining the two methods into one method and doing magic to make it work. You can argue "yeah, but that is not Ruby's fault." And I would say that there are many Rubyists who love to do strange things like this.Optional Parenthesis. Now it is hard to tell what is an argument and what is a function call.
Testing. `expect(foo(4)).to be_nil`. You have to memorize a whole testing DSL to know your options. What can go after "to_"? `expect{ stock.increment }.to change(stock, :value).by(100)`... Like, while you can read it, you have no idea how to compose it without knowing the testing DSL. And the following:
describe "order" do
it "is marked as complete" do
expect(@order).to be_complete
end
it "is not yet shipped" do
expect(@order).not_to be_shipped
end
end
I can't see any value add to that over the following made up syntax that looks like most other tests I'm familiar with: func TestOrder():
order = new(Order)
if order.is_complete != "complete"
fail("expected to be complete")
if order.is_shipped == true
fail("should not be shipped yet")
The only difference being that in the second example, you just need to know your language's normal code to do the tests. No need for a framework full of custom extensions. Tests are just code.I think a lot of programmers love to build up an encyclopedia of obscure knowledge on how to do things in their languages. It gives them a sense of dominance or something. Personally, I don't want strange syntaxes that help in some obscure case. I want straight forward code that is both straight forward to read and to write. I don't want custom DSLs, strange test structure, and such. I want a new person on my team who is basically familiar with C-like syntax to be able to be productive quickly.
I wonder if the use of DSL reflects a poor choice for solving the problem rather than an inherent problem in Ruby?
> I think a lot of programmers love to build up an encyclopedia of obscure knowledge on how to do things in their languages. It gives them a sense of dominance or something. Personally, I don't want strange syntaxes that help in some obscure case. I want straight forward code that is both straight forward to read and to write.
I agree 100% and this behaviour can be found in programmers across all languages.