Live data from Hacker News

jQuery v4.0 Beta

blog.jquery.com

261–270 of 404 posts

Re: jQuery v4.0 Beta

#261
post #224

Earlier quoted context omitted.

> DOM APIs are entirely functional. (Almost) none of the DOM APIs are functional. They are literally `object.methodCall()`

Yes, functional programming can have methods. Methods are functions. OOP is all about polyinstantiation and inheritance. Functional programming is all about functions and input/output, which is entirely what happens in this case. The only OOP here is the method assignment you don’t see: Element.prototype.getElementById = function () {};

You're making no sense. Functional programming is more than just "about functions".

DOM APIs are the embodiment of 90s-era OOP. There's literally nothing functional about them. All [1] "functions" are methods defined on very specific objects. You can't even get a proper reference to them without binding them to specific object instances

What exactly is functional about this?

  const newDiv = document.createElement("div");
  const newContent = document.createTextNode("Hello, world");
  newDiv.appendChild(newContent);
  const currentDiv = document.getElementById("div1");
  document.body.insertBefore(newDiv, currentDiv);

Okay, here's an easier question. What will happen here, and why?

   const function_reference = document.getElementById;
   function_reference("#id");

[1] Technically speaking, not all all. The more recent `fetch` is probably the only piece of browser APIs that can be called functional for some very limited definition of functional

Most (all?) other "global" functions are defined on the instance of the window object: getComputedStyle, getSelection etc.

Re: jQuery v4.0 Beta

#262

Earlier quoted context omitted.

Nah, not simpler, nextjs is simpler then php to start working with. Also running & deploying nowadays is easier. PHP used to be easiest, but fell behind.

This very much depends on what you are building and how experienced you are. If you just want a few pages, no need for background workers or database migrations, PHP is still the king. You download one of many single-executable LAMP servers, and start writing your index.php. Deploy? Just copy files to server. Zero downtime deploy? Copy files to server and use symlink to atomically switch versions. Dependencies? Compo…

Opinion: If more product teams had one person high up who felt embarrassed by even one of the things in your third paragraph we'd have significantly better tech.

Re: jQuery v4.0 Beta

#263
post #191

Earlier quoted context omitted.

> I much prefer to have HTML with some JS sprinkled That's not what vue templates are. It's three or four different templating DSLs in one. v-for alone will show that it's not HTML with Javascript: https://news.ycombinator.com/item?id=28059397 And there's more: https://news.ycombinator.com/item?id=19199423

> That's not what vue templates are. It's three or four different templating DSLs in one. The pattern is very obvious? If array: (value, index)=>void If object: (value, key, index)=>void If it's an array, it's the call signature for the args of the forEach method, i.e. (value, index)=>void, but can be assigned a function that's just (value)=>void if index is unneeded. If it's an object, it's an extension of the same…

> The pattern is very obvious?

It's not

> It's not 4 dsls in one, anymore than jsx

I "like" that when discussing these things everyone completely ignores everything, and focuses on one specific thing.

So, again. The claim was that Vue templates is "HTML + Javascript"

1. As v-for clearly shows it's not even close to Javascript, as there are no Javascript constructs that correspond to this

2. As everything else, not just v-for shows, it's neither HTML (so many custom attributes with extensions and shorcuts etc.) nor Javascript.

Re: jQuery v4.0 Beta

#264

For those of you who are curious what drives jQuery in 2024 and beyond, you need to remember that WordPress is still more than 1/3 of the web, and the majority of installations and so many plugins critically rely on jQuery. Yes, seriously. Any advances to removing deprecated APIs or functions are great. jQuery will probably be around dominantly on the web for years to come.

Also, jQuery is awesome. People have been in love with the overly complex and fancy javascript frameworks for the last 15 years or so. But jQuery doing dynamic binding to dynamically generated forms for some error states and maybe an ajax calls is literally all the javascript you need in 99% of web pages and the rest is overkill. The industry is going to move away from the complexities to React and towards more of th…

I’ve been writing JavaScript for 15 years professionally, and I must say this comment seems to be made by someone not as familiar with the context here. Moving away from React and frameworks like it would require a radical rethinking of what we expect to do with web apps. Building something like google maps, google docs, figma, are definitely doable with some of these tools, but it is almost impossible to maintain. This comment truly ignore the context of why frameworks like react took off. Jquery is great if you need a slideshow on a page, and maybe just some tracking, and even then, I’ve recently opted to just use vanilla js, with things like webpack build targeting whatever versions I would need. JavaScript programming is complex because making great ux can be a non trivial task.

Please excuse any typos, written on the phone

Re: jQuery v4.0 Beta

#265
post #261

Earlier quoted context omitted.

Yes, functional programming can have methods. Methods are functions. OOP is all about polyinstantiation and inheritance. Functional programming is all about functions and input/output, which is entirely what happens in this case. The only OOP here is the method assignment you don’t see: Element.prototype.getElementById = function () {};

