News for hackers. Stuff that matters.
Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by lloydatkinson on Tuesday April 23, 2024 @08:50AM (#40131376)
Heavens help us if we are naming features after an accidentally popular library like jQuery.
Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by sausajez on Tuesday April 23, 2024 @08:54AM (#40131411)
Accidentally? How can something be intentionally/ unintentionally popular?
Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by PurpleRamen on Tuesday April 23, 2024 @10:13AM (#40132242)
Marketing makes something intentionally popular.

Accidentally, seems harder. It kinda smells for people to intentionally make it not popular by actively working against fame, or something like that..

Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by robertlagrant on Tuesday April 23, 2024 @12:25PM (#40133779)
> Accidentally, seems harder. It kinda smells for people to intentionally make it not popular by actively working against fame, or something like that..

It's not harder; it's the only thing that works for tools. Tools cannot be good for long because of marketing. Marketing is the thin layer of paint over the Ferrari. Very nice paint, but if the car doesn't work or go very fast very quickly then that's that.

Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by robertlagrant on Tuesday April 23, 2024 @12:22PM (#40133748)
It wasn't accidentally popular. It was just very good.
Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by throwup238 on Tuesday April 23, 2024 @12:10PM (#40133597)
That ship sailed with Javascript in 1995.
Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by lloydatkinson on Tuesday April 23, 2024 @09:56AM (#40132025)
I made the mistake of forgetting HN simultaneously hates the web and JavaScript but worships jQuery
Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by The_Colonel on Tuesday April 23, 2024 @11:41AM (#40133214)
JS DOM API is still abysmal and jQuery API is still great. No worshipping needed.
Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by recursive on Tuesday April 23, 2024 @12:20PM (#40133715)
Really? Genuine question, which part? If there are too many to name, how about just one? It seems pretty good to me.
Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by The_Colonel on Tuesday April 23, 2024 @01:45PM (#40134798)
My favorite is this comparison for checking whether an element is hidden:

    $(el).is(':hidden')
vs.

    !(el.offsetWidth || el.offsetHeight || el.getClientRects().length)
DOM API has other problems like lack of chaining which forces you into a very imperative style of programming, e.g.:

    $(".alert").hide();
vs.

    for (const el of document.querySelectorAll(".alert")) {
         el.style.display = 'none';
    }
Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by recursive on Tuesday April 23, 2024 @02:00PM (#40134994)
I've never had a case where I didn't know the reason or mechanism by which an element would be hidden. In my code, I use the `hidden` property. In that case it simplifies from

    $(el).is(':hidden')
to

    el.hidden
It's not quite as succint as your jquery, but you also could have written this.

    document.querySelectorAll(".alert").forEach(el => el.hidden = false);
Is it less imperative? I mean I guess it doesn't have an explicit loop, but I don't really see why that's good or bad.
Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by The_Colonel on Tuesday April 23, 2024 @02:29PM (#40135412)
> I've never had a case where I didn't know the reason or mechanism by which an element would be hidden.

Unfortunately, I usually don't keep the whole codebase in my head (including libraries), so I often don't know the reason.

The more general point is that I don't want to have to know, because the mechanism of how it is hidden is not what I care about.

> It's not quite as succint as your jquery, but you also could have written this.

Yes, it's more than three times as long as the jQuery variant.

Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by recursive on Tuesday April 23, 2024 @03:11PM (#40135947)
Ok, I get it. Fair points. I'm not a jquery hater. In a lot of cases, I'd rather write jquery than react for instance.
Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by troupo on Tuesday April 23, 2024 @06:08PM (#40137937)
jQuery has a fluent interface and often shorter/smaller/more convenient APIs on top of that.

DOM APIs are quite literally 90s era Java-style APIs.

While DOM APIs have pulled in a few niceties over the years, some of them are really anemic (e.g. querySelectorAll does not return a proper Array-like object). Worse is combining them. Almost every API is a single-shot tedious step-by-step chore.

Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by kreetx on Tuesday April 23, 2024 @08:59AM (#40131456)
It's often referred to as the masonry layout, so why not?
Re:Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout by chickenchase-r on Tuesday April 23, 2024 @09:09AM (#40131544)
because every new construction requires a solid cornerstone? every archway a keystone? dont forget to put your boots in the trunk and your trunk in the boot. Nucular aluminum? I dunno