618 points · by ducktective · 4y ago · 208 comments
(Around 7-8 minute mark)
Update:
At 24-25 minute mark, he talks about the technologies he is inquiring to write his new book with (he mentions troff and groff).
He says he wanted to try "XeTeX" (which supports Unicode) but "...I was going to download it as an experiment and they wanted 5 gigabytes and 5 gigabytes at the particular boonies place I'm living would...mmm..not be finished yet!"
So there we go...We had the opportunity to read the mind of the developer of awk and unix and co-author of the literal "C Programming Language", confronting with the absolute state of the tooling of the modern world.
A full install means installing ~4000 packages, including their source files (tens of thousands of tex files) and built documentation (thousands of PDF files) and hundreds of free fonts (otfs, ttfs, texs own format).
This is huge (>7GB, not just the 5 GB claimed here).
However, you don't need 99 % of this for any given document.
Not installing the source files and documentation PDFs will alone reduce the size by roughly half.
Only installing the packages you really need from a minimal installation gives you a few hundred megabytes at most for even complex documents.
It's a bit annoying to get the list of packages needed though, since there is not really any working dependency management.
I wrote a python wrapper around the tex live installer [1] to make this easy for CI jobs, see e.g. [2].
On a side note: I'd recommend luatex over xetex.
- [1] https://github.com/maxnoe/texlive-batch-installation/
- [2] https://github.com/pep-dortmund/toolbox-workshop/blob/8b00f0...
It’s mostly a death by a thousand cuts thing.
MikTeX, which is available for Mac and Linux as well as Windows will do on-demand downloading of packages and is probably my recommendation for a new installation.
A lot of the drawbacks to TeX stem from to trying to meet the combined requirements of computing platforms of the 1970s–1990s. All input files effectively live in a single namespace so you cannot have two input files with the same name (the same applies to coding where you have a single namespace for all your commands as well).
I recall I managed to cut MiKTeX down to about 12MB. Never heard a single complaint about it.
Sounds like someone should just create a wrapper that catches file opens of uninstalled dependencies and automatically downloads them on the fly.
Hah, TeX Live is... not that.
It's been enormous since I installed it off a CD in the 90s. The idea, and it works, is that you can just compile anyone's stuff out of the TeX ecosystem.
There is just... a lot... in it. You don't need a package manager if you install the whole universe locally. Like I said: not what I would call a modern approach to tooling.
On the other hand, I have latex files from the mid-Noughties and, I don't even need to check: they'll compile if I want them to.
But yeah, if you want just a little piece of TeX here and there, you're off the beaten track. That's not how TUG rolls.
More modern approach: "hey, we have a lot of disk space, we can install everything locally".
Even more modern approach: "hey, we have fast Internet access, we only have to install stuff when we need it".
It also seems quite slow to update, and a recent (?) name change of `tools' to `latex-tools' seems to have broken multicol, which drove me to MikTeX. Internet connection required, but far less headache.
Man, I think once you're Kernighan there should be like a 1gigabit/sec symmetric circuit wherever you go just in case you use it to do something else useful.
Besides, where would you put the bar for “distinguished”? Who would take the decision?
It’s just that the distros also include oodles of (plain text!) macro packages for everything under the sun. There are some legitimately large things such as fonts, but generally speaking a full TeXLive or MiKTeX distribution is bloat by ten thousand 100-kilobyte files, like a Python distribution with the whole of PyPI included.
If you know what you want, you can probably fit a comprehensive LaTeX workbench in under 50M, but it takes an inordinate amount of time.
He can try "Tectonic" [0] - a modern XeTeX based TeX/LaTeX distribution that installs a minimum system and then downloads and installs dependencies on-demand. Tectonic is written in C and Rust [1].
[1] https://github.com/tectonic-typesetting/tectonic/issues/459
"MacTeX installs TeX Live, which contains TeX, LaTeX, AMS-TeX, and virtually every TeX-related style file and font. [...] MacTeX also installs the GUI programs TeXShop, LaTeXiT, TeX Live Utility, and BibDesk. MacTeX installs Ghostscript, an open source version of Postscript."
Which is, as you say, considerably more than just "XeTeX".
(Also those are universal binaries containing both Intel and ARM versions which probably adds some heft.)
Heh, I remember when "universal binaries" meant "PowerPC and Intel". Different universes ….
I wonder what distro or editor he is using...
I remember installing teTeX (the predecessor of TeX Live) back in 2003 and I despaired at the file size because I knew it would take days to download on the shitty dialup connection I had at the time. Yeah, it wasn't 5 GB big back then, but it was certainly big by 2003 standards.
Well, I've been using groff on and off for a few years, I can give it a shot. Most "macros" as in TeX, are invoked by having the first character of a line be a `.` and then as in TeX, refer to a name. Now, macros in groff are weird. Macros are not delimited by `{}` delimiters as in TeX, but either by having an environment block like so:
.TS
.TE
Incidentally, `.TS` and `.TE` is the environment for tbl(1), the pre-processor for tables.
Or by invoking another macro, as in this example for headings and paragraphs
in the -ms macro set. (The -ms macro set is called as such because that's how you get it into
your document, you supply the -ms flag at build time to groff to get the -ms macros).
See groff_ms(7) for more information than I will supply here. .NH 1
Some heading here
.PP
Start of a paragraph.
Sometimes you want to start a line of input with a period.
To do that you just use the character '\&' before the period.
The `\&` character is a non printing character, so use it anywhere you want, really.
I imagine you want to play with math typography, in that case there is EQN.
EQN works by having an environment block, `.EQ` and `.EN` and in that block
you type in the EQN mini-language. .EQ
f ( x ) ~=~ x sup {2} - 1
.EN
EQN does not care about precedence or anything, so use `{}` to delimit expressions.
I think there is some kind of EQN document rescued from Bell Labs that tells
you about how the language works. Check troff.org for it, or email the mailing
list for groff, which is also pretty good for newbie questions, it is not really
all that high traffic.Groff also does pictures, so you can for example create a box with some text in it (it is capable of more, like strokes, macros, color, and I believe rotation[not sure]). To start a picture, `.PS` and `.PE` will do so, and again, a small language as input in that block.
Now, to print anything you should know the design of the original troff system was heavily based on the UNIX philosophy, which means the output you get from running the groff program prints the output to stdout. Just redirect the output to a file to get a PDF or a PS document.
Obviously, there is much I have not covered in this comment, such as macros, registers, and other exciting topics such as refer(1), but this should give you a quick start.
I didn't know about '\&' as a way to "short circuit" groff from interpreting something as a macro that should be literal (such as a line-initial period). That's great to know.
I've found a couple of resources that have been helpful. Mostly, I've been referring to this[0] page on gnu.org. I've also learned from this[1] article on Linux journal and Luke Smith's YouTube playlist[2] on groff.
To practice, I'm trying to re-typeset a paper I wrote in school that follows the Chicago Manual of Style[3]. I formatted the original in MS Word using a template my school provided, so I have something to visually compare against. I'm using the -ms macro set, mostly because that's what Luke Smith demos in his videos so that's what I got started with.
I've already got a reasonable imitation of the original document, which is fun and a bit rewarding. But there's a couple of very small details that I'm finding difficult to crack. Are you very well-versed with -ms? In particular, right now I'm trying to figure out how to add one blank line of space in footnotes AFTER the horizontal line, but BEFORE the first footnote begins. I suspect I'll need to redefine the -ms macro that controls the trap for footnotes...? But I haven't figured out which macro that is just yet.
[0] "The GNU Troff Manual", https://www.gnu.org/software/groff/manual/groff.html
[1] "Typesetting with groff Macros", https://www.linuxjournal.com/article/4375
[2] "groff/troff for Minimalist Document Complication", https://www.youtube.com/playlist?list=PL-p5XmQHB_JRe2YeaMjPT...
[3] "The Chicago Manual of Style Online", https://www.chicagomanualofstyle.org/home.html
I'm struggling to understand this sentence. Who are they? What's a boonie? What's not finished?
My answer to "how long do I want my career to be?" will never be "until my body or mind fail me".
Now, Brian obviously has much better instincts about performance than I do and may even have tried some things and benchmarked them, but my guess would have been that you should stay in UTF-8 because it's always faster for the typical cases.
A complete guess on my part though, I never looked into AWK's source code.
Similar with substr() and other string functions, which when operating as bytes are O(1), but become O(N) when trying to count the number of codepoints as UTF-8.
GNU Gawk has a fancier approach, which stores strings as UTF-8 as long as it can, but converts to UTF-32 if it needs to (eg: the string is non-ASCII and you call substr).
It looks like Brian Kernighan's code has the same issue with length() and substr(). I'm going to try to email him about this, as I think it's kind of a performance blocker.
That's not actually useful, because unicode itself is a variable length encoding.
So it mostly blows up the size of your data.
Though it might have been selected for implementation simplicity and / or backwards compatibility (e.g. same reason why Python did it, then had to invent "flexible string representation" because strings had become way too big to be acceptable).
[1] At least when talking about code points, which is what matters for regular expressions (unless you want stuff like \X with is not universally supported).
I think these days people don't bother with UTF-32 too much because it's not even like you have a clean "one 32bit int, one character" relation anyway since some characters can be built from multiple codepoints. Since generally most code manipulating character strings are interested in characters and not codepoints, UTF-32 is effectively a variable-length encoding too...
90% Only care about ASCII, thus individual bytes in UTF-8, and so UTF-32 just wastes memory
1% Care about individual code points, but spread over multiple bytes (e.g. the double dagger ‡), UTF-32 is perfect
9% Care about multiple code points (to form e.g. a Flag, or é written in combining form, or two women kissing) and so UTF-32 doesn't really help again
Edit: Mixed up code units and code points.
Unicode in UTF-8 will have variable char length. Plain ASCII will be one byte for each char, but others might have up to 4 bytes. Anything dealing with it will have to be aware of leading bytes.
UTF-32 in other hand will encode all chars, even plain ASCII ones, using 4 bytes.
Take the "length of a string" function, for example. Porting that from ASCII to UTF-32 is just dividing the length in bytes by 4. For UTF-8, you'd have to iterate over each character and figure out if there is a combination of bytes that collapse into a single character.
You have to do that with UTF-32 as well. Yes, every codepoint is 32 bits, but every character can be made up of one or more codepoints.
Why else might you need to know the length? If it's to know how much space to allocate in a GUI (or even on a console) then neither encoding is going to help.
Maybe it's because of some arbitrary limitation like "your name must be less than 50 characters" and I'll just say that if that's the case, you are doing it wrong (if you need to limit it for storage/efficiency purposes, fine, but you will probably be better off limiting by bytes and using UTF-8 since most people will be able to squeeze in more of their names).
I'm not saying there aren't reasons for needing to know the "length" (number of Code Points) of a string, and certainly many existing algorithms are written in a way that they assume that calculating string length and being able index arbitrarily into the middle of a string are fast (O( 1 ) for indexing) but in reality, for almost any real world problem beyond "how much storage do I need" almost everything you need to do actually requires iterating over a string one Code Point at a time (which is O( n ) for both, with the biggest difference being that UTF-8 may require more branching, but also it's common enough that in many cases between vectorization and just generally better optimizations because of it's popularity, UTF-8 will do just fine while usually using less storage, which can significantly benefit CPU cache locality).
It is surely better than dealing with UTF-16 "surrogate pairs"[2] in most pre-UTF-8 tech where a `char` is 16-bits but can't fit all Unicode codepoints without another 16-bit `char`.
[1]: https://doc.rust-lang.org/std/primitive.char.html#representa...
But as an internal representation, some of it can be ignored by choice.
$ awk -V
awk version 20211208
Kernighan's version is likely used in other places where the GPL is eschewed. $ awk -version
awk version 20200816 # awk -version
awk version 20210215 $ echo 'ö' | awk '{print length}'I have only worked with one person really who knew is backwards and forwards. That seemed helpful at first until he used his deep knowledge to try some sort of tricky fix-up and in the process lost some of my work. Given that a version control system's one job is to not lose work, I was very disappointed.
Not confined to your local machine?
He was very apologetic about it, and it wasn't more than a day or two of work, so I was ok with it. But it was one of many experiences that have left me permanently suspicious of doing anything fancy with git. Which is fine, because for a lot of reasons mostly not to do with any particular VCS, I work to keep branching to an absolute minimum.
When I took my undergrad roughly a decade ago, github was already a thing but our courses were still using subversion.
Academia is slow to adopt new tools.
Whether it’s git or vi/emacs or C or LaTex or whatever, there are a bunch of us old-timers who went through the pain already and now notice the modest loss of capability on hg or VSCode or whatever.
But even as such an old-timer, I don’t think it’s a good idea to default everyone into this low-level shit. Mercurial and VSCode and Python are fine, you can do great work without “the bare metal”.
Edit: Clarified that it’s a “revision control” power-user tool, plenty of “power users” have more typical revision-control needs.
I’ve always found git to be exceedingly simple in design. Though, the CLI is a quite messy I grant you.
I haven't used it, but my understanding was all the unix tools were upgraded to work with unicode - don't quite see why it's taken so long if the work was done already years ago
I've always found that for my personal use cases, writing a little Python snippet has always been much faster and simpler than understanding what CLI tool to use, and how to use it, to achieve the same thing.
I've had to work on environments where awk was available by default, but Python was not (and was not going to be).
It can be good to have a screwdriver for every type of screw in the toolbox.
https://github.com/onetrueawk/awk/compare/master...unicode-s...
Long live, K!
Following the spirit of UNIX, I did a little analysis on the upvotes this post got over time (fish-shell):
while true; curl -sL 'https://news.ycombinator.com/item?id=32534173' | pup '#score_32534173 text{}' | awk -F'[^0-9]*' '{print $1}' | tee -a points; sleep 15s; end
(Initially I used `grep -Po '\d+'` but switched it with an awk solution due to...context!)I started it approx. when I posted it. Now ~2 hours have passed since. Using `gnuplot`:
f(x) = a*x+b; fit f(x) "points" via a,b; set terminal png size 1920,1080 enhanced font "Inconsolata,20" ;set output "HN-analysis.png" ;set grid; set ylabel "points";set key bottom right ; set xlabel "sample # (15s interval)"; plot 'points' w linesp lt 7 lw 3 lc rgb "orange", f(x) lc rgb 'blue' lw 2
We generate the plot: https://i.imgur.com/pS6AaI5.png(The jump #100 sample is due to a network error on my side)
And here are the coeffs. of a linear fit over the data (note that every 4 samples is 1 minute, so this post got ~1.52 upvotes per minute)
a = 0.380809, b = 19.8437( For bonus fun, fit successive unbiased moving averages of a selectable width, for further fun do this for non uniform sample times .. time weighted, and look beyond simple moving averages to (say) Savitzky–Golay filter family for both uniform and non uniform sampling intervals )
Are you suggesting another method for graphing?
gnuplot was/is Berkley / GNU developed software.
Guess more of a 70's/80's pre-open source observational comment.
Even Kernighan struggles with git.
Pull requests are feature of GitHub, not a part of git.
https://docs.github.com/en/pull-requests/collaborating-with-...
Git has tooling to help with those, so it kinda is a git feature: git request-pull. https://git-scm.com/docs/git-request-pull
I guess it might be more accurate for me to think about pull requests as Github's reification of the social protocol of pulling among kernel developers.
Figuring out how all of this works is substantially more difficult I find in practice than fixing many longstanding trivial bugs in a great deal of software.
Some good reasons not to use GitHub is because you’re familiar with standard/traditional tools, or because you prefer not to use centralized services. Both of those are fine reasons! But “the traditional way is easier” isn’t.
They just said, "The culture around p.r.s is truly a high barrier of entry for many people." That's true and it's important to acknowledge that on any project that wants contributions from as many people as possible. When I was at Code for America I saw smart people putting plenty of time into helping people get over that barrier.
That's certainly the case here. If a professor of CS receives help from an open-source maintainer who's been coding for decades and still doesn't feel confident, then it's safe to say a) there's room for improvement, and b) until we figure out what the improvement is, we should make sure that we're providing the necessary support to everybody we want to contribute.
The fact that (for example) GitHub requires a fork for you to send a PR to a project (that you don’t have push access to) is soooo overkill.
In many cases, it is sufficient to simply send an email with:
> There's a bug in the function `handle_request` in `src/network/core.rs` that can cause it to return a double answer when invoked during a leap second. This fixes that issue: ...
And just include the new function inside of the email body, without attachment.
That should be sufficient for many cases, but many projects do not allow this and demand p.r.s.