Hacker News new | past | comments | ask | show | jobs | submit login

> The only thing I don’t like about jQuery is that commands fail silently when a selector finds zero results.

The set-operatic approach of jquery is one I absolutely love about it, though it does lead to unforeseen behaviours in edge cases (sometimes performance concerns running code on nothing or on way more than expected) it's leads to extremely convenient and fluent code, much more so than the explicit iterations of the normal DOM.

> More often we expect something to happen, and the cases where the results might be empty are obvious enough that adding a “fail silently” flag in those cases wouldn’t be a hardship.

Extending jquery to assert a lower bound (and even an upper bound as well) wouldn't be a hardship either.




A few years before I encountered jQuery, I found an experimental programming language that tried to do away with the distinction between variables that contained 0-1 values and those that contain 0-n. In this language, all operations were set operations. When your data model changed from 1:1 to 1:n (classic example - user:address is probably the concept I’ve seen mis-modeled the most often).

So when I saw jQuery for the first time, I’d already been primed for this concept. I’m a little surprised it’s been used so infrequently.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: