Live data from Hacker News

Do you know that there is an HTML tables API?

christianheilmann.com

181–190 of 206 posts

Re: Do you know that there is an HTML tables API?

#181
post #23

It is similar as with buttons ( https://news.ycombinator.com/item?id=45774182 ). Not sure when it was (10-15 years ago), but at some point everything became s. So, instead of semantic markup, HTML became a UI toolbox.

That's because the DOM is mostly used as a render target instead of a semantic document. I think semantic HTML is a great idea but it's kind of jaded to expect it at this point. It also doesn't help that semantic elements have styling. That right there gives people good reason to use a neutral container as a baseline. In fact I would go as far as to say that having both div and span is a bad design decision. They are…

The semantic web never took off because companies don't want to make their content easy to scrape.

Just look at how they salivate for WASM where everything is closed up and inaccessible, including a11y.

Re: Do you know that there is an HTML tables API?

#182
post #125

Earlier quoted context omitted.

Compared to what? What gives you all that, and what prevents you from having it with tables?

Javascript arrays have functions for all of that, so if you use something like React and renders your table from data arrays then it's all pretty trivial. I guess the point is that if you have to use JS to do those manipulations, then at some point it's going to be easier to just the React(/Vue/Svelte/etc) approach than manipulating the table yourself using the API described in the article.

Frameworks that make development easy are inherently inefficient. If performance is priority, then you better sort it yourself.

Re: Do you know that there is an HTML tables API?

#183
post #140

Earlier quoted context omitted.

And spans for creating links…

I recently discovered our frontend widget library draws an SVG to implement Radio instead of using . I was looking at it because they forgot to add a "disabled" attribute. Best case I'm hoping it's because they were required to get an exact design, but they really should have pushed back on that one if so.

Sounds like they either don't care about accessibility or like wasting money comprehensively reinventing things.

Re: Do you know that there is an HTML tables API?

#184
post #15

Interesting, but the JavaScript examples hurt: let table = [ ['one','two','three'], ['four','five','six'] ]; let b = document.body; let t = document.createElement('table'); b.appendChild(t); table.forEach((row,ri) => { let r = t.insertRow(ri); row.forEach((l,i) => { let c = r.insertCell(i); c.innerText = l; }) }); Use full words for variable names!

I was just about to comment the same. I’m sure people have a good reason for it (or at leafy _a_ reason), but single-letter variable names always struck me as optimizing for the wrong thing. As someone who likes to program in Haskell, I feel this pain very strongly. :)

It is also a math thing. most(if not all) constructions intended for mathematical consumption have some of the most miserable naming I have ever seen. I think it comes down to two things. when I am feeling less charitable it is that naming things is hard. so they don't bother. And when more charitable it is that they are optimizing for quick mental manipulation of a familiar machine. This tends toward the smallest variable names you can get away with, tons of implied context and compressed symbology. Of course this leaves the rest of us struggling, not with the concept but the way it is presented.

I like to joke, "you think programmers are bad at naming thing, you should see the mathematicians, programmers are infants before the infernal naming sense of the common mathematician".

Re: Do you know that there is an HTML tables API?

#185
post #104

Earlier quoted context omitted.

HTML tables are cognitively if not officially deprecated these days. I made my 1996 resume in HTML using a table for layout and it was indistinguishable from the Word version when printed. Made by editing the HTML by hand too! Tables are great. I don't doubt that CSS stuff is more capable, but the old ones are still useful.

I think the problem was that tables were always supposed to be for things that look like actual tables in the output - for that purpose they are not deprecated. What is discouraged is using tables as invisible layout grids - and that was their primary de-facto usecase before CSS and grid layouts. But that had always been a hack, even though a necessary one.

How was it a hack?

Hack implies brittleness. Using tables for layout was just fine for all but the most ideologically pure pedants.

Re: Do you know that there is an HTML tables API?

#186

Woah, it’s always weird to see how there’s modern web engineers that didn’t grow up during the era where entire layouts were built on tables. Not saying that it was good or bad, but just interesting.

I remember doing image maps, splitting large images up into pieces, placing them in table cells and adding links to each cell as a poor man's GUI

I did this with OCR text. The OCR software output bounding boxes which I converted into client side image maps. The company wanted to patent it.

Re: Do you know that there is an HTML tables API?

#187
post #144

This is a great reminder that the Eternal September still exists and perhaps mercifully appears to be affecting those with at least some technical exposure. https://en.wikipedia.org/wiki/Eternal_September

And the release of the iPhone created another, larger wave.

Re: Do you know that there is an HTML tables API?

#188

Earlier quoted context omitted.

How about displaying data in rows and columns, like records in a database? Or have you forgotten SQL, because you retrieve JSON from your 1000 NoSQL microservices?

Rows and columns are exactly what grid was added to CSS for.

I'd hate to hear that on a screen reader.

Re: Do you know that there is an HTML tables API?

#189
post #19

Earlier quoted context omitted.

Really? The variable name lengths? Not that the code is clearer as: const te = document.createElement('table'); document.body.appendChild(te); [ ['one', 'two', 'three'], ['four', 'five', 'six' ], ].forEach((r, i) => { const re = te.insertRow(i); r.forEach((c, j) => { re.insertCell(j).innerText = c; }) }); My personal stance on short variable names is that they are fine as long as their scope is very limited, which is…

This is not an improvement. Having named variables for things is good actually. They will need to be declared again immediately once you want to modify the code. insertCell(i).innerText = c is a nonsense statement, it should be 2 lines for the 2 operations

I disagree, but maybe it is a cultural thing for those of us that are more used to functional styles of programming? I was taught method chaining as a style by a seasoned JavaScript and Ruby programmer myself and I do not find the semantics confusing. "Create X with Y set to 17 and Z to 4711" can be either on one or three lines to me, as long as the method calls are clear and short enough.

As for variables, I (again personally) find it taxing to have many variables in scope, so I do net see their presence as a universal good. If we instead simply use expressions, then there is no need to concern yourself with whether the variable will come into play later on. Thus, I think it increases clarity and favour that over the ease of future modification argument you propose (heck, I would argue that you get better diffs even if you force the variable declaration into a future modification).

As for bikeshedding this piece of code further, if I steal some ideas from chrismorgan [1] and embedding-shape [2] who appear to be way more seasoned JavaScript programmers than me:

    const $t = document.createElement('table');
    for (const r of
            [
                ['one',  'two',  'three'],
                ['four', 'five', 'six'  ],
            ]) {
        const $r = $t.insertRow();
        for (const e of r)
            $r.insertCell().innerText = e;
    };
    document.body.append($t);
This is now rather minimal and the logic is easy (for me) to follow as the scopes are minimal and namespace uncluttered. It was a rather fun little exercise for a language I am not overly familiar with and I learned a few tricks and perspectives.

[1]: https://news.ycombinator.com/item?id=45782938

[2]: https://news.ycombinator.com/item?id=45781591

Re: Do you know that there is an HTML tables API?

#190

Earlier quoted context omitted.

That's because the DOM is mostly used as a render target instead of a semantic document. I think semantic HTML is a great idea but it's kind of jaded to expect it at this point. It also doesn't help that semantic elements have styling. That right there gives people good reason to use a neutral container as a baseline. In fact I would go as far as to say that having both div and span is a bad design decision. They are…

The semantic web never took off because companies don't want to make their content easy to scrape. Just look at how they salivate for WASM where everything is closed up and inaccessible, including a11y.

That is one reason. Another reason is everybody’s way of organizing content is different. There would need to be an infinite set of semantic tags to really make it work.
Post reply on HN