A couple of weeks ago, I started working on Underscore.m. It’s a small utility library that helps you with manipulating data structures in Objective-C.
Here’s a quick example:
If you know Objective-C, you can probably tell that it uses a somewhat unconventional syntax. Underscore.m eschews square brackets as they are not well suited for chaining. [[[[[[[[[They will pile up at the beginning of your call chain and add unnecessary noise.
Don’t get me wrong, I think named arguments in Objective-C are great. They make code a lot more self-descriptive. Consider
compared to, let’s say its Java equivalent
The latter makes it much harder to guess what those two parameters mean. Now, Java’s popular IDEs make it easy to look up the documentation or definition of methods, but it’s still an unnecessary overhead.
However, the Java example is still a lot shorter, so named arguments are clearly a double edged sword.
If you’ve written at least a tiny bit of Objective-C, you’ve probably come in contact with
which, thankfully, Objective-C now has a literal for:
Similarly, the usual functional suspects like
tail etc., are
well understood and don’t need a verbose, 20 character selector associated with
This is were Underscore.m comes in. By providing a tool-set of the most common functional idioms, it tries to encourage developers to structure their operations in small, concise chucks.
Similar to Objective-C’s new literals, I hope its clarity can outweigh conventions.Posted in working-on