Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Never 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.



Readable 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.


You'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().


Why 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-... )


Ruby'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?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: