6 ms·
OT - I can't help but mentally shorten code snippets with underscore/whatever. For example, I see this - for(var index = 0, length = listItems.length; index <
by threepointone 14y ago
OT - I can't help but mentally shorten code snippets with underscore/whatever. For example, I see this -
for(var index = 0, length = listItems.length; index < length; index++) {
listItems[index].remove();
}
and I think to myself -
_(listItems).invoke('remove')
- zaptheimpaler 14y agoThat's awesome! Is that from underscore.js?
- threepointone 14y agoYup. I love the philosophy underlying underscore. The functions are ridiculously simple, but so powerful to use once you grok it.
- RegEx 14y agoI'm sorry, but can we please stop with the 'grok' thing?
- threepointone 14y agoI apologize, I didn't realize it's offensive to you/others. Seemed like a perfectly cromulent word.
- RegEx 14y agoIt might just be me. I just find it obnoxious.
- lhnn 14y agoDo you know the reference?
- falava 14y agoIt's from Robert A. Heinlein scifi book "Stranger in a Strange Land". In the novel native martians do exist and they are very smart. "Grok" it's the martian word for "water" and "to drink". Water is a scarce resource there, and, like here, very important for life. Drinking is putting water inside you but also occurs that this water becomes part of you. Then, in that society, drinking is used as the metaphor for understand something in a level that becomes part of you. I'm a native spanish speaker and I don't know if that word sounds bad in english, but for me the metaphor is so powerful and beautiful that I like it very much.
- shawndumas 14y agoI have been so conditioned by posting on HN to not reply with the banal, 'this', or, 'good one', that it almost seems wrong to just say, 'thank you for that post'.
- falava 14y agoThanks ;)
- lhnn 14y agoFYI I knew the reference, but was wondering if the agitated OP did. You explained it better than I would have. "To really understand something REALLY well".
- RegEx 14y agoPerhaps it's just been by a series of improbable coincidences that in the years I have read forums, IRC logs, books, and articles, I've only seen the term here on HN.
- lobster_johnson 14y agoCould be a case of Baader-Meinhof [1], or maybe you haven't been socializing in right forums. The word "grok" has been in popular use on Usenet since the early 1990s at least, probably before, since it's from a 1970s Heinlein novel. [1] http://wikibin.org/articles/baader-meinhof-phenomenon.html http://wikibin.org/articles/baader-meinhof-phenomenon.html
- davidarkemp2 14y ago"grok" thing? It's in the OED
- heretohelp 14y ago>The functions are ridiculously simple, but so powerful to use once you grok it. As a Lisp hacker and current learner of Haskell, this makes my spleen rupture. It's just functional programming 101, seriously. That's all it is.
- AlisdairO 14y agoJust to let you know, while you're 100% right, I downvoted you for unnecessary snark.
- threepointone 14y agoAck, didn't mean to offend you either. I like Lisp too (I'm learning Racket). I was just trying to explain how underscore.js makes me feel.
- heretohelp 14y agoMaybe your approach is better for the advocacy of functional programming anyway, makes it less intimidating.
- Kiro 14y agoHow does that work?
- threepointone 14y agohttp://underscorejs.org/#invoke http://underscorejs.org/#invoke In simple terms, it goes through the array, and calls the named function on every element. You could read it as - "For this array, invoke the 'remove' function on every element."
- thinkingisfun 14y agothat's funny, I'm the other way around.. whenever I see syntactic sugar implemented via javascript, I unroll it in my head and consider it overhead, compared to sending a bunch of more bytes down the wire which hardly matter after gzip.
- thedz 14y agoTIL javascript functions are syntactic sugar.
- thinkingisfun 14y agoAnd TIL stands for what, exactly? Sure you would not simply equate "syntactic sugar" with "syntactic sugar implemented in javascript".. so what are "TIL javascrip functions"? I tried searching, but no luck, woth none of the permutations. There are too many acronyms for TIL to just blindly guess. My point basically was that _(listItems).invoke('remove') is actually short for * [content of http://underscorejs.org/underscore-min.js http://underscorejs.org/underscore-min.js] _(listItems).invoke('remove')* and even if you removed all non-called parts from underscore, that's still a lot more complex than for(var index = 0, length = listItems.length; index < length; index++) { listItems[index].remove(); } it's just hidden, out of sight and out of mind.
- Terretta 14y agoTIL stands for Today I Learned. They were attempting to use a meme acronym sarcastically -- an example of content-free commenting that works well for karma elsewhere but hopefully doesn't gain a foothold here. On topic, I agree with your amplification of your point.
- brianfryer 14y agoIf you use memes on HN, you're going to have a bad time. (They tend to be downvoted to oblivion, 'round these parts.)
- thinkingisfun 14y ago
- quarterto 14y agoOr, in LiveScript: map (.remove!),list-items