6 ms·
_.m: A port of Underscore.js to Objective C
- justinvoss 14y agoAs someone who knows both Javascript and Objective-C, this is less readable than either. Underscore.js may have some useful abstractions, but they'd be better exposed as Objective-C categories rather than trying to shoehorn everything into Javascript syntax.
- Groxx 14y ago'Underscore.m' seems a lot nicer to me: http://underscorem.org/ http://underscorem.org/ I mean, what? N* value = (N*) hash.getOrAdd(l, ^{ return N.I(0); }); I'll take a minor increase in verbosity for a massive increase in readability in the future. (edited; unwrapping is needed in both libraries)
- aaronbrethorst 14y agoAgreed, I hadn't seen this library before.
- Groxx 14y agofwiw, I do like seeing a variety of libraries - they occasionally come to the same kind behavior through different techniques. It's a fun way to get a deeper knowledge of the language.
- jawngee 14y agoWhat an abortion. Seriously just stop. Every time I see someone misuse properties like this on Objective-C, I want to hire them to work at my company just so I can fire them. And then I would call them a few days later and apologize for being so rash and convince them to come back and work for me just so I could fire them again once they've settled into their desk. Nobody wants your shitty javascript syntax mixed in with Objective-C. Nobody but you anyways. This isn't smart, regardless of whatever functionality it provides. You've done all this work to create this awkward, unclear, confusing, cryptic layer of shit that makes no sense when read. If I have to read documentation to understand what is going on, you've failed. This is full of fail. WTF is A? N? N.I what the fuck is that? underscorem is better for sure, but it still abuses property syntax in a way that I would reject on any project I saw its use in. I'm always amazed at how much work people want to put into not having to write proper Objective-C. It doesn't make any sense. So slow clap for writing some useless crap. Sorry for the vitriol, but this shit is just dumb.
- jawngee 14y agoAnd just as a follow up, it's kind of sad because it looks like you put a lot of work in this. But as someone who writes nothing but Objective-C (well, some C++ too) all day, every day, for a living. I would never ever use this. Mostly because it's obvious that you don't get objective-c and are trying to shoe horn some weird javascript idioms into a place where it doesn't belong. I hate seeing wasted effort. I understand underscore provides nice functionality in javascript land and would appreciate someone taking the time to bringing similar functionality to objective-c in a way that fits and is natural with it's surrounding code. As this is, no.
- obituary_latte 14y agoCan't wait to see your version. When it does come out, I hope others can be constructive without coming across like a cunt. Nobody likes that stuff, and as we all know, it's not very helpful.
- sirclueless 14y agoWell, it's not his, but http://underscorem.org/ http://underscorem.org/ looks wayyyy cleaner. It's not the basic concept of a collection of array and hash manipulation functions that's contentious, it's the godawful syntax brought on by abbreviating all of Objective-C's types.
- ashray 14y agoI'm curious to know then what your take on coffee script is ?
- floatingatoll 14y ago"How dare people port X to run on Y! This has no place in production code and you are WASTING OUR TIME doing theoretical experiments!" Saying "Sorry for the vitriol" doesn't excuse being an ass, it just confirms that you were being an ass intentionally. How is your verbal assault an appropriate response to this project?
- revelation 14y agoI don't get it. So this is a poor mans LINQ? Without the necessary performance considerations and a distressing lack of language support for its primitives?
- pzearfoss 14y agoI feel as though most of these functions can be achieved with existing methods or with other libs like blocksKit. Apart from the downright foreign (to objective-c) syntax what makes this different?
- Groxx 14y agoIt's probably just another attempt to build the same thing. Maybe for learning, maybe because they didn't know others existed (blockKit is new to me, fwiw). Maybe as a curiosity.
- mpweiher 14y agoFor a more Objective-C-ish take on these sorts of functional idioms, have a look at Higher Order Messaging: myStrings = @[ @"hello" @"world" ]; upperCase = [[myStrings collect] upperCaseString]; myInts = @[ @1 @2 @3 ]; sum = [myInts reduce] add:@0]; [[self onMainThread] doSomething]; [[delegate ifResponds] delegateMessage]; Blocks also work, but the built-in methods tend to be a tad verbose.
- SeoxyS 14y agoWow, I just found out about Higher-Order Messaging. This is pretty awesome. Here are some links for more info: - http://cocoadev.com/wiki/HigherOrderMessaging - http://macdevcenter.com/pub/a/mac/2004/07/16/hom.html --- As an aside, I like to use my own [ATFunctionalCollectionExtensions][] for this purpose, which is a blocks-based implementation of map, reduce, inject, each, and filter. [ATFunctionalCollectionExtensions]: https://github.com/kballenegger/ATFunctionalCollectionExtensions https://github.com/kballenegger/ATFunctionalCollectionExtens...
- mmariani 14y agoFirst of all, language design is tough business. And for not appreciating that, with all my heart, I thank Netscape's project managers for rushing JS designers. That said, I don't get all the hate towards ObjC. Taking into consideration its requirements, I think it has been doing great for us. As for _.m, I appreciate the effort taken by its author, really. However, I won't be using it because it hurts one of the most pristine features of ObjC, which is readability. Fix that, and you'll get a lot more love from the community.