4 ms·
You're talking about ActiveSupport probably, and I really love it. It augments Ruby in a very beautiful way. I really like 2.days.ago There were zero times w
by joelbluminator 7y ago
You're talking about ActiveSupport probably, and I really love it. It augments Ruby in a very beautiful way.
I really like
2.days.ago
There were zero times were I wished it wouldn't do that.
But to each his own.
- pas 7y agoSupporting postfix operators, extension methods, etc. is different from monkey patching. Scala has "2 days ago" conversion to Duration type via implicits, but it doesn't monkey patches Integer for that. C# has extension methods and it can do the same without monkey patching. And monkey patching is not necessarily the end of the world, it's just error prone if multiple libs try to do it (on the same targets) without being careful.
- joelbluminator 7y agoNever said you can't reach the same outcome with other languages. I guess C# can do DateTime.Today.AddDays(-3). It's all turing complete, so yes, you can do it in assembly as well. I just really love Ruby's (Rails actually) 2.days.ago and never saw the harm in that. It's readable, easy and nice.
- sethammons 7y agoReadable yes. I don't feel it is writable. Discovery only happens when you read what someone else did or you guess unless you read over the entire docs related to $thing. It is a major reason I dislike Ruby as these things are encouraged. In testing, it is even worse. Made up DSL: Expect(myFunc).WithParams(4).To().BeCalled(1).Returns(8).InUnder(2). Milliseconds().WithEspilon(30).Microseconds(). You have to be fully familiar with a custom DSL to write this kind of test. I prefer Go's principal of "tests are just code." It is more verbose to write, but no custom DSL to learn. The more verbose code is often not harder to read either as it is the same code style as the application too.
- joelbluminator 7y agoRuby's default test suite is minitest, not RSpec. I agree that RSpec can be overkill sometimes. And well, libraries and frameworks expect you to go over their docs if u wanna use them, that's kinda universal. Can u write a Spring MVC app without going over he docs?
- jspash 7y agoYou'd be lucky if it was all just a chain of methods. In reality one of those links would be replaced by space. Which is an implicit method call. (Invisible parenthesis) I find this infuriating because the DSL isn't discoverable. You have to know what each method returns. Is it self, or is it a value. Spot the difference: Expect(myFunc).WithParams(4).To BeCalled(1).Returns(8).InUnder(2). Milliseconds().WithEspilon(30).Microseconds().
- pas 7y agoWhy isn't it discoverable? You know what type is returned by "To()" and if that has a BeCalled() method you can call it :) Now, the problem that requires an IDE, that many curse Scala for comes in when you have implicit things. So even if "To()" returns a WhateverTestDslElement that might not tell you anything because there might be a hundred implicit functions that convert WhateverTestDslElement to OtherFancyDslThingWithTheMethodYouAreLookingFor. Of course, at this point you are basically back to reading the documentation, which is kind of what C programming looks like. That said efficient and useful and really "domain specific" layers are great, and many systems would benefit from one. (Which is sort of what the whole clean code "entities" is about - https://blog.cleancoder.com/uncle-bob/images/2012-08-13-the-clean-architecture/CleanArchitecture.jpg https://blog.cleancoder.com/uncle-bob/images/2012-08-13-the-... )
- btilly 7y agoEver encountered code where you have to load 2 modules in a particular order or else they don’t work? Or maybe you didn’t figure out why a module that works fine for others doesn’t for you. Monkey patching is one of the top causes of that. And is part of why Ruby projects tend not to scale in complexity as well as Python.
- joelbluminator 7y agoIt's quite rare to be honest, so no. And I've been doing Ruby for a long time. It's not like every Ruby developer out there tries to monkey patch esoteric things just to confuse the enemy. And again, monkey patching is possible in every dynamic language.
- joelbluminator 7y agoI"ve seen a developer break 20000 websites at once because he monkey patched a jquery method in a widget our company built, so lets not make this out to be a Ruby thing.
- btilly 7y agoIf it is rare, then I must be unlucky. Because I'm not a Ruby developer, but I have had to help people diagnose exactly that problem more than once.