Most active commenters
  • eru(4)

←back to thread

An SVG is all you need

(jon.recoil.org)
281 points sadiq | 11 comments | | HN request time: 0.265s | source | bottom
1. tylervigen ◴[] No.46240126[source]
Two years ago I re-vamped my "Spurious Correlations" side project, which is mostly just a bunch of charts. However, I couldn't find a charting software I liked that would display clean, simple visuals with the constraints I wanted. (I had used pCharts and HighCharts in the past, but didn't like charting in Javascript or PHP.)

I decided to "roll my own" and write Python scripts that outputted SVG markup. I was worried this would go about as well as every other "roll your own" project does, but was pleasantly surprised. It is surprisingly easy to output reliable, good-looking SVG graphics using Python. If you are making a chart, everything is just math.

The infinite scalability is almost just a happy upside to the simplicity of creating the visualizations, which is annoying in raster format. It made me like SVG even more.

replies(3): >>46240143 #>>46240416 #>>46240918 #
2. eru ◴[] No.46240143[source]
It's a bit sad that Postscript never caught on as much as it could have. In an alternate timeline, it could have been the HTML (and SVG) we got in ours.
replies(1): >>46240200 #
3. shakna ◴[] No.46240200[source]
Postscript is still everywhere. Its just out of sight, being used as a compile target.

PDF may have "officially" replaced it, but it is still embedded almost everywhere you look.

replies(1): >>46240253 #
4. eru ◴[] No.46240253{3}[source]
PDF is a sad replacement for PS. As far as I can tell, it was an attempt to obscure PS, because alternative vendors were getting better as Postscript than the originators.

(There was some justification in terms of 'Oh, a binary format like PDF is more space efficient.' But PDF never really was more efficient than compressed PS.)

It's not that PS has vanished, but PS isn't nearly as 'everywhere' as HTML came to be.

replies(2): >>46240658 #>>46240844 #
5. leephillips ◴[] No.46240416[source]
Thanks for making that website. I used examples from it in the first day of my statistics course ("by the end of this course you won't make these kinds of mistakes").
replies(1): >>46243946 #
6. tambourine_man ◴[] No.46240658{4}[source]
PDF is also a lot less powerful, purposefully so. You can start an infinite loop just by double-clicking a PS file, for instance.

It is extremely useful to have a full programing language as a file format, though.

I miss macOS’s Preview.app auto-converting PS to PDF when double-clicked. It was a way to easily distribute a document that could randomize question orders each time it opened, print multiple bingo cards from a single file, etc.

The stack-based and reverse Polish notation thing was also fun.

replies(1): >>46242021 #
7. f30e3dfed1c9 ◴[] No.46240844{4}[source]
From the perspective of someone who worked in printing and publishing starting in the 1980s, there's more to it than that. PostScript was and is terrific as a page description language and as a printer control language. It absolutely revolutionized the printing business. For the first time, you could get complete pages (as opposed to unpaginated galleys) out of high-end imagesetters.

But it was not all that good as a way to send documents to be printed elsewhere. Postscript files were in some ways too dependent on the printer they targeted, so the person creating the PS file had to know too much about the printer that would be used to print it: its resolution and optimal halftone screen frequencies, media sizes, etc. With high-resolution output on photographic film costing around $10 per foot, mistakes could be expensive as well as time-wasting.

Fonts could also be a problem. Ideally, the PS file would contain all the fonts it required but this did not fit very well with the terms of most font licenses. And some applications would include a copy of every font used once on each page on which it was used. This was in line with Adobe's recommended Document Structuring Conventions and had the advantage of making pages within the file independent of one another, but for documents with hundreds of pages, this could add up fast and make the PS file literally hundreds of times larger than if all the fonts were included just once. With small storage media and slow network links, this was a real problem.

The "P" in PDF is for portable, and these are the problems it solved. Unlike a PS file, a PDF file is not targeted for a specific printer model, and most font licenses allowed the licensee to include subsetted fonts in PDF files. I personally prepared PS files for a few thousand books to be printed at various places around the US and later, PDF files for thousands more. There is no comparison: PDF was and is better in every way for this purpose.

replies(1): >>46242010 #
8. crabmusket ◴[] No.46240918[source]
If anyone is looking for a clean JS charting framework, I highly recommend Observable Plot.

It's from the creator of D3 and it's much easier than using raw D3. I've been using it outside the Observable platform for debug charts and notebooks, and I find its output crisp and its API very usable.

It doesn't try to have all the bells and whistles, and I'm not even sure if it has animations. But for the kind of charts you see in papers and notebooks I think it covers a lot.

9. eru ◴[] No.46242010{5}[source]
I agree that postscript was far from perfect.

However we can imagine a world where some relatively minor evolutions in PS would have moved it into the right trajectory.

(Thanks for all the historic details!)

10. eru ◴[] No.46242021{5}[source]
You could have made a deliberately restricted subset of PS without going all binary.

Btw, doesn't PDF include Javascript these days? So you can still randomise stuff at view-time in a PDF. See https://th0mas.nl/2025/01/12/tetris-in-a-pdf/

11. tylervigen ◴[] No.46243946[source]
Glad to hear it! The use in stats courses is the main reason I keep it alive.