News for hackers. Stuff that matters.
Re:jQuery 4.1.0 by hax0ron3 on Tuesday November 17, 2026 @03:32PM (#50537763)
Although jQuery isn't very relevant these days, I still find its pattern of chaining a sequence of methods on a set chosen by a selector to be a beautiful example of going with a language's features.
Re:jQuery 4.1.0 by embedding-shape on Tuesday November 17, 2026 @03:54PM (#50538043)
[delayed]
Re:jQuery 4.1.0 by kiliancs on Tuesday November 17, 2026 @03:57PM (#50538079)
It was not commonplace at the time jQuery was released.
Re:jQuery 4.1.0 by tyre on Tuesday November 17, 2026 @03:58PM (#50538087)
Method chaining is library-specific, a function of methods returning `this`/`self`.

jQuery made the decision to do this, not JavaScript.

Re:jQuery 4.1.0 by hax0ron3 on Tuesday November 17, 2026 @04:37PM (#50538546)
Yes, I'm talking about using JS' method chaining. That's what I mean by "going with a language's features".
Re:jQuery 4.1.0 by btown on Tuesday November 17, 2026 @04:06PM (#50538194)
To that point, there was a conscious choice that the return type of most method invocations (except in specific "read a value" modes) should be a standardized container type.

That was, and still is, rare! And in a time without type checking and bundling, it was vital. Match your parentheses and quotes, and your jquery code might not find what you want, but it would (likely) not throw exceptions.

For those unfamiliar, I recommend looking at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/mast... and searching for the 201 instances of

    : this
in that file. A remarkably fluent API. We could all be so elegant.
Re:jQuery 4.1.0 by submain on Tuesday November 17, 2026 @09:28PM (#50541102)
I'm just sitting and waiting until someone mentions "monads"...
Re:jQuery 4.1.0 by hax0ron3 on Tuesday November 17, 2026 @09:29PM (#50541106)
I considered doing it in my top-level comment but I decided not to, since I don't actually know enough about monads to be sure that I know what I'm talking about, lol.
Re:jQuery 4.1.0 by lgas on Wednesday November 18, 2026 @02:09AM (#50542853)
Looks like you beat them to it. Good job.
Re:jQuery 4.1.0 by paulddraper on Tuesday November 17, 2026 @04:39PM (#50538569)
This is called a fluent interface [1].

A TC39 Stage 2 proposal adds this into the language itself with the pipeline `|>` operator. [2]

[1] https://en.wikipedia.org/wiki/Fluent_interface

[2] https://github.com/tc39/proposal-pipeline-operator

Re:jQuery 4.1.0 by anamexis on Tuesday November 17, 2026 @05:14PM (#50538998)
Fluent interface is method chaining, and it's already obviously in JS. The proposed pipeline operator is neither method chaining nor fluent interface.
Re:jQuery 4.1.0 by abanana on Tuesday November 17, 2026 @05:37PM (#50539273)
As I understand it, it's a different method to create something that matches the whole idea of a fluent interface, without having to build every method to support chaining, isn't it? And in a way that works for all language features rather than just your custom methods?

Maybe not precisely the same from a technical point of view but is it just pendantry to argue against someone referring to it as a fluent interface? Happy to learn and to be corrected if required.

Re:jQuery 4.1.0 by anamexis on Tuesday November 17, 2026 @06:20PM (#50539630)
What is the "whole idea" of a fluent interface if not specifically method chaining?
Re:jQuery 4.1.0 by abanana on Wednesday November 18, 2026 @05:36AM (#50544518)
paulddraper has phrased it perfectly in answer to your previous post - chaining everything so that the process flow reads fluently from left to right. (I'm replying just to avoid leaving your question hanging.)

To suggest the pipeline proposal must not be referred to as a "fluent interface" would seem to me to be arguing semantics, ignoring the point behind the words, or the facts that they can have implied meanings or subtle changes over time.

Re:jQuery 4.1.0 by anamexis on Wednesday November 18, 2026 @09:12AM (#50546542)
I think the point behind the words is that it is a specific design pattern based on building DSLs using method chaining. I don't think pipelines, broadly, are an implementation of that design pattern. It's a way to string together function calls in a way that they read left-to-right, yes, but the spirit of "fluent interface" is not just "reads left-to-right." It's a specific pattern.
Re:jQuery 4.1.0 by everforward on Tuesday November 17, 2026 @08:26PM (#50540702)
It can, but the typical usage I’m used to is far less structured and need not involve the value having the same type at every point. Eg something like

|> docker.listContainers() filter(x => x.name == “something”) first getNetwork getIpAddress toString ping

(ignore that some of these should be chained and some should be arguments, I haven’t read the proposal fully)

They’re doubly nice in Clojure because of the lazy evaluation. You can map a pipeline over a list and it will evaluate one at a time rather than pre-evaluating and allocating memory for the whole thing.

Re:jQuery 4.1.0 by paulddraper on Tuesday November 17, 2026 @11:34PM (#50541917)
The pipeline operator makes it possible to chain any functions.

Which true is not per se fluent interfaces, but it reads similarly. And "fluent" as the name suggests, has a lot to do with how it reads.

Re:jQuery 4.1.0 by pwdisswordfishq on Tuesday November 17, 2026 @06:23PM (#50539653)
Meh, other than being easier to type, it's nothing to sing praises about. It is harder to reason about, both for the interpreter (which does not immediately know that the return value is the same object as the receiver and therefore cannot optimize based on that assumption) and for the programmer (which has to look up documentation to learn the same).

I hope https://github.com/tc39/proposal-pipeline-operator and perhaps also https://github.com/tc39/proposal-do-expressions will put it to rest.

Re:jQuery 4.1.0 by leptons on Tuesday November 17, 2026 @06:33PM (#50539750)
Not very relevant? It's still powering 64% of the websites in the world in 2026. React is only powering about 6% of the website sin the world today.

Jquery is only not relevant if you're living in a tech bubble that demands that "new, shiny" is the only thing that could possibly be relevant.

Re:jQuery 4.1.0 by greenchair on Tuesday November 17, 2026 @07:18PM (#50540181)
amen
Re:jQuery 4.1.0 by hax0ron3 on Tuesday November 17, 2026 @08:20PM (#50540658)
True. I am living in such a tech bubble. It has been a very long time since I've worked with jQuery. Which is separate from my personal feelings about jQuery, since I'm a jQuery fan - although these days I wouldn't use it, since changes in Web APIs, changes partly inspired by jQuery, have made it possible to write jQuery-esque code without actually loading jQuery.
Re:jQuery 4.1.0 by addedlovely on Tuesday November 17, 2026 @08:50PM (#50540874)
Where are those numbers from, I make it about 53% and 10% for react. https://theweb.report/#front-end

But still everywhere!

Re:jQuery 4.1.0 by hk1337 on Tuesday November 17, 2026 @07:03PM (#50540049)
Mootools was way better but never got the attention jquery got.
Re:jQuery 4.1.0 by thallavajhula on Tuesday November 17, 2026 @07:03PM (#50540054)
If you pick a pure OOP language like Ruby, you'll have the same experience. You can pick a literal and call a method on it and chain the method calls. It's lovely.
Re:jQuery 4.1.0 by lofaszvanitt on Tuesday November 17, 2026 @09:32PM (#50541125)
Why? It's still the sanest choice for a site that doesnt need a bloated js "framework".
Re:jQuery 4.1.0 by skrtskrt on Tuesday November 17, 2026 @10:10PM (#50541391)
Things like Alpine, HTMX, and Datastar seem to be more in favor these days.

They have the small surface area of jQuery, but still aim for component-based reactivity and SSR-when-possible which just aligns more with the mental model and development preferences that have developed from the whole world of React/Next and similar.

Re:jQuery 4.1.0 by hax0ron3 on Wednesday November 18, 2026 @12:17AM (#50542157)
Given how good AI is at coding, I'd be tempted to just have it write vanilla Typescript that uses direct DOM manipulations unless I really wanted to leverage a framework's ecosystem of components.
Re:jQuery 4.1.0 by sgt on Wednesday November 18, 2026 @02:54AM (#50543134)
Correct, vanilla JS is widely accepted as a robust way of achieving the same. And LLMs are really good at it.

I'd still recommend keeping it at a minimum though. Rather rely on tools like htmx.

Re:jQuery 4.1.0 by azangru on Wednesday November 18, 2026 @03:00AM (#50543192)
Why would a site that does not need a bloated js framework need jQuery? What is it that jQuery brings to the table that is worth paying for in terms of making it a dependency?
Re:jQuery 4.1.0 by franciscop on Tuesday November 17, 2026 @10:58PM (#50541704)
This is one of the first things I learned in programming. A friend back in University showed me a bit of his code (neither of us were in CS), and I was like why are you returning `this`? Then he showed me this chaining. I only found it a "cool trick" at the moment, who'd told me that I'd end up loving it the more I learned programming. I've made two of my main libraries, `umbrellajs` and a plumbing one called `swear` (chaining but for promises, some chaining syntax sugar on top of promises basically), based on this. I stopped doing it too much in recent years, but still it's amazing.
Re:jQuery 4.1.0 by pknerd on Wednesday November 18, 2026 @12:57AM (#50542392)
Who said it is not relevant? Many like me who abhor so called modern JS frameworks still use it along with bootstrap CSS
Re:jQuery 4.1.0 by dawnerd on Wednesday November 18, 2026 @03:09AM (#50543269)
It’s still probably the most distributed library. Every Wordpress site includes it.

I had to use it on a legacy site recently and forgot how nice it was and it all just came back to me too. Didn’t need docs either. That’s a sign of a very well designed lib

Re:jQuery 4.1.0 by jmathai on Wednesday November 18, 2026 @01:24AM (#50542533)
jQuery's API is the most elegant I've ever used. I haven't written jQuery in over a decade but I'm pretty sure this works.

$('#selector').html('new <strong>text</strong>').attr('foo', 'bar');