News for hackers. Stuff that matters.
Re:HTML is the Web by bo1024 on Wednesday June 26, 2019 @08:28AM (#20284247)
I'm inclined to disagree, but I guess the real problem is that webpages on the internet are being forced to serve both purposes.

Paradigm 1 - interconnected, hyperlinked web of text-and-content-based documents: open, accessible, amenable to indexing and tooling and so forth.

Paradigm 2 - delivery vehicle for cross-platform, full-featured, somewhat-security-sandboxed, applications.

I agree with the article that it's sad if Paradigm 1 is trampled to make way for Paradigm 2, just because (as you point out) we haven't been able to develop a viable alternative. In theory these could coexist, but the point of the article is people are being trained in Paradigm 2 and try to use it for purposes that are much more suited for Paradigm 1.

Just as sad, Paradigm 1 is more oriented around decentralization, giving power, options, and information to the user; Paradigm 2 is often exploited for lock-in, control over user's decisions, collecting information about the user, etc.

Re:HTML is the Web by _jwilde on Wednesday June 26, 2019 @02:18PM (#20287650)
I feel like this gives an overly rosy picture of the past—

The need to serve Paradigm 2 existed all over the place in the plain html days.

It’s just instead of having standards-based languages for Paradigm 2, we used to embed janky Flash SWFs and Java applets, were dependent on single vendors to patch zero-days in closed source code, and had to pay hundreds of dollars for licenses for developer tools.

Today’s Paradigm 2 now has multiple competing implementations, open standards, and powerful DOM inspectors in almost every web browser to tear apart any modern Paradigm 2 app you come across.

I think today’s Paradigm 2 gives more power to users than the Paradigm 2 of the past :)

Re:HTML is the Web by krisrm on Wednesday June 26, 2019 @02:32PM (#20287806)
Absolutely agree with this. The Internet-as-appplication-platform has never been better, from a developer's perspective.

From a user's perspective, it's maybe a bit more nuanced... I'm tired of websites trying to get around my adblocker, and everyone attempting to enable desktop notifications, for example. If I'm trying to read someone's document they've published, I'd like it to just be a document, thanks. But, increasingly, "Paradigm 2" webapps like Spotify and Google docs are as good or better than "rich" desktop apps.

Re:HTML is the Web by tracker1 on Wednesday June 26, 2019 @05:44PM (#20289527)
The "notifications" request REALLY pisses me off to no end. A simple "Subscribe" button (if the notifications API is present) would be enough to trigger the request. I wish I could just turn it off all around in the browser... Looking now... Nope, at least in chrome, cannot just disable the feature.

Also agreed, many web apps these days are as good or better than desktop. I actually have worked and am working on applications that replace their desktop counterparts. They're practically easier to scale, tend to have tooling to handle window sizes better, customization is easier and imho just nicer to write against. Better still if you don't have to support legacy browsers. Most browsers today are supporting modules and async import. Still using Webpack and Babel for JSX, but really close to a point where I'd just assume write for esm and have a server-side translation for JSX on demand (cached).

Re:HTML is the Web by bo1024 on Wednesday June 26, 2019 @02:58PM (#20288039)
Funny, I think you actually pinned that interpretation yourself - the post was meant to discuss use cases of the web today and doesn't mention the past at all! Regardless, I see your points, but I'd rather compare today to an idealized future and discuss how we'd prefer it to be.
Re:HTML is the Web by wildduck on Wednesday June 26, 2019 @12:16PM (#20286359)
Paradigm 1's security/privacy (WebRTC and webttorrent ip leaking, canvas finger printing) are being compromised in sake of striving for fancy stuff in Paradigm 2.

Browser vendors (Firefox, Chrome, Brave) please get your act together to prevent https://nothingprivate.ml

Re:HTML is the Web by MadWombat on Wednesday June 26, 2019 @06:11PM (#20289774)
For what its worth, I just tried this on Firefox 67.0.4 and it didn't work. It couldn't find the name I typed after I loaded from a private window.
Re:HTML is the Web by jamesmp98 on Thursday June 27, 2019 @09:10AM (#20294033)
It didn't work for my friend when done via Chrome on Android, and when I tried it, i got someone else's name in incognito
Re:HTML is the Web by dccoolgai on Wednesday June 26, 2019 @11:02AM (#20285662)
I think what the author is saying is that paradigm 2 is built _on top of_ paradigm 1 and if you can't do #1 right, then by definition _neither_ can be right. It's astounding the number of interview candidates who are super-fluent in JS but can't tell you to save their lives why it's a bad idea to put a click handler on a div. React will die (It's already started to) and we'll migrate back to the actual Web at some point and for my money it can't happen fast enough.
Re:HTML is the Web by hombre_fatal on Wednesday June 26, 2019 @11:23AM (#20285888)
> It's astounding the number of interview candidates who are super-fluent in JS but can't tell you to save their lives why it's a bad idea to put a click handler on a div.

Go on?

Re:HTML is the Web by paulhebert on Wednesday June 26, 2019 @11:59AM (#20286218)
Using a button here would be more appropriate for a few reasons:

Buttons by default have keyboard support for focusing and clicking. You’d have to manually add this to a div.

Screenreaders, scrapers, and other automated tools reading your html understand buttons and treat them differently from divs.

It’s easier for other devs to understand your code at a glance if clickable elements are buttons.

Re:HTML is the Web by snek on Wednesday June 26, 2019 @11:56AM (#20286191)
Putting a click element on a div is transparent to accessibility systems. And no, it isn't possible to consider an element with an onclick the same as a button, because events bubble, which means the element with the event listener isn't necessarily the element being watched for a click. IIRC there even used to be a "good practice" where people would attach a single click handler at the root and use it to dispatch events based on the `event.target` instead of attaching a separate handler to each target.
Re:HTML is the Web by dsego on Wednesday June 26, 2019 @07:40PM (#20290451)
React does that, they call it synthetic events, but it's hidden from the developer. In jQuery it used to be called event delegation, made it easy to handle events on dynamic elements without the need to constantly attach/detach handlers.
Re:HTML is the Web by dreamcompiler on Wednesday June 26, 2019 @11:58AM (#20286211)
Because the user can't hover over it and see where the link goes. Because the click handler represents a Javascript program that has to be downloaded. Because it can't be used with Javascript turned off -- which is increasingly necessary these days since ad networks abuse Javascript.

But mostly because it's usually unnecessary and smacks of laziness on the developer's part.

Re:HTML is the Web by saagarjha on Wednesday June 26, 2019 @11:51AM (#20286134)
Because you've literally just described what a <button> is.
Re:HTML is the Web by felxh on Wednesday June 26, 2019 @01:49PM (#20287338)
That would mean that anything that responds to click events is a button. From your experience of using UIs, you can probably think of many more UI elements that respond to clicks and are not buttons
Re:HTML is the Web by frenchyatwork on Wednesday June 26, 2019 @11:12AM (#20285776)
> React will die

Hopefully, but people have a large capacity to deal with broken web software. Back when I was young, it was all the Java & .Net websites that turned every friggin link into a POST form so that navigating back, and opening in a new window was completely broken.

Re:HTML is the Web by antibland on Wednesday June 26, 2019 @12:55PM (#20286800)
> React will die (It's already started to)

I read a lot of articles about front end, including framework & library trends, usage statistics, rumors, etc., though I've never heard that React has begun to die. Can you provide a citation?

Re:HTML is the Web by robertoandred on Wednesday June 26, 2019 @12:52PM (#20286768)
Nothing about React stops you from correctly putting click handlers on buttons.
Re:HTML is the Web by tracker1 on Wednesday June 26, 2019 @06:06PM (#20289734)
Well, the behavior is a bit awkward, and older browsers don't even work right. Of course, some older browsers that shall not be named, you couldn't disable certain styling attributes of buttons, which means an anchor may have been more appropriate back then.

I tend to prefer semantic tags most of the time. I do wish there was a CSS declaration, or maybe an <html> attribute to start off with absolutely NO styling, so that it all comes up from what's in the CSS only. Various resets suck or don't work well, or are really big for various reasons. For that matter, being able to reset everything under a given element that way so that in-browser rules aren't applied would be really nice for WebComponents.

My own weakest point is probably on CSS these days, I just haven't really kept up since 2.x as I haven't really needed to, and can usually google when I need more. I feel the flexbox stuff is more complex than it should be.

Re:HTML is the Web by stellar678 on Wednesday June 26, 2019 @11:27AM (#20285932)
I’ll bite: Why is it bad to put a click handler on a div? Because we’re losing the semantic content of the markup?
Re:HTML is the Web by citrablue on Wednesday June 26, 2019 @12:34PM (#20286583)
Because there's already an element for that. Putting a click handler on a div is a hack.

In a clean (from scratch) dev situation, when would it make sense to use the div option?

Re:HTML is the Web by mattwad on Wednesday June 26, 2019 @03:47PM (#20288446)
People have been putting event listeners on div long before any framework was around. Tons of libraries and documentation show how to attach a click handler to a div (ex: https://api.jquery.com/click/). I can think of some cases... maybe the div is contenteditable and I want to trigger some analytics. Maybe I want to listen to all the children of a container rather than apply expensive listeners all over. Do you put button tags around all your tooltips? You might end up making your HTML look right, but now you are jumping through hoops to make it not look like a button. As with all things, it's naive to say "never do something."
Re:HTML is the Web by cortesoft on Wednesday June 26, 2019 @11:56AM (#20286195)
For one, it won't play nice with accessibility helpers... screen readers, keyboard interaction, etc.
Re:HTML is the Web by giobox on Wednesday June 26, 2019 @12:17PM (#20286373)
While I agree semantically use of <button> can be clearer, clickable divs can still play largely fine with most accessibility technologies if ARIA attributes are used.

Does it semantically make the most sense? Not necessarily, but it isn't a blocker to most accessibility tools and use and support for ARIA attributes is pretty widespread nowadays, including all of the major browsers and screen readers.

> https://developers.google.com/web/fundamentals/accessibility...

> https://developer.mozilla.org/en-US/docs/Web/Accessibility/A...

Re:HTML is the Web by ricardobeat on Wednesday June 26, 2019 @12:46PM (#20286709)
Number of times I remember seeing an an app using `<div onclick>` with proper aria attributes: 0.
Re:HTML is the Web by giobox on Wednesday June 26, 2019 @01:11PM (#20286959)
It's often a legal or contractual requirement when selling software to public bodies in many countries, so I've seen it used a lot. Mileage may vary in other markets.

The important point is that fundamentally using a <div> in place of <button> can still be made to work easily with these accessibility tools - many comments here imply it can't be done at all and only a button will work. Does it semantically make sense? Likely no, but it isn't a hard blocker on accessibility.

Re:HTML is the Web by mosdl on Wednesday June 26, 2019 @01:23PM (#20287065)
Reinventing the wheel is bad
Re:HTML is the Web by rthomas6 on Wednesday June 26, 2019 @09:34AM (#20284828)
Don't we kind of have Paradigm 2 on our smartphones and tablets? It's not perfect but it's something.
Re:HTML is the Web by bo1024 on Wednesday June 26, 2019 @02:53PM (#20287995)
I agree it's better in some ways than the desktop programs ("apps") situation
Re:HTML is the Web by EGreg on Wednesday June 26, 2019 @10:20AM (#20285237)
We should replace DNS with DHT, then we can have content addressable (or otherwise verified) apps sideloaded or loaded in chunks from anywhere like in BitTorrent or Dat.

To me, the Browser is the most widely distributed sandbox runtime ever! It’s just missing a few crucial things we plan to add soon :-)

Re:HTML is the Web by JBiserkov on Wednesday June 26, 2019 @11:02AM (#20285667)
Have you seen https://github.com/staltz/dat-installer ?

It can be used to update itself, too :-)