You're making no sense. Functional programming is more than just "about functions". DOM APIs are the embodiment of 90s-era OOP. There's literally nothing functional about them. All [1] "functions" are methods defined on very specific objects. You can't even get a proper reference to them without binding them to specific object instances What exactly is functional about this? const newDiv = document.createElement("div…

> What exactly is functional about this?

A series of function calls that each do something and each returns a value.

> Okay, here's an easier question. What will happen here, and why?

A function call that does something and returns a value, because in this language complex types are passed by reference.

Re: jQuery v4.0 Beta

#266
post #81

Earlier quoted context omitted.

>But jQuery doing dynamic binding to dynamically generated forms Do you have an example of that?

Hold my beer! https://alive22-dev.turnaroundhealth.com/static/javascript/q...

More that one line, doesn't count! =D

Re: jQuery v4.0 Beta

#267
post #261

Earlier quoted context omitted.

You're making no sense. Functional programming is more than just "about functions". DOM APIs are the embodiment of 90s-era OOP. There's literally nothing functional about them. All [1] "functions" are methods defined on very specific objects. You can't even get a proper reference to them without binding them to specific object instances What exactly is functional about this? const newDiv = document.createElement("div…

> What exactly is functional about this? A series of function calls that each do something and each returns a value. > Okay, here's an easier question. What will happen here, and why? A function call that does something and returns a value, because in this language complex types are passed by reference.

> A series of function calls that each do something and each returns a value.

Doesn't make it functional

> A function call that does something and returns a value,

Ah, so you don't know.

Here's what will actually happen:

      TypeError: Can only call Document.getElementById on instances of Document
Because it's a method on an object. And you have to bind that method to a specific object instance before you can call it.

If it was functional this would never be the case. But since this is 90s-era OOP, you have to do this:

      const function_reference = document.getElementById.bind(document);
      function_reference("#id");

Re: jQuery v4.0 Beta

#268
post #247

Earlier quoted context omitted.

Absolutely yes. jQuery selector engine was developed before the official Selector API, which ended up being almost exactly the same. Except for a few exceptions which John wasn't too sure about when they asked for feedback: https://johnresig.com/blog/thoughts-on-queryselectorall/

I don't know what you think that link shows (I don't know what John thought it showed, either—it's a classic "talking to one's own head, instead of who you're trying to communicate with" situation, and David Baron's confusion on the mailing list at the time is understandable). To reiterate: > The argument for querySelector / querySelectorAll calls is literally mimicked from John Resig's grounbreaking API design No, i…

So you couldn't get away with lazy and ignorant two word answer and it forced you to write quality one :)

One would argue whether we'd have querySelector if jQuery wasn't as popular. We may have an inspiration chain here... but thanks for pointing out to prior art.

Re: jQuery v4.0 Beta

#269
post #254
post #134

Earlier quoted context omitted.

Instead of needing to import leftpad you have the missing standard js lib

It isn't missing. Javascript was created to serve a specific purpose, which didn't include left-padding text in a terminal. Most language I'm aware of wouldn't have that in their standard lib. If you want Javascript to act as a drop-in replacement for C++ or Java or some other general programming language (which Javascript was never intended to be) don't act as if needing to write libraries to cover that missing func…

> Most language I'm aware of wouldn't have that in their standard lib.

Python has str.ljust [1] (and str.rjust [2]):

> Return the string left justified in a string of length width. Padding is done using the specified fillchar (default is an ASCII space). The original string is returned if width is less than or equal to len(s).

[1] https://docs.python.org/3/library/stdtypes.html#str.ljust

[2] https://docs.python.org/3/library/stdtypes.html#str.rjust

Re: jQuery v4.0 Beta

#270

For those of you who are curious what drives jQuery in 2024 and beyond, you need to remember that WordPress is still more than 1/3 of the web, and the majority of installations and so many plugins critically rely on jQuery. Yes, seriously. Any advances to removing deprecated APIs or functions are great. jQuery will probably be around dominantly on the web for years to come.

I don't care what anyone says, jQuery still rocks and is so damn important and influential. You remove jQuery from every piece of software a good chunk of the all the websites stop working all around the Internet.

I'm not saying jQuery isn't great, but being entrenched and being great are two different things. It's not really saying anything to say things would break if you remove it.

The thing is for a certain time, jQuery was almost seen as inseparable from JS itself. Like the Python standard library is to Python. You can still find StackOverflow questions today asking to do something in JS and the answer is jQuery, and not just "here's how to do it in jQuery", just "here's what you asked for". That means it certainly got used in a lot of places where it wasn't really necessary.

The backlash against it, though, is just your typical pendulum swing that seems so much an unfortunate part of human nature. It's like when CSS was in and table-based layouts were out. I saw developers trying to use CSS to render tables. Nuance is hard and people can't help going to extremes. jQuery is probably still a really useful tool. I've seen some jQuery expressions that are far more elegant and beautiful then a plain JS equivalent. Whether this matters for any particular project is completely up to you. I don't like the way it encourages tons of ad hoc JS snippets all over the place, but that's a fault of developers, not jQuery.

Post reply on HN