News for hackers. Stuff that matters.
Re:Show HN: NSString + Ruby by jakobe on Friday October 11, 2013 @01:30AM (#6531544)
One thing that irks me is that the author doesn't stick to ObjC naming conventions.

Take for example the capitalize methods. In ruby, you have "capitalize" and "capitalize!" to distinguish the immutable and mutable versions. To make this distinction in ObjC, you generally use nouns vs. verbs. So for the equivalent of ruby's "capitalize", you'd use "capitalizedString" (which is in fact provided by NSString). But the mutable version, the equivalent of ruby's "capitalize" should simply be "capitalize", not "capitalizedStringInPlace".

Re:Show HN: NSString + Ruby by thingsdoer on Friday October 11, 2013 @02:45AM (#6531750)
-(NSString*)capitalizeInPlace; is the actual signature.

The reasoning for this is for consistency, while still maintaining autocomplete proximity.

Re:Show HN: NSString + Ruby by jakobe on Friday October 11, 2013 @03:31AM (#6531873)
I'm not really sure I understand; why would calling the method "capitalize" instead of "capitalizeInPlace" be inconsistent?

(Also, the comments in the header file and the README file contain the name "capitalizedStringInPlace" instead of "capitalizeInPlace")

Another inconsistency is that most mutating methods in ObjectiveC don't return self, but either void or a boolean or an integer that reports if the method succeeded. But I assume that this inconsistency is on purpose because you want to make the methods chainable.

Re:Show HN: NSString + Ruby by thingsdoer on Friday October 11, 2013 @04:05AM (#6531933)
The issue with the default syntax in NSString is that the mutating methods are the more concise, but are also the ones you use the least. It makes far more sense for the more used methods to be more concise than their mutating siblings.

I don't disagree with you though. I'd prefer if the interface for this was more idiomatic.

Returning void is sort of pointless. A boolean, maybe. I feel like returning self is just making better use of things, really, and probably doesn't really cause any confusion.

Re:Show HN: NSString + Ruby by jakobe on Friday October 11, 2013 @05:27AM (#6532174)
Okay, now I get it, the naming makes autocomplete more convenient.

Returning void makes it easier to spot errors. If you accidentally use "capitalizeInPlace" instead of "capitalizedString" your code will compile without issues. If the mutating method returned void, it would result in a compile error.

Re:Show HN: NSString + Ruby by thingsdoer on Friday October 11, 2013 @05:46AM (#6532214)
That's an extreme edge case though, since if you're using a mutating method, you're using a mutating string, and you're probably aware of that.
Re:Show HN: NSString + Ruby by khangtoh on Friday October 11, 2013 @02:18AM (#6531673)
What's stopping you from submitting a pull request with these suggestions?
Re:Show HN: NSString + Ruby by jakobe on Friday October 11, 2013 @03:41AM (#6531891)
Two reasons:

a) The author might disagree with my asessment. A pull request would imply that I consider it an error, but I think it's more a question of style.

b) I already waste too much time on HN. Forking a project, trying to understand all of it, making changes, writing a pull request, etc. would probably take me all day but I need to clean the kitchen and take care of the kids and work on some overdue client work that I have been postponing for far too long.

Re:Show HN: NSString + Ruby by fosk on Friday October 11, 2013 @04:20AM (#6531956)
If you open a new issue on GitHub, somebody else could fix it.