Live data from Hacker News

Ruby's exceptional creatures

exceptionalcreatures.com

11–20 of 133 posts

Re: Ruby's exceptional creatures

#14
post #12

[flagged]

Reading your comment one would think Ruby is the only programming language with exceptions. In fact, lots of programming languages have them, even PHP. https://www.php.net/manual/en/language.exceptions.php

If I had a dollar for every time I forgot in PHP which Array methods are 'haystack, needle' and which are 'needle, haystack'.

Re: Ruby's exceptional creatures

#15

It's painful to see method_missing called out as a first class solution in the first creature https://www.exceptionalcreatures.com/bestiary/NoMethodError.... . "Practical Ruby" has three chapters dedicated to method_missing. "define_method" is more common these days and also painful to see. Ruby gets a lot of criticism for embracing magic and indirection ("Ruby, the bad parts of Perl"). It has some good parts (no fun…

Respectfully mostly disagree. Ruby is full of sharp knives. Other languages have dull knives. Writing code without thinking will cut you either way. Things like method missing are exactly the right solution for a certain set of problems. If used thoughtfully, they’re amazing. If used thoughtlessly, bloody mess. But this is true in every language.

If you want to be wowed by how incredible method_missing and define_method are, read through ActiveSupport and ActiveRecord's source code.

Early in my career I made my own toy ActiveRecord implementation and it's full of define_method and was literally the first time in my life that programming felt like a real superpower.

Re: Ruby's exceptional creatures

#16

It's painful to see method_missing called out as a first class solution in the first creature https://www.exceptionalcreatures.com/bestiary/NoMethodError.... . "Practical Ruby" has three chapters dedicated to method_missing. "define_method" is more common these days and also painful to see. Ruby gets a lot of criticism for embracing magic and indirection ("Ruby, the bad parts of Perl"). It has some good parts (no fun…

I definitely prefer Clojure/Elixir-style macros to Ruby’s meta-programming features.

They’re still better than nothing, though. Method-mossing and friends played a critical role in making a framework like Rails possible in Ruby. In contrast, languages like Python and JavaScript just aren’t quite expressive enough to do it. A lot of energy went into attempts over the years, too! At best, something like Sails could get 2/3 off the way there and offer significant advantages on another axis, like making websockets first class.

Re: Ruby's exceptional creatures

#17
post #12

[flagged]

Reading your comment one would think Ruby is the only programming language with exceptions. In fact, lots of programming languages have them, even PHP. https://www.php.net/manual/en/language.exceptions.php

Exceptions are not the issue, Ruby's inherent "cleverness" is. Whatever problems the original commenter has with exceptions likely stems from this.

Re: Ruby's exceptional creatures

#19

It's painful to see method_missing called out as a first class solution in the first creature https://www.exceptionalcreatures.com/bestiary/NoMethodError.... . "Practical Ruby" has three chapters dedicated to method_missing. "define_method" is more common these days and also painful to see. Ruby gets a lot of criticism for embracing magic and indirection ("Ruby, the bad parts of Perl"). It has some good parts (no fun…

[deleted]

Re: Ruby's exceptional creatures

#20

It's painful to see method_missing called out as a first class solution in the first creature https://www.exceptionalcreatures.com/bestiary/NoMethodError.... . "Practical Ruby" has three chapters dedicated to method_missing. "define_method" is more common these days and also painful to see. Ruby gets a lot of criticism for embracing magic and indirection ("Ruby, the bad parts of Perl"). It has some good parts (no fun…

[deleted]
Post reply on HN