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

And 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] _(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.



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


If you use memes on HN, you're going to have a bad time.

(They tend to be downvoted to oblivion, 'round these parts.)


Oh. Thanks, I get it now.

I guess while syntactic sugar is usually considered a functionality of the language itself, it surely is used in the way I meant it, too... random search result:

http://www.developerdrive.com/2012/05/an-introduction-to-und...

"In this part of the tutorial we’re going to take a look at some of the syntactic sugar that Underscore gives us to work with array-like collection."

And of course, even if I had been utterly wrong for using the term, my point would stand unmoved, but you know that :)


I can get where you're going with this, but as someone who uses underscore everyday I have to say in this particular case I don't agree with you.

Underscore as a production library is 4kb. The functions are terse, and its extremely easy to understand what they're doing - nothing is generally hidden (this example is pretty easy to understand, yet one of the most "complex" uses of underscore I've seen).

At the end of the day on a production javascript app of multiple thousand lines of JS, it likely actually saves me bytes over the wire from not having to write "for(var x = 0...." every time I want to iterate through something or filter an array or find if an array includes something etc (There's around 70 bytes removed in this single example).


Well, of course it matters how often you do it. I would not do it in loops, or often called event handlers, such as scrolling. If you do it once on page load, sure, it hardly matters.

But if you do it a lot in your code, that just means you can easily copy and paste it from a nearby place? At least that's what I often end up doing.


I've been using underscore for a few months and had no idea that you could call _ as a function until today. Pretty amazed that I missed this all along. Thanks for this!




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

Search